public void Update() { if (current == null) { current = Game.instance.SelectedPiece() as HumanPiece; } if (current == null) { return; } List <Tile> possibleMoves = null; try { possibleMoves = active[current]; } catch (Exception) { } if (possibleMoves == null) { current = null; return; } foreach (KeyValuePair <HumanPiece, List <Tile> > entry in active) { entry.Key.Unselect(); } current.Select(); Game.instance.currentState = new Move(current, active); }
int PossibleDamage(Tile position, HumanPiece humanPiece) { int res = 0; Vector2Int myPos = new Vector2Int(x, y); Vector2Int enemyPosition = new Vector2Int(humanPiece.x, humanPiece.y); Move(position.x, position.y, false); List <Tile> possibleMoves = humanPiece.GetPosibleMoves(); foreach (Tile move in possibleMoves) { humanPiece.Move(move.x, move.y, false); bool requireChoice; List <Piece> attacksPossibilities = humanPiece.GetAttackPossibilities(out requireChoice); if (attacksPossibilities.Contains(this)) { res += humanPiece.damage; break; } } Move(myPos.x, myPos.y, false); humanPiece.Move(enemyPosition.x, enemyPosition.y, false); return(res); }
public override List <Piece> GetAttackPossibilities(out bool requireChoice) { List <Piece> res = new List <Piece>(); for (int k = 0; k < 9; ++k) { if (k == 4) { continue; } Vector2Int adjacentLocation = new Vector2Int(k / 3, k % 3) - new Vector2Int(1, 1) + new Vector2Int(x, y); try { HumanPiece piece = Game.instance.pieces[adjacentLocation.x, adjacentLocation.y] as HumanPiece; if (piece != null) { res.Add(piece); } } catch (Exception) { } } if (res.Count > 1) { requireChoice = true; } else { requireChoice = false; } return(res); }
public DroneAttackAnimation(Drone drone, HumanPiece target) { this.drone = drone; this.target = target; List <Piece> tmp = new List <Piece>(); tmp.Add(target); LazerAnimation.lazerAnimation.Animate(drone, tmp); }
public Move(HumanPiece current, Dictionary <HumanPiece, List <Tile> > active) { this.current = current; this.active = active; moves = active[current]; InfoPanel infoPanel = Game.instance.InfoPanel.GetComponent <InfoPanel>(); infoPanel.InfoText.text = "Select a Tile to Move to"; }
public SelectPiece(Dictionary <HumanPiece, List <Tile> > active, HumanPiece current = null) { this.active = active; this.current = current; if (current == null) { Game.instance.InfoPanel.SetActive(true); InfoPanel infoPanel = Game.instance.InfoPanel.GetComponent <InfoPanel>(); infoPanel.InfoText.text = "Select piece to Move"; } }
public ChooseTarget(HumanPiece attacking, List <AIPiece> targets) { this.attacking = attacking; this.targets = targets; foreach (AIPiece piece in targets) { piece.Select(); } Game.instance.InfoPanel.SetActive(true); Game.instance.InfoPanel.GetComponent <InfoPanel>().InfoText.text = "Choose a Target to Attack"; }
public AttackAnimation(HumanPiece attacking, List <AIPiece> targets) { this.attacking = attacking; this.targets = targets; List <Piece> AITargets = new List <Piece>(); foreach (AIPiece p in targets) { AITargets.Add(p); } LazerAnimation.lazerAnimation.Animate(attacking, AITargets); }
public HumanPiece getNearestEnemy() { double minDist = 1000; HumanPiece nearest = null; foreach (HumanPiece humanPiece in HumanPiece.HumanPieces) { Vector3 offset = humanPiece.monoBehaviour.transform.position - monoBehaviour.transform.position; if (offset.magnitude < minDist) { minDist = offset.magnitude; nearest = humanPiece; } } return(nearest); }
public void Update() { Dictionary <HumanPiece, List <Tile> > active = HumanPiece.ActivePieces(); if (active.Count == 0) { Game.instance.currentState = new AI.BeginTurn(); return; } foreach (KeyValuePair <HumanPiece, List <Tile> > entry in active) { entry.Key.Select(); } Game.instance.currentState = new SelectPiece(active); }
public void Update() { foreach (Tile t in moves) { t.Select(); } HumanPiece piece = Game.instance.SelectedPiece() as HumanPiece; if (piece != null) { Game.instance.UnselectAllTiles(); current.Unselect(); if (active.ContainsKey(piece)) { Game.instance.currentState = new SelectPiece(active, piece); return; } Game.instance.currentState = new ActivePieces(); return; } Tile tile = Game.instance.SelectedTile(); if (tile == null || !tile.isSelected) { return; } Game.instance.UnselectAllTiles(); current.Unselect(); Game.instance.InfoPanel.SetActive(false); Game.instance.currentState = new MoveAnimation(current, new Vector2Int(tile.x, tile.y)); }
public void Update() { if (moves.Count > 1) { HumanPiece nearest = dreadnought.getNearestEnemy(); Tile enemyPosition = Game.instance.board[nearest.x, nearest.y]; double minDist = 100; Tile bestMove = null; foreach (Tile move in moves) { Vector3 offset = enemyPosition.transform.position - move.transform.position; if (offset.magnitude < minDist) { minDist = offset.magnitude; bestMove = move; } } moves.Clear(); moves.Add(bestMove); } Game.instance.currentState = new MoveDreadnoughtAnimation(dreadnought, new Vector2Int(moves[0].x, moves[0].y)); }
public MoveAnimation(HumanPiece piece, Vector2Int position) { this.piece = piece; piece.Move(position.x, position.y); }
public Attack(HumanPiece piece) { this.piece = piece; }