void OnMouseUp() { grid.HideAllTiles(); if (_eventUID == uidEvents.EVENT_ONTILE) { _eventUID = uidEvents.EVENT_SPAWN; } else { _eventUID = uidEvents.EVENT_IDLE; } }
void OnMouseUp() { _grid.HideAllTiles(); if (_currentEvent == Events.ON_TILE) { _currentEvent = Events.SPAWN; } else { _currentEvent = Events.IDLE; } }
void UpdateEvents() { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; Debug.DrawRay(ray.origin, ray.direction * 100, Color.red); if (Physics.Raycast(ray, out hit)) { if (Input.GetMouseButtonDown(0)) { if (_currentEvents == Events.SELECTED) { if (hit.transform.name == Constants.NAME_MOVE_BUTTON) { _currentEvents = Events.MOVING; _gSystem.ShowAllTiles(0); _gSystem.ShowAllTiles(1); UpdateTiles(); } else if (hit.transform.name == Constants.NAME_UPGRADE_BUTTON) { _currentEvents = Events.UPGRADE; UpgradeStructure(); } else { _currentEvents = Events.IDLE; } Destroy(GameObject.FindGameObjectWithTag(Constants.TAG_SELECTED_BUTTONS)); buttonsSpawned = false; _sController.EnableAllRays(); Gridsystem.EnableAllRays(); } else if (_currentEvents == Events.MOVING) { if (hit.transform.name == Constants.NAME_TILE) { if (openList.Contains(hit.transform.GetComponent <Gridtile>())) { Gridsystem.getGridTile(transform.position).occupied = false; transform.position = new Vector3(hit.transform.position.x, hit.transform.position.y + 0.4f, hit.transform.position.z); hit.transform.GetComponent <Gridtile>().occupied = true; Reset(); _gSystem.HideAllTiles(0); _gSystem.HideAllTiles(1); _sController.hasUpMoved = true; _currentEvents = Events.IDLE; } else { _currentEvents = Events.IDLE; Reset(); _gSystem.HideAllTiles(0); _gSystem.HideAllTiles(1); } } else { _currentEvents = Events.IDLE; Reset(); _gSystem.HideAllTiles(0); _gSystem.HideAllTiles(1); } } else if (_currentEvents == Events.IDLE) { if (hit.transform == _sController.hitPoint.transform) { _currentEvents = Events.SELECTED; ShowMiniMenu(); _sController.DisableAllRays(); Gridsystem.DisableAllRays(); } } } } }