Take Away Coin After Losing Match

Share your ideas and feedback to improve our assets!
Post Reply
User avatar
mikalburrows
Contributor
Contributor
Posts: 36
Joined: Tue Nov 05, 2019 4:10 pm

Fri Nov 15, 2019 11:48 am

It would be cool if there was an option for the coin system. That if a player loses a match he/she also loses X amount of coins.
User avatar
Lovatto
Admin
Admin
Posts: 1535
Joined: Sun Dec 07, 2014 3:18 pm
Contact:

Fri Nov 15, 2019 12:05 pm

That sounds more like a personal modification for me :)
You can do it in bl_GameFinish.cs -> CollectData() -> you will see a local variable called "winner" you can use it to check if the player lose the match (winner == false), so if the codition is true (winner == false) -> deduct coins from the player with:

Code: Select all

 bl_DataBase.Instance.SubtractCoins(COINTS_TO_LOSE);
User avatar
mikalburrows
Contributor
Contributor
Posts: 36
Joined: Tue Nov 05, 2019 4:10 pm

Fri Nov 15, 2019 1:23 pm

Lovatto wrote:
Fri Nov 15, 2019 12:05 pm
That sounds more like a personal modification for me :)
You can do it in bl_GameFinish.cs -> CollectData() -> you will see a local variable called "winner" you can use it to check if the player lose the match (winner == false), so if the codition is true (winner == false) -> deduct coins from the player with:

Code: Select all

 bl_DataBase.Instance.SubtractCoins(COINTS_TO_LOSE);
I am pretty novice Dev, and while this seems fairly simple in concept to implement I'm not sure if I understand exactly what and where to add to that script. Sorry if my questions are very noobish. I love your product and want to learn it more.
User avatar
mikalburrows
Contributor
Contributor
Posts: 36
Joined: Tue Nov 05, 2019 4:10 pm

Fri Nov 15, 2019 3:44 pm

Okay so I was able to implement subtracting coins on lost match but does not reflect on the game finish page. How I do I make it display that you have lost coins?
User avatar
Lovatto
Admin
Admin
Posts: 1535
Joined: Sun Dec 07, 2014 3:18 pm
Contact:

Sat Nov 16, 2019 9:44 am

If you're not using Localization addon, in bl_GameFinish.cs find this line:

Code: Select all

CoinsText.text = string.Format("+{0}\n<size=9>COINS</size>", coins);
and replace with:

Code: Select all

        if (winner)
        {
            CoinsText.text = string.Format("+{0}\n<size=9>COINS</size>", coins);
        }
        else
        {
            CoinsText.text = string.Format("-{0}\n<size=9>COINS</size>", LOSS_COINS);
        }
replace the "LOSS_COINS" with the same parameter that you set in bl_DataBase.Instance.SubtractCoins();
User avatar
mikalburrows
Contributor
Contributor
Posts: 36
Joined: Tue Nov 05, 2019 4:10 pm

Sat Nov 16, 2019 3:36 pm

Awesome worked perfect. Thanks Lovatto.
Post Reply