コード例 #1
0
 public AllPirates(AttackerList Alist, DefenderList Dlist)
 {
     this.AttackerList = Alist;
     this.DefenderList = Dlist;
 }
コード例 #2
0
        /// <summary>
        /// yaya
        /// </summary>
        /// <param name="game"></param>
        public void DoTurn(PirateGame game)
        {
            GameSettings.game = game;
            if (!GameSettings.START)
            {
                GameSettings.game = game;

                GameSettings.allPirates = OnGameStart(game);
                GameSettings.defList    = GameSettings.allPirates.DefenderList;
                GameSettings.AtkList    = GameSettings.allPirates.AttackerList;
                form = new Formation();

                GameSettings.START = true;
            }

            GeneralMethods.UpdateLists();

            List <Defender> defenders = GameSettings.allPirates.DefenderList;


            foreach (Defender defender in defenders)
            {
                if (defender.IsAlive())
                {
                    if (!GeneralMethods.TryPush(defender.Pirate))
                    {
                        // Enemy capsule defenders work
                        Location start;
                        if ((defenders[0].Equals(defender) || defenders[1].Equals(defender)))
                        {
                            defender.Layer = Roles.front;
                            if (defender.DefendFrom(game) == null)
                            {
                                start = defender.ProtectFromCarriers(0, game);
                                defender.Pirate.Sail(start);
                            }
                            else
                            {
                                defender.Pirate.Sail(defender.DefendFrom(game));
                            }
                        }
                        else if (defenders[2].Equals(defender) || defenders[3].Equals(defender))
                        {
                            defender.Layer = Roles.backup;
                            if (defender.DefendFrom(game) == null)
                            {
                                start = defender.ProtectFromCarriers(450, game);
                                defender.Pirate.Sail(start);
                            }
                            else
                            {
                                defender.Pirate.Sail(defender.DefendFrom(game));
                            }
                        }
                    }
                }
            }



            if (GameSettings.game.GetMyCapsule().Holder != null)
            {
                AttackerList list    = GameSettings.AtkList;
                Pirate       carrier = GameSettings.game.GetMyCapsule().Holder;
                form.RoleAssign(carrier);
                foreach (Attacker a in list)
                {
                    if (!a.Pirate.Equals(carrier) && a.Pirate.Distance(carrier) < 800)
                    {
                        form.RoleAssign(a.Pirate);
                    }
                    else if (a.Pirate.Distance(carrier) >= 800)
                    {
                        a.Pirate.Sail(carrier.Location);
                    }
                }
                GameSettings.game.Debug("carrier = " + form.Carrier);
                GameSettings.game.Debug("body1 = " + form.Bodyguard);
                GameSettings.game.Debug("body2 = " + form.Bodyguard2);
                GameSettings.game.Debug("tail = " + form.HeadGuard);

                form.SailToTarget(GameSettings.game.GetMyMothership().Location);
            }
            else
            {
                form.ClearRoles();

                foreach (Attacker a in GameSettings.AtkList)
                {
                    if (!GeneralMethods.TryPush(a.Pirate))
                    {
                        a.Pirate.Sail(GameSettings.game.GetMyCapsule().Location);
                    }
                }
            }
        }