private void Update() { if (_gameManager.IsGameOnPause) { return; } if (_gameManager.IsTowerMenuOpen && Input.GetMouseButtonDown(0) && !Mouse.IsMouseOverUI()) { Messenger.Broadcast(GameEvent.PLAY); return; } if (!Input.GetMouseButtonDown(0) || Mouse.IsMouseOverUI()) { return; } if (!Mouse.GetGameObjectPointed(out var hit)) { return; } if (hit.CompareTag(Tag.BuildBlockTag)) { _selectedBlock = hit.GetComponent <SpawnTower>(); ClickOnBuildBlock(); } else if (hit.CompareTag(Tag.TowerTag)) { Debug.Log("Click o tower"); _selectedTowerState = hit.GetComponent <TowerState>(); _selectedBlock = _selectedTowerState.Block; OpenUpdateSellMenu(); } }
private IEnumerator CommandInvoker() { while (true) { yield return(new WaitUntil(() => isCommandReceive)); switch (command) { case Commands.SpawnUnit: SpawnTower.SpawnUnit((Tower.TypeUnits)buffer[1], true); break; case Commands.SetPos: int idHexagon = BitConverter.ToInt32(FromBuffer(1, 4), 0); int idUnit = BitConverter.ToInt32(FromBuffer(5, 4), 0); Hexagon hexagon = HexagonField.GetChild(idHexagon).GetComponent <Hexagon>(); foreach (var unit in cacheUnit) { if (unit.IdUnit == idUnit) { hexagon.MoveHere(unit); break; } } break; } isCommandReceive = false; yield return(new WaitForEndOfFrame()); } }
public void UpdateUI(SpawnTower selectedBlock, TowerState selectedTowerState) { sellButton.UpdateButton(selectedTowerState.Price); upgradeButton.UpdateButton(selectedTowerState.Type, selectedTowerState.TowerLevel); towerMenu.transform.position = PositionHelper.OnTop( selectedBlock.Tower.transform, selectedBlock.Tower.transform.localScale.y ); }
void Start() { // This time the Start() function is really useful to us. // I really like preparing all the rects that the GUI // functions need. I also like keeping a copy of the // half point of the screen which will probably come // handy later on. If not, we can always remove it! // Check the OnGUI () for more on Rects. stInstance = gameObject.GetComponent <SpawnTower> (); widthMid = Screen.width / 2; heightMid = Screen.height / 2; selected = "None"; selectedRect = new Rect(10, 10, 100, 50); creditsRect = new Rect(10, 30, 100, 50); tower1Rect = new Rect(10, Screen.height - 110, 100, 100); removeRect = new Rect(Screen.width - 110, Screen.height - 110, 100, 100); int nameLenght = 10 * ImportMap.mapName.Length; nameRect = new Rect(Screen.width - 25 - nameLenght, 10, nameLenght, 50); }
void Start() { SpawnTower = GameObject.Find("Nodes").GetComponent <SpawnTower>(); }
void Start() { // This time the Start() function is really useful to us. // I really like preparing all the rects that the GUI // functions need. I also like keeping a copy of the // half point of the screen which will probably come // handy later on. If not, we can always remove it! // Check the OnGUI () for more on Rects. stInstance = gameObject.GetComponent<SpawnTower> (); widthMid = Screen.width / 2; heightMid = Screen.height / 2; selected = "None"; selectedRect = new Rect (10, 10, 100, 50); creditsRect = new Rect (10, 30, 100, 50); tower1Rect = new Rect (10, Screen.height - 110, 100, 100); removeRect = new Rect (Screen.width - 110, Screen.height - 110, 100, 100); int nameLenght = 10 * ImportMap.mapName.Length; nameRect = new Rect (Screen.width - 25 - nameLenght, 10, nameLenght, 50); }