Example #1
0
        void AddScenery(BattleField field)
        {
            FileLocation  fl     = FileSystem.Instance.Locate("sceneObjects.xml", GameFileLocs.Config);
            Configuration config = ConfigurationManager.Instance.CreateInstance(fl);

            foreach (KeyValuePair <string, ConfigurationSection> e in config)
            {
                ConfigurationSection sect = e.Value;

                SceneryObject obj = new SceneryObject(field);
                obj.Parse((GameConfigurationSection)sect);
                obj.InitalizeGraphics(renderSys);
                scene.Scene.AddObjectToScene(obj);
            }
        }
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
        void AddScenery(BattleField field)
        {
            FileLocation fl = FileSystem.Instance.Locate("sceneObjects.xml", GameFileLocs.Config);
            Configuration config = ConfigurationManager.Instance.CreateInstance(fl);

            foreach (KeyValuePair<string, ConfigurationSection> e in config)
            {
                ConfigurationSection sect = e.Value;

                SceneryObject obj = new SceneryObject(field);
                obj.Parse((GameConfigurationSection)sect);
                obj.InitalizeGraphics(renderSys);
                scene.Scene.AddObjectToScene(obj);
            }
        }
Example #4
0
        void AddResources(BattleField field)
        {
            NaturalResource[] res = field.NaturalResources;

            for (int i = 0; i < res.Length; i++)
            {
                NaturalResource obj = res[i];
                switch (obj.Type)
                {
                    case NaturalResourceType.Oil:
                        OilFieldObject oilfld = obj as OilFieldObject;
                        if (oilfld != null)
                        {
                            oilfld.ResVisible += scene.Resource_Visible;
                            oilfld.InitalizeGraphics(renderSys);
                            scene.Scene.AddObjectToScene(oilfld);
                        }
                        break;
                    case NaturalResourceType.Wood:
                        ForestObject forest = obj as ForestObject;
                        if (forest != null)
                        {
                            forest.ResVisible += scene.Resource_Visible;
                            forest.InitalizeGraphics(renderSys);
                            scene.Scene.AddObjectToScene(forest);
                        }
                        break;
                }
            }
        }