public override void DoClickTargetSpace(ClickableSpace space) { Game game = Game.Instance(); Unit unit = game.GetSelectedUnit(); unit.DoMoveTo(space.pos); DefaultState(); }
public override void DoClickTargetSpace(ClickableSpace space) { bool casted = ability.DoClickTarget(space.pos); if (casted) { DefaultState(); } }
public static ClickableSpace Create(int x, int y, Type type) { // TODO cache Transform parent = GameObject.Find("ClickableSpaces").transform; ClickableSpace s = Factory.Create <ClickableSpace>("ClickableSpace"); s.transform.parent = parent; s.pos = new Coord(x, y); s.type = type; return(s); }
public override void DoClickOnUnit(Unit unit) { // Try to cast on tile unit is standing on // ClickableSpace space = Game.Instance().tileLayer.FindTile(unit.pos); if (space != null) { DoClickTargetSpace(space); } else { // Clicked on unit out of range/untargettable // // Fall back to default behavior? // // base.DoClickOnUnit(unit); } }
public virtual void DoClickTargetSpace(ClickableSpace space) { WrongState("DoClickAbilitySpace"); }
public ClickableSpace[] LayTiles(int x, int y, int r, ClickableSpace.Type type) { ClearTiles(); Board board = Game.Instance().board; List <ClickableSpace> createdSpaces = new List <ClickableSpace>(); // TODO size? const int size = 64; CoordState[,] coords = new CoordState[size, size]; List <Coord> results = new List <Coord>(); List <Coord> q = new List <Coord>(); // Algorithm #1 // q.Add(new Coord(x, y)); coords[x, y] = CoordState.Visited; for (int i = 0; i <= r; i++) { List <Coord> newQ = new List <Coord>(); foreach (Coord p in q) { if (i != 0) { bool shouldAdd = false; if (type == ClickableSpace.Type.Move) { // Can we move to the tile? // bool canMove = false; if (board.IsEmpty(p)) { canMove = true; } shouldAdd = canMove; } else { // Can we attack the tile? // shouldAdd = true; } if (shouldAdd) { results.Add(p); } } if (i != r) { AddIfNotVisited(coords, newQ, p.x + 1, p.y); AddIfNotVisited(coords, newQ, p.x, p.y + 1); AddIfNotVisited(coords, newQ, p.x - 1, p.y); AddIfNotVisited(coords, newQ, p.x, p.y - 1); } } q = newQ; } foreach (Coord p in results) { ClickableSpace space = ClickableSpace.Create(p.x, p.y, type); createdSpaces.Add(space); } ClickableSpace[] createdSpacesArray = createdSpaces.ToArray(); currentTiles = createdSpacesArray; return(createdSpacesArray); }