Building upgradable
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
public class Building : MonoBehaviour
|
||||
@@ -18,8 +19,7 @@ public class Building : MonoBehaviour
|
||||
void OnSelectedChanged(){
|
||||
if(Selector.selectedBuilding == null){ToggleOutlines(false); return;}
|
||||
|
||||
ToggleOutlines(Selector.selectedBuilding == this);
|
||||
// Debug.Log(buildingName);
|
||||
ToggleOutlines(Selector.selectedBuilding == this);
|
||||
}
|
||||
|
||||
void ToggleOutlines(bool value){
|
||||
@@ -28,5 +28,14 @@ public class Building : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
public async Task Upgrade(){
|
||||
if(curLevel >= buildingData.levels.Count-1){Debug.Log("Already max");return;}
|
||||
int cost = buildingData.levels[curLevel+1].price;
|
||||
Debug.Log("Upgrading " + buildingData.buildingName + " for " + cost + " coins");
|
||||
|
||||
await (DBmanager.SetCoins(DBmanager.Coins-cost));
|
||||
Mathf.Clamp(curLevel++,0, buildingData.levels.Count-1);
|
||||
}
|
||||
|
||||
/* */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user