private void OnMouseDown() { RaycastHit2D Tile = Physics2D.Raycast(Camera.main.transform.position, Input.mousePosition, float.MaxValue, 8); _tileToAct = Tile.collider.GetComponent <Tile>(); if (_tileToAct.GetPlacedEntity()) { if (_currentState == State.OnSelect) { if (!Units.Contains(targetedUnit)) { targetedUnit = _tileToAct.GetPlacedEntity().GetComponent <IBaseUnitController>(); Attack(); } else { _selectedUnit = _tileToAct.GetPlacedEntity().GetComponent <IBaseUnitController>(); _currentState = State.OnSelect; } } } else if (_currentState == State.OnSelect) { Move(); } }
public void Attack(IBaseUnitController target) { if (CanAttack(target)) { target.TakeDamage(damage); } }
public bool CanAttack(IBaseUnitController unit) { return(AvaliableForAttack.Contains(unit.CurrentTile)); }