Пример #1
0
        private List <ACommand> GetValidAttacks()
        {
            List <ACommand> validAtks = new List <ACommand>();

            foreach (ABasicPawn pawn in CurPlayer.GetPawns())
            {
                foreach (ABasicPawn enemy in GetOponent().GetPawns())
                {
                    if (Coord.Distance(pawn.Position, enemy.Position) < pawn.MovePoints)
                    {
                        AttackCommand atk = new AttackCommand();
                        atk.SetUp(Boards, CurPlayer, GetOponent());
                        atk.SetUp(pawn.Position, enemy.Position, CurPlayer, GetOponent(), Boards);
                        if (atk.IsValid())
                        {
                            validAtks.Add(atk);
                        }
                    }
                }
            }

            return(validAtks);
        }
Пример #2
0
        private AttackCommand SetUpAttack(Board boards, Player oponent)
        {
            AttackCommand attackCmd = new AttackCommand();
            Coord         selPos    = boards.SelectUnit(Pawns);
            Coord         cursorCp  = new Coord(Cursor.X, Cursor.Y);

            Cursor = selPos;
            if (GetPawnAt(selPos) is ABasicPawn ally)
            {
                Dijkstra     didi     = new Dijkstra(boards.GetBoard(), selPos, ally.AtkRange);
                List <Coord> atkRange = didi.GetValidPaths(Command.ATTACK);
                Coord        enemyPos = boards.SelectPosition(cursorCp, selPos, Command.ATTACK, atkRange);

                // Set up command variables
                attackCmd.SetUp(selPos, enemyPos, this, oponent, boards);
            }
            return(attackCmd);
        }