Esempio n. 1
0
    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);
    }
Esempio n. 2
0
        public void Update()
        {
            bool         requireChoice;
            List <Piece> attackPosibilities = piece.GetAttackPossibilities(out requireChoice);

            if (attackPosibilities.Count == 0)
            {
                Game.instance.currentState = new ActivePieces();
                return;
            }

            List <AIPiece> AITargets = new List <AIPiece>();

            foreach (Piece p in attackPosibilities)
            {
                if (p as AIPiece != null)
                {
                    AITargets.Add(p as AIPiece);
                }
            }

            if (requireChoice)
            {
                Game.instance.currentState = new ChooseTarget(piece, AITargets);
                return;
            }

            Game.instance.currentState = new AttackAnimation(piece, AITargets);
        }