Пример #1
0
        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);
        }
Пример #2
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);
    }
Пример #3
0
    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);
    }
Пример #4
0
        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);
        }
Пример #5
0
        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";
        }
Пример #6
0
        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";
            }
        }
Пример #7
0
        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";
        }
Пример #8
0
        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);
        }
Пример #9
0
    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);
    }
Пример #10
0
        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);
        }
Пример #11
0
        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));
        }
Пример #12
0
        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));
        }
Пример #13
0
 public MoveAnimation(HumanPiece piece, Vector2Int position)
 {
     this.piece = piece;
     piece.Move(position.x, position.y);
 }
Пример #14
0
 public Attack(HumanPiece piece)
 {
     this.piece = piece;
 }