override public void castAbility() { base.castAbility(); basicRange = unit.Range; unit.Range = castRange; List <Cell> listCells = PathfindingTool.cellsInRadius(unit.currentCell, castRange); int maxTargetTouch = 0; Cell bestTargetCell = null; List <Unit> listUnitsTouch = new List <Unit>(); foreach (Cell cell in listCells) { List <Unit> listUnitsTouchProv = PathfindingTool.unitsInRadius(cell, areaOfEffect, unit.getTargetTag()); int maxTargetTouchProv = listUnitsTouchProv.Count; if (maxTargetTouchProv > maxTargetTouch) { bestTargetCell = cell; maxTargetTouch = maxTargetTouchProv; listUnitsTouch = listUnitsTouchProv; } } if (bestTargetCell != null) { List <Cell> listCellsTouched = PathfindingTool.cellsInRadius(bestTargetCell, areaOfEffect); StartCoroutine(ProjectileAnimation(bestTargetCell, listCellsTouched)); unit.Range = basicRange; } }
private void DesactivateArea(Cell center) { if (center != null) { List <Cell> affectedCells = PathfindingTool.cellsInRadius(center, range); foreach (Cell cell in affectedCells) { if (cell != null) { cell.SetColor(Color.white); if (cell.GetCurrentUnit() != null) { cell.GetCurrentUnit().desactivateOutline(); } } } } }
private void ActivateArea(Cell center) { if (center != null) { List <Cell> affectedCells = PathfindingTool.cellsInRadius(center, range); foreach (Cell cell in affectedCells) { if (cell != null) { cell.SetColor(Color.red); //new Color(Color.red.r, Color.red.g, Color.red.b,0.9f) if (cell.GetCurrentUnit() != null) { switch (race) { case (Race.Orc): if (cell.GetCurrentUnit().getRace() == Race.Orc) { cell.GetCurrentUnit().activateOutline(); outlinedUnit.Add(cell.GetCurrentUnit()); } break; case (Race.Skeleton): if (cell.GetCurrentUnit().getRace() == Race.Human) { cell.GetCurrentUnit().activateOutline(); outlinedUnit.Add(cell.GetCurrentUnit()); } break; case (Race.Octopus): if (cell.GetCurrentUnit().getRace() == Race.Human) { cell.GetCurrentUnit().activateOutline(); outlinedUnit.Add(cell.GetCurrentUnit()); } break; case (Race.Elemental): if (cell.GetCurrentUnit().getRace() == Race.Human) { cell.GetCurrentUnit().activateOutline(); outlinedUnit.Add(cell.GetCurrentUnit()); } break; case (Race.Giant): if (cell.GetCurrentUnit().getRace() == Race.Giant) { cell.GetCurrentUnit().activateOutline(); outlinedUnit.Add(cell.GetCurrentUnit()); } break; case (Race.Ratman): break; case (Race.Demon): break; } } } } } }