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); } }
/// <summary> /// Handles all messages recieved with a vector in the message /// </summary> /// <param name="MSG">The message</param> /// <param name="POS">The position attached to the message</param> public void OnRecieveMessage(string MSG, Vector3 POS, TowerSpawnPoint TSP) { IDebug.DebugVerbose("\"" + this.name + "\" has recieved a message: \"" + MSG + "\" with vector \"" + POS + "\"."); m_currentTowerSpawnPoint = TSP; if (MSG == "MOVE_TOWER_UI") { MOVETOWERUI(POS); } }
void HIGHLIGHT_MSG(GameObject OBJ) { if (previousTowerSpawnPoint == null && currentTowerSpawnPoint == null) { currentTowerSpawnPoint = OBJ.GetComponent <TowerSpawnPoint>(); MsgJunction.instance.SendTowerSpawnMsg("HIGHLIGHT", currentTowerSpawnPoint, true); } else { previousTowerSpawnPoint = currentTowerSpawnPoint; currentTowerSpawnPoint = OBJ.GetComponent <TowerSpawnPoint>(); MsgJunction.instance.SendTowerSpawnMsg("HIGHLIGHT", previousTowerSpawnPoint, false); MsgJunction.instance.SendTowerSpawnMsg("HIGHLIGHT", currentTowerSpawnPoint, true); } }
/// <summary> /// Handles all query messages /// </summary> /// <param name="IDToQuery"></param> public void OnMessageRecieved(int IDToQuery, TowerSpawnPoint TSP) { IDebug.DebugVerbose("\"" + this.name + "\" has recieved a message: \"" + IDToQuery + "\" with TowerSpawnPoint \"" + TSP.name + "\"."); GameObject Obj; try { Obj = Database[IDToQuery]; } catch { IDebug.LogError("TowerDatabaseManager (\"" + this.name + "\") does not have a entry with the ID \"" + IDToQuery + "\"."); return; } MsgJunction.instance.SendTowerSpawnMsg("SPAWN_TOWER", TSP, Obj); }
/// <summary> /// Handles all messages to be sent to the TowerDatabaseManager through querying. If the ID corosponds to a actual entry it wil be sent to te given TowerSpawnPoint. /// </summary> /// <param name="IDToQuery">self explanitory</param> public void SendQueryMsg(int IDToQuery, TowerSpawnPoint TSP) { TDMReciever.OnMessageRecieved(IDToQuery, TSP); }
/// <summary> /// Handles messages being sent to a tower spawn point with a Gameobject in the message /// </summary> /// <param name="MSG">The Message</param> /// <param name="Reciever">The tower spawn point to recieve the message</param> /// <param name="OBJ">The object to send with the message</param> public void SendTowerSpawnMsg(string MSG, TowerSpawnPoint Reciever, GameObject OBJ) { Reciever.OnMessageRecieved(MSG, OBJ); }
/// <summary> /// Handles messages being sent to a tower spawn point with a bool in the message /// </summary> /// <param name="MSG">The message</param> /// <param name="Reciever">The tower spawn point to recieve the message</param> /// <param name="T_F">true or false</param> public void SendTowerSpawnMsg(string MSG, TowerSpawnPoint Reciever, bool T_F) { Reciever.OnMessageRecieved(MSG, T_F); }
/// <summary> /// Handles messages to the UI message reciever with a position and TowerSpawnPoint in the message /// </summary> /// <param name="MSG">The message to send</param> /// <param name="POS">A vector to give the reciever</param> public void SendUIMsg(string MSG, Vector3 POS, TowerSpawnPoint TSP) { UIMsgReciever.OnRecieveMessage(MSG, POS, TSP); }