Take Away Coin After Losing Match
- mikalburrows
- Contributor
- Posts: 36
- Joined: Tue Nov 05, 2019 4:10 pm
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.
- Lovatto
- Admin
- Posts: 1834
- Joined: Sun Dec 07, 2014 3:18 pm
- Contact:
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:
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);
- mikalburrows
- Contributor
- Posts: 36
- Joined: Tue Nov 05, 2019 4:10 pm
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.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);
- mikalburrows
- Contributor
- Posts: 36
- Joined: Tue Nov 05, 2019 4:10 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?
- Lovatto
- Admin
- Posts: 1834
- Joined: Sun Dec 07, 2014 3:18 pm
- Contact:
If you're not using Localization addon, in bl_GameFinish.cs find this line:
and replace with:
replace the "LOSS_COINS" with the same parameter that you set in bl_DataBase.Instance.SubtractCoins();
Code: Select all
CoinsText.text = string.Format("+{0}\n<size=9>COINS</size>", coins);
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);
}
- mikalburrows
- Contributor
- Posts: 36
- Joined: Tue Nov 05, 2019 4:10 pm
Awesome worked perfect. Thanks Lovatto.