Example #1
0
        public void StartNewGame()
        {
            GameCreationParameters gcp = new GameCreationParameters();

            gcp.Player1 = new Player("Player", 0);
            gcp.Player2 = new AIPlayer(1);
            gcp.Player3 = new AIPlayer(2);
            gcp.Player4 = new AIPlayer(3);
            gcp.Player5 = new AIPlayer(4);
            gcp.Player6 = new AIPlayer(5);
            gcp.Player7 = new AIPlayer(6);
            gcp.Player8 = new AIPlayer(7);

            ColorValue[] colors = GetSideColors();
            gcp.Player1.SideColor = colors[0];
            gcp.Player2.SideColor = colors[1];
            gcp.Player3.SideColor = colors[2];
            gcp.Player4.SideColor = colors[3];
            gcp.Player5.SideColor = colors[4];
            gcp.Player6.SideColor = colors[5];
            gcp.Player7.SideColor = colors[6];
            gcp.Player8.SideColor = colors[7];

            currentGame = new Game(this, gcp);
        }
Example #2
0
        public Game(Code2015 game, GameCreationParameters gcp)
        {
            this.game       = game;
            this.renderSys  = game.RenderSystem;
            this.parameters = gcp;
            this.soundWorld = new SoundObjectWorld();

            gameState = new GameState(GetLocalPlayers(gcp));

            BattleField field = gameState.Field;

            // 初始化场景
            this.scene = new GameScene(renderSys);



            field.ResourceBallChanged += Field_ResourceBallChanged;

            for (int i = 0; i < field.CityCount; i++)
            {
                City city = field.Cities[i];

                city.InitalizeGraphics(renderSys);
                city.CityVisible += scene.City_Visible;

                GatherCity gaCity = city as GatherCity;
                if (gaCity != null)
                {
                    gaCity.Harvester.InitializeGraphics(renderSys);
                    scene.Scene.AddObjectToScene(gaCity.Harvester);
                }
                scene.Scene.AddObjectToScene(city);
            }

            field.Fog.InitailizeGraphics(renderSys);

            AddResources(field);
            AddScenery(field);

            gameState.InitialStandards();
            {
                HumanPlayer = gameState.LocalHumanPlayer;
                City hstart = HumanPlayer.Area.RootCity;
                this.scene.Camera.Longitude = MathEx.Degree2Radian(hstart.Longitude);
                this.scene.Camera.Latitude  = MathEx.Degree2Radian(hstart.Latitude);
            }
            this.ingameUI = new InGameUI(game, this, scene, gameState);
        }
Example #3
0
        Player[] GetLocalPlayers(GameCreationParameters gcp)
        {
            List <Player> list = new List <Player>();

            if (gcp.Player1 != null && gcp.Player1.Type != PlayerType.Remote)
            {
                list.Add(gcp.Player1);
            }
            if (gcp.Player2 != null && gcp.Player2.Type != PlayerType.Remote)
            {
                list.Add(gcp.Player2);
            }
            if (gcp.Player3 != null && gcp.Player3.Type != PlayerType.Remote)
            {
                list.Add(gcp.Player3);
            }
            if (gcp.Player4 != null && gcp.Player4.Type != PlayerType.Remote)
            {
                list.Add(gcp.Player4);
            }
            if (gcp.Player5 != null && gcp.Player5.Type != PlayerType.Remote)
            {
                list.Add(gcp.Player5);
            }
            if (gcp.Player6 != null && gcp.Player6.Type != PlayerType.Remote)
            {
                list.Add(gcp.Player6);
            }
            if (gcp.Player7 != null && gcp.Player7.Type != PlayerType.Remote)
            {
                list.Add(gcp.Player7);
            }
            if (gcp.Player8 != null && gcp.Player8.Type != PlayerType.Remote)
            {
                list.Add(gcp.Player8);
            }
            return(list.ToArray());
        }
Example #4
0
        public Game(Code2015 game, GameCreationParameters gcp)
        {
            this.game = game;
            this.renderSys = game.RenderSystem;
            this.parameters = gcp;
            this.soundWorld = new SoundObjectWorld();
            
            gameState = new GameState(GetLocalPlayers(gcp));

            BattleField field = gameState.Field;
            // 初始化场景
            this.scene = new GameScene(renderSys);
           

            
            field.ResourceBallChanged += Field_ResourceBallChanged;

            for (int i = 0; i < field.CityCount; i++)
            {
                City city = field.Cities[i];

                city.InitalizeGraphics(renderSys);
                city.CityVisible += scene.City_Visible;

                GatherCity gaCity = city as GatherCity;
                if (gaCity != null)
                {
                    gaCity.Harvester.InitializeGraphics(renderSys);
                    scene.Scene.AddObjectToScene(gaCity.Harvester);
                }
                scene.Scene.AddObjectToScene(city);
            }

            field.Fog.InitailizeGraphics(renderSys);

            AddResources(field);
            AddScenery(field);
            
            gameState.InitialStandards();
            {
                HumanPlayer = gameState.LocalHumanPlayer;
                City hstart = HumanPlayer.Area.RootCity;
                this.scene.Camera.Longitude = MathEx.Degree2Radian(hstart.Longitude);
                this.scene.Camera.Latitude = MathEx.Degree2Radian(hstart.Latitude);
            }
            this.ingameUI = new InGameUI(game, this, scene, gameState);
        }
Example #5
0
 Player[] GetLocalPlayers(GameCreationParameters gcp)
 {
     List<Player> list = new List<Player>();
     if (gcp.Player1 != null && gcp.Player1.Type != PlayerType.Remote)
     {
         list.Add(gcp.Player1);
     }
     if (gcp.Player2 != null && gcp.Player2.Type != PlayerType.Remote)
     {
         list.Add(gcp.Player2);
     }
     if (gcp.Player3 != null && gcp.Player3.Type != PlayerType.Remote)
     {
         list.Add(gcp.Player3);
     }
     if (gcp.Player4 != null && gcp.Player4.Type != PlayerType.Remote)
     {
         list.Add(gcp.Player4);
     }
     if (gcp.Player5 != null && gcp.Player5.Type != PlayerType.Remote)
     {
         list.Add(gcp.Player5);
     }
     if (gcp.Player6 != null && gcp.Player6.Type != PlayerType.Remote)
     {
         list.Add(gcp.Player6);
     }
     if (gcp.Player7 != null && gcp.Player7.Type != PlayerType.Remote)
     {
         list.Add(gcp.Player7);
     }
     if (gcp.Player8 != null && gcp.Player8.Type != PlayerType.Remote)
     {
         list.Add(gcp.Player8);
     }
     return list.ToArray();
 }
Example #6
0
        public void StartNewGame()
        {
            GameCreationParameters gcp = new GameCreationParameters();

            gcp.Player1 = new Player("Player", 0);
            gcp.Player2 = new AIPlayer(1);
            gcp.Player3 = new AIPlayer(2);
            gcp.Player4 = new AIPlayer(3);
            gcp.Player5 = new AIPlayer(4);
            gcp.Player6 = new AIPlayer(5);
            gcp.Player7 = new AIPlayer(6);
            gcp.Player8 = new AIPlayer(7);

            ColorValue[] colors = GetSideColors();
            gcp.Player1.SideColor = colors[0];
            gcp.Player2.SideColor = colors[1];
            gcp.Player3.SideColor = colors[2];
            gcp.Player4.SideColor = colors[3];
            gcp.Player5.SideColor = colors[4];
            gcp.Player6.SideColor = colors[5];
            gcp.Player7.SideColor = colors[6];
            gcp.Player8.SideColor = colors[7];

            currentGame = new Game(this, gcp);
        }