public static Tower Create(string type, TowerSpawnPoint spawn) { GameObject tower; if (GameSession.Instance.isNetworkGame) { tower = (GameObject)Network.Instantiate(PrefabManager.PrefabTowers[type], spawn.transform.parent.position, Quaternion.identity, 0); } else { tower = (GameObject)Instantiate(PrefabManager.PrefabTowers[type], spawn.transform.parent.position, Quaternion.identity); } Tower towerData = tower.GetComponentInChildren <Tower>(); towerData.Init(spawn.firingRadius); if (spawn.ring != null) { spawn.ring.obj = towerData; spawn.ring.toInit = true; } if (GameSession.Instance.isNetworkGame) { Network.Destroy(spawn.transform.parent.gameObject); } else { Destroy(spawn.transform.parent.gameObject); } GameSession.Instance.credits -= Constants.TowerBuildCosts[type]; UIScreenTextController.MakeGoldText(0, "-$" + Constants.TowerBuildCosts[type], spawn.transform.position); return(towerData); }
public void Sell() { GameObject obj; if (GameSession.Instance.isNetworkGame) { obj = (GameObject)Network.Instantiate(PrefabManager.PrefabTowerSpawnPoint, transform.parent.position, Quaternion.identity, 0); } else { obj = (GameObject)Instantiate(PrefabManager.PrefabTowerSpawnPoint, transform.parent.position, Quaternion.identity); } TowerSpawnPoint spawn = obj.GetComponentInChildren <TowerSpawnPoint>(); spawn.toInit = false; spawn.firingRadius = firingRadius; ring.obj = spawn; ring.toInit = true; GameSession.Instance.credits += SellingCost; UIScreenTextController.MakeGoldText(0, "+$" + SellingCost, transform.position); if (GameSession.Instance.isNetworkGame) { Network.Destroy(transform.parent.gameObject); } else { Destroy(transform.parent.gameObject); } }
protected void showGoldGain(int val) { if (val == 0) { return; } GameSession session = GameSession.Instance; session.credits += val; UIScreenTextController.MakeGoldText(iconHeightOffset, "+$" + val, transform.position); }
void showDamageIcon(int val, bool poison) { string prefix = ""; if (poison) { prefix = "#"; } if (val > 0) { UIScreenTextController.MakeHealText(iconHeightOffset, val.ToString(), transform.position); } else if (val < 0) { UIScreenTextController.MakeDamageText(iconHeightOffset, prefix + Mathf.Abs(val).ToString(), transform.position); } }
public bool Upgrade() { GameSession session = GameSession.Instance; if (Level > 2) { return(false); } int cost = UpgradeCost; if (cost <= session.credits) { Level++; swapTowerSkin(); updateFiringRadius(); session.credits -= cost; UIScreenTextController.MakeGoldText(0, "-$" + cost, transform.position); return(true); } return(false); }
public static void MakeGoldText(float upOff, string inText, Vector3 pos) { UIScreenTextController obj = Create(); obj.Init(upOff, inText, pos, yellow); }
public static void MakeDamageText(float upOff, string inText, Vector3 pos) { UIScreenTextController obj = Create(); obj.Init(upOff, inText, pos, red); }