Exemple #1
0
        private void ButtonConnect_Click(object sender, EventArgs e)
        {
            var name    = TextProcess.Text;
            var process = Process.GetProcessesByName(name)[0];

            Instance = new AoEInstance(process);

            Message($"Connected to process {process.Id}");
        }
Exemple #2
0
        private void ButtonDev_Click(object sender, EventArgs e)
        {
            int t = (int)ComboGameType.SelectedItem;

            Debug.WriteLine(t);

            return;

            var process  = Process.GetProcessesByName("WK")[0];
            var instance = new AoEInstance(process);

            var game = new Game()
            {
                VictoryType = 1
            };

            var player1 = new Game.Player()
            {
                PlayerNumber = 1,
                IsHuman      = false,
                AiFile       = "Barbarian",
                Civilization = 1,
                Color        = 1,
                Team         = 0
            };

            var player2 = new Game.Player()
            {
                PlayerNumber = 2,
                IsHuman      = false,
                AiFile       = "Promi",
                Civilization = 2,
                Color        = 2,
                Team         = 0
            };

            game.Players.Add(player1);
            game.Players.Add(player2);

            instance.RunGame(game);
        }
Exemple #3
0
        private void StartGame()
        {
            if (!File.Exists(TextExe.Text))
            {
                throw new Exception("Exe does not exist");
            }
            else if (!Directory.Exists(TextAiFolder.Text))
            {
                throw new Exception("Ai folder does not exist");
            }

            // set up game

            var game = new Game()
            {
                GameType          = (int)ComboGameType.SelectedItem,
                ScenarioName      = TextScenario.Text,
                MapType           = (int)ComboMapType.SelectedItem,
                MapSize           = (int)ComboMapSize.SelectedItem,
                Difficulty        = (int)ComboDifficulty.SelectedItem,
                StartingResources = (int)ComboStartingResources.SelectedItem,
                PopulationLimit   = (int)ComboPopulationCap.SelectedItem,
                RevealMap         = (int)ComboRevealMap.SelectedItem,
                StartingAge       = (int)ComboStartingAge.SelectedItem,
                VictoryType       = (int)ComboVictoryType.SelectedItem,
                VictoryValue      = int.Parse(TextVictoryValue.Text),
                TeamsTogether     = CheckTeamsTogether.Checked,
                LockTeams         = CheckLockTeams.Checked,
                AllTechs          = CheckAllTech.Checked,
                Recorded          = CheckRecorded.Checked,
            };

            var players = new ComboBox[] { ComboPlayer1Name, ComboPlayer2Name, ComboPlayer3Name, ComboPlayer4Name, ComboPlayer5Name, ComboPlayer6Name, ComboPlayer7Name, ComboPlayer8Name };
            var civs    = new ComboBox[] { ComboPlayer1Civ, ComboPlayer2Civ, ComboPlayer3Civ, ComboPlayer4Civ, ComboPlayer5Civ, ComboPlayer6Civ, ComboPlayer7Civ, ComboPlayer8Civ };
            var colors  = new ComboBox[] { ComboPlayer1Color, ComboPlayer2Color, ComboPlayer3Color, ComboPlayer4Color, ComboPlayer5Color, ComboPlayer6Color, ComboPlayer7Color, ComboPlayer8Color };
            var teams   = new ComboBox[] { ComboPlayer1Team, ComboPlayer2Team, ComboPlayer3Team, ComboPlayer4Team, ComboPlayer5Team, ComboPlayer6Team, ComboPlayer7Team, ComboPlayer8Team };

            for (int i = 0; i < players.Length; i++)
            {
                var name = (string)players[i].SelectedItem;

                if (name != "*Closed")
                {
                    var player = new Game.Player()
                    {
                        PlayerNumber = i + 1
                    };

                    if (name == "*Human")
                    {
                        player.IsHuman = true;
                    }
                    else
                    {
                        player.IsHuman = false;
                        player.AiFile  = name;
                    }

                    player.Civilization = (int)civs[i].SelectedItem;
                    player.Color        = (int)colors[i].SelectedItem;
                    player.Team         = (int)teams[i].SelectedItem;

                    game.Players.Add(player);
                }
            }

            if (game.Players.Count < 2)
            {
                throw new Exception("Need at least 2 players");
            }

            SaveSettings();

            // run on aoe

            var process = Process.Start(TextExe.Text);

            Thread.Sleep(10 * 1000);

            var instance = new AoEInstance(process);

            instance.RunGame(game);
        }