void DeselectCurrent() { //Deselect current unit if (selected) { unitScript unit = selected.GetComponent <unitScript>(); if (unit != null && unit.getOwner() == 0) { gui.GetComponent <GUIController>().setCharacterPanelVisibility(false); gui.GetComponent <GUIController>().setCombatPanelVisibility(false); unit.SendMessage("deselect"); if (unit.getOwner() == 0) { GridItem pos = selected.GetComponent <GridItem>(); map.UnHilightMap(); //map.toggleHighlight(false,Color.white, pos.getX(), pos.getY(), unit.getSpeed()); pathFinder.setPathfinding(false); rangeRenderer.enabled = false; attackMode = false; } } } selected = null; }
public void selectUnit(unitScript unit) { GUIController cont = gui.GetComponent <GUIController>(); DeselectCurrent(); selected = unit.gameObject; cont.setCharacterPanelVisibility(true, unit); if (unit.getOwner() == 0) { unit.SendMessage("select"); // IF unit has not moved if (unit != null && !unit.hasMoved()) { // Allow them to if (unit.getOwner() == 0 && unit.hasMoved() == false) { GridItem pos = selected.GetComponent <GridItem>(); pathFinder.getMovementPaths(pos.getPos(), unit.getMovementDistance(), true); //map.toggleHighlight(true, Color.cyan, pos.getX(), pos.getY(), unit.getMovementDistance()); } } } }