private bool HaveUnitOnTheWay(Vector3Int selectedPosition, Vector3 differencePosition) { if (selectedPosition.x != 0f) { for (int i = 1; i < Mathf.Abs(differencePosition.x); ++i) { Vector3 checkStep = new Vector3(Mathf.Sign(differencePosition.x), 0f, 0f); Vector3 currentPositionForCheck = selectedPosition - i * checkStep; if (listOfTheLiving.GetUnitOnPosition(currentPositionForCheck) != null) { return(true); } } } if (selectedPosition.y != 0f) { for (int i = 1; i < Mathf.Abs(differencePosition.y); ++i) { Vector3 currentPositionForCheck = selectedPosition - (new Vector3(0f, i * Mathf.Sign(differencePosition.y), 0f)); if (listOfTheLiving.GetUnitOnPosition(currentPositionForCheck) != null) { return(true); } } } return(false); }
protected bool KillEnemieUnit() { Unit attackedUnit = listOfTheLiving.GetUnitOnPosition(board.SelectedPosition); if (attackedUnit != null) { attackedUnit.IsDead(); return(true); } return(false); }
private bool HaveUnitOnTheWay(Vector3Int selectedPosition, Vector3 differencePosition) { Vector3 checkStep = new Vector3(Mathf.Sign(differencePosition.x), Mathf.Sign(differencePosition.y), 0); for (int i = 1; i < Mathf.Abs(differencePosition.x); ++i) { Vector3 currentPositionForCheck = transform.position + i * checkStep; if (listOfTheLiving.GetUnitOnPosition(currentPositionForCheck) != null) { return(true); } } return(false); }
private bool UnitWasSelected() { Unit unit = listOfTheLiving.GetUnitOnPosition(board.SelectedPosition); if (unit != null) { if (unit.IsWhite && currentPlayer == Players.White) { UpdateSelectedUnit(unit); return(true); } if (!unit.IsWhite && currentPlayer == Players.Black) { UpdateSelectedUnit(unit); return(true); } } return(false); }