示例#1
0
        private Globals()
        {
            _random = new Random();

            GameWorld     = GameWorld.Create();
            MovementTypes = MovementTypes.Create(new List <MovementType> {
                MovementType.Create(1, "Ground")
            });
            TerrainTypes  = TerrainTypes.Create(TerrainTypesLoader.GetTerrainTypes());
            MineralTypes  = MineralTypes.Create(MineralTypesLoader.GetMineralTypes());
            UnitTypes     = UnitTypes.Create(UnitTypesLoader.GetUnitTypes(MovementTypes));
            RaceTypes     = RaceTypes.Create(RaceTypesLoader.GetRaceTypes());
            BuildingTypes = BuildingTypesLoader.GetBuildingTypes();
        }
示例#2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // Load stuff
            List <TerrainType> terrainTypes = TerrainTypesLoader.GetTerrainTypes();

            _texts = new List <string>();
            foreach (TerrainType terrainType in terrainTypes)
            {
                string text = $"{terrainType.Id} - {terrainType.Name}";
                _texts.Add(text);
            }

            _images = new Images();

            // Create gameboard
            //int[,] terrain = MapLoader.Load("Map.txt");
            int[,] terrain = MapGenerator.Generate(COLUMNS, ROWS);
            GameBoard testMap = GameBoard.Create(1, terrain, ALL_VISIBLE);

            Globals.Instance.GameWorld.SetGameBoard(testMap);

            var player = new Player();

            player.UnitMoved += Player_UnitMoved;
            player.TurnEnded += Player_TurnEnded;
            player.AddSettlement("Margeritaville", Point2.Create(1, 1), Globals.Instance.RaceTypes[0]);
            player.AddUnit(4, Point2.Create(0, 0)); // cavalry
            player.AddUnit(0, Point2.Create(0, 1)); // cavalry
            player.StartTurn();

            var player2 = new Player2();

            player2.UnitMoved += Player2_UnitMoved;
            player2.AddUnit(0, Point2.Create(1, 0)); // 50,30
            player2.AddUnit(0, Point2.Create(2, 0));

            Globals.Instance.GameWorld.SetPlayer(player);
            Globals.Instance.GameWorld.SetPlayer2(player2);

            // Start timer
            timer1.Interval = 1;
            timer1.Start();
        }