Ejemplo n.º 1
0
    public void AttackMode(ICellRange range)
    {
        if (_canAttack)
        {
            if (_selectedCells != null)
            {
                foreach (var cell in _selectedCells)
                {
                    cell.Unhighlight();
                }
            }

            //Please don't look at this
            if (UnitType == UnitType.SOLDIER)
            {
                _selectedCells = range.GetCellsInRange(Position, MaxRange, true);
            }
            else if (UnitType == UnitType.SNIPER)
            {
                _selectedCells = range.GetCellsInLineRange(Position);
            }

            foreach (var cell in _selectedCells)
            {
                cell.Highlight();
            }
        }
    }
Ejemplo n.º 2
0
 public void Select(ICellRange range)
 {
     if (!_selected)
     {
         _selected      = true;
         _selectedCells = range.GetCellsInRange(Position, _currentRange, false);
         foreach (var cell in _selectedCells)
         {
             cell.Highlight();
         }
     }
 }
Ejemplo n.º 3
0
 public void Attack(Unit u, ICellRange range)
 {
     if (_canAttack && u.Player != Player)
     {
         List <Cell> cellsInRange = null;
         if (UnitType == UnitType.SOLDIER)
         {
             cellsInRange = range.GetCellsInRange(Position, MaxRange, true);
         }
         else if (UnitType == UnitType.SNIPER)
         {
             cellsInRange = range.GetCellsInLineRange(Position);
         }
         if (cellsInRange.Contains(u.Position))
         {
             StartCoroutine(Attack(u, 0.6f));
             _canAttack    = false;
             _currentRange = 0;
         }
     }
 }
Ejemplo n.º 4
0
    public void Move(ICellRange range, Cell targetCell)
    {
        var cellsInRange = range.GetCellsInRange(Position, _currentRange, false);

        foreach (var cell in cellsInRange)
        {
            if (cell.Position.Equals(targetCell.Position))
            {
                if (targetCell.CanMove() && _isMoving == false)
                {
                    var path = GetComponent <Pathfinder>().FindPath(Position, targetCell);
                    if (path == null)
                    {
                        return;
                    }

                    _currentRange -= path.Count;
                    StartCoroutine(Move(path, 0.6f));
                    return;
                }
            }
        }
    }