public void ReturnMana(Spell spell, int [] cellCoord) { int cellLine = cellCoord [0]; int cellNum = cellCoord [1]; print(cellLine + " " + cellNum); Cell cell = field.GetCell(cellLine, cellNum); Vector2 cellPos = cell.transform.position; if (!cell.IsEngaged) { PrintMessage("Nothing to return!"); EndCasting(); return; } if (spell.cost > wizard.GetManapoints()) { PrintMessage("You have no mana!"); EndCasting(); return; } List <Tower> lineTowers = ec.lines [cellLine].lineTowers; Tower towerToDestroy = null; for (int i = 0; i < lineTowers.Count; i++) { Tower towerTmp = lineTowers [i]; if (towerTmp != null) { if (towerTmp.GetCell() == field.GetCell(cellLine, cellNum)) { towerToDestroy = towerTmp; } } } if (towerToDestroy) { StartCoroutine(PrepareSpell(Constants.RETURN_TOWER, spell, towerToDestroy, null, null, null, null)); wizard.ManaWaste(spell.cost); PrintMessage(spell.spellName); return; } List <Trap> lineTraps = ec.lines [cellLine].lineTraps; Trap trapToDestroy = null; for (int i = 0; i < lineTraps.Count; i++) { Trap trapTmp = lineTraps [i]; if (trapTmp != null) { if (trapTmp.GetCell() == field.GetCell(cellLine, cellNum)) { trapToDestroy = trapTmp; } } } if (trapToDestroy) { StartCoroutine(PrepareSpell(Constants.RETURN_TRAP, spell, null, trapToDestroy, null, null, null)); wizard.ManaWaste(spell.cost); PrintMessage(spell.spellName); return; } if (!trapToDestroy && !towerToDestroy) { PrintMessage("Bad attempt!"); EndCasting(); } }