void Update() { // HP bar UI functions if (hpBar._localScale.x > (float)unitParameters.CHP / (float)unitParameters.MHP) { hpBar.ChangeLocalScale((float)unitParameters.CHP / (float)unitParameters.MHP); } // Unit is in attacking phase if (isAttacking) { unitSelectable.OscillateHighlight(true); //AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA GameObject foundUnitObject = null; if (Input.GetMouseButton(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 1000f)) { foundUnitObject = hit.transform.gameObject; // If attack is impossible, deselect the found unit // and put selector back to this unit if (foundUnitObject != null) { PrepareAttackOn(foundUnitObject); foundUnitObject.GetComponent <UnitStateController>().DeselectUnit(); unitSelectable.SelectThis(true); unitSelectable.OscillateHighlight(false); //AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA } } } if (Input.GetKeyDown(KeyCode.Z)) { Debug.Log("Deselected " + unitData.UnitName + " via attack cancel"); if (foundUnitObject != null) { foundUnitObject.GetComponent <UnitStateController>().DeselectUnit(); } unitSelectable.OscillateHighlight(false); //AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA isAttacking = false; } } else if (unitSelectable.GetSelectStatus()) { if (!moveIsDone) { if (battleState.isPlayerTurn && unitData.UnitTeam == Team.HERO || !battleState.isPlayerTurn && unitData.UnitTeam == Team.ENEMY) { battleNavigate.Move(); } } //ESCAPE to deselect unit if (Input.GetKeyDown(KeyCode.Escape)) { unitSelectable.SelectThis(false); Debug.Log("Deselected a selectable via esc"); } //SPACE to simulate unit performing an action if (Input.GetKeyDown(KeyCode.Space) && !actionIsDone) { DoneActing(); } //Simulate a unit getting damaged if (Input.GetKeyDown(KeyCode.F)) { unitParameters.CHP -= 10; HPChange(10); Debug.Log(unitParameters.CHP); if (unitParameters.CHP <= 0) { KillUnit(); } } //Hit Z to simulated a selected unit to be in attacking phase if (Input.GetKeyDown(KeyCode.Z) && !actionIsDone) { Attacking(); } if (Input.GetKeyDown(KeyCode.B) && moveIsDone && !actionIsDone) { battleNavigate.Return(); moveIsDone = false; } } }