Пример #1
0
        private int timePerRound  = 5000; // 15 seconds

        public Battle(ScrapWarsApp scrapWarsApp, GraphicsDevice graphics, GameWindow window, Map map, Team teamOne, Team teamTwo)
            : base(scrapWarsApp, graphics, window)
        {
            currentBattleState = BattleState.Unfinished;
            SubscribeToEvents();

            this.map     = map;
            this.teamOne = teamOne;
            this.teamTwo = teamTwo;

            bullets = new List <Bullet>();

            allMechs = new List <Mech>();
            foreach (Mech mech in teamOne.Mechs)
            {
                mech.RestoreDefaultState( );
                allMechs.Add(mech);
            }
            foreach (Mech mech in teamTwo.Mechs)
            {
                mech.RestoreDefaultState( );
                allMechs.Add(mech);
            }

            mapChanged            = true;
            battlePaused          = true;
            upperLeftOfView       = Vector2.Zero;
            GameSettings.TileSize = GameTextureRepo.tileDirt.Width;

            battleDrawer = new BattleDrawer(this, graphics, spriteBatch);
            battleInput  = new BattleInput(this);
            battleLogic  = new BattleLogic(this);

            battleLogic.PlaceTeams(teamOne, teamTwo);
        }
Пример #2
0
    private void CreateBattle()
    {
        var id = BattleFactory.CreateBattle(battleWorldId: 1);

        battle = BattleFactory.GetBattle(id);
        var input = new BattleInput(battle);

        battle.Input = input;
    }
Пример #3
0
    public void recordEvent(Fighter a, Fighter b, int action)
    {
        BattleInput input = new BattleInput()
        {
            myHealth = a.getScore(), theirHealth = b.getScore()
        };

        int[] new_action = new int[attackCount];
        new_action[action] = 1;
        InOutMap iomap = new InOutMap()
        {
            _in = input, action_selected = new_action
        };

        thisGame.Add(iomap);
    }
Пример #4
0
        static void Main(string[] args)
        {
            Console.WriteLine("battle test start...");
            if (args.Length < 2)
            {
                Console.WriteLine("error args");
                return;
            }
            Console.WriteLine("loading from testcase:{0}", args[0]);
            //XmlSerializer serializer = new XmlSerializer(typeof(TestCaseXml));
            //using (StreamReader sr = new StreamReader(testCaseXmlFile))
            //{
            //    testCase = serializer.Deserialize(sr) as TestCaseXml;
            //}
            RoleManager.Init(args[0]);
            TestCaseXml testCase = new TestCaseXml();

            testCase.Roles = RoleManager.getRoles();

            //Effect
            EffectManager.Init(args[2]);

            //Talent
            TalentManager.Init(args[3]);

            //Skill 处理
            SkillManager.Init(args[1]);
            Console.WriteLine("loading from skillfile:{0}", args[1]);
            //将角色技能信息根据skill信息补完
            foreach (Role role in testCase.Roles)
            {
                role.Skills  = SkillManager.updateSkills(role.Skills);
                role.Talents = TalentManager.updateTalent(role.Talents);
            }

            BattleInput input = new BattleInput()
            {
                Roles = testCase.Roles
            };
            BattleComputer computer = new BattleComputer(input);
            BattleResult   result   = computer.Compute();

            DisplayBattleResult(result);

            Console.ReadKey();
        }