示例#1
0
        public bool LoadGame(string filename)
        {
            bool result = false;

            if (File.Exists(filename))
            {
                GameStorage storage    = new GameStorage(filename, false);
                GameStorage mapStorage = new GameStorage("map.dat", false);

                try
                {
                    this.PlayerCamera.Restore(storage);
                    this.LODMap = new LODTerrain.LODTerrain(this, GameSession.mapNumCellsPerSide, GameSession.mapNumCellsPerSide, this.effect, this.device, mapStorage);
                    result      = true;
                }
                catch (Exception ex)
                {
                    LoadGameReadExection = ex;
                    Console.WriteLine("Loadgame exception occured: ");
                    Console.WriteLine(ex.ToString());
                }
            }



            return(result);
        }
示例#2
0
        public bool SaveGame(string filename)
        {
            bool result = false;

            GameStorage storage = new GameStorage(filename, true);


            try
            {
                this.PlayerCamera.Store(storage);
                //   this.LODMap.Store(storage);



                // this.entityFactory
                // this.CurrentGameState


                result = true;
                storage.Close();
            }
            catch (Exception ex)
            {
                SaveGameWriteExeption = ex;
                Console.WriteLine("Savegame exception occured: ");
                Console.WriteLine(ex.ToString());
            }
            return(result);
        }
示例#3
0
 public void Restore(GameSession.GameStorage storage)
 {
     this.Iron      = storage.ReadSingle();
     this.Copper    = storage.ReadSingle();
     this.Aluminium = storage.ReadSingle();
     this.Lithium   = storage.ReadSingle();
     this.Titanium  = storage.ReadSingle();
     this.Nickel    = storage.ReadSingle();
     this.Silver    = storage.ReadSingle();
     this.Tungsten  = storage.ReadSingle();
     this.Platinum  = storage.ReadSingle();
     this.Gold      = storage.ReadSingle();
     this.Lead      = storage.ReadSingle();
     this.Uranium   = storage.ReadSingle();
 }
示例#4
0
 public void Store(GameSession.GameStorage storage)
 {
     storage.Write(Iron);
     storage.Write(Copper);
     storage.Write(Aluminium);
     storage.Write(Lithium);
     storage.Write(Titanium);
     storage.Write(Nickel);
     storage.Write(Silver);
     storage.Write(Tungsten);
     storage.Write(Platinum);
     storage.Write(Gold);
     storage.Write(Lead);
     storage.Write(Uranium);
 }
示例#5
0
        public void LoadContent(ContentManager Content, GameStorage storage, GameStorage mapstorage)
        {
            this.Content = Content;

            this.effect = Content.Load <Effect>("Series4Effects");

            this.font = Content.Load <SpriteFont>("Courier New");

            this.PlayerCamera = new Camera(this.device.Viewport.AspectRatio);

            this.PlayerCamera.DoFixedAltitude = true;

            this.PlayerCamera.Restore(storage);
            this.LODMap = new LODTerrain.LODTerrain(this, GameSession.mapNumCellsPerSide, GameSession.mapNumCellsPerSide, this.effect, this.device, mapstorage);

            this.PlayerCamera.LODMap = this.LODMap;

            this.PlayerCamera.DrawDistance = 1200.0f; // 300.0f;

            this.HUD_overlay.PreloadImages(Content);

            this.HUD_overlay.ConstructButtons();

            this.textureGenerator = new TextureGenerator(this);

            this.LODMap.GetRenderer().waterBumpMap = Content.Load <Texture2D>("waterbump");

            this.LODMap.GetRenderer().Textures    = new Texture2D[5];
            this.LODMap.GetRenderer().Textures[0] = Content.Load <Texture2D>("Textures\\tex1");
            this.LODMap.GetRenderer().Textures[1] = Content.Load <Texture2D>("Textures\\tex0");
            this.LODMap.GetRenderer().Textures[2] = Content.Load <Texture2D>("Textures\\tex2");
            this.LODMap.GetRenderer().Textures[3] = Content.Load <Texture2D>("Textures\\tex3");
            this.LODMap.GetRenderer().Textures[4] = Content.Load <Texture2D>("Textures\\tex1");
            //       this.LODMap.GetRenderer().WaterTexture = Content.Load<Texture2D>("Textures\\water");

            this.LODMap.selectionTexture = this.textureGenerator.SelectionImage(Color.Yellow, 5); //WorldMap.mapCellScale);

            // skydome
            this.LODMap.GetRenderer().LoadSkyDome(Content.Load <Model>("Models/dome"));


            this.PlayerCamera.UpdateViewMatrix();


            this.entityFactory = EntityFactory.CreateFactory(this, this.LODMap, this.PlayerCamera.projectionMatrix);
        }
示例#6
0
        protected override void LoadContent()
        {
            if (System.IO.File.Exists("savegame.dat") && System.IO.File.Exists("map.dat"))
            {
                GameSession.GameStorage storage    = new GameSession.GameStorage("savegame.dat", false);
                GameSession.GameStorage mapstorage = new GameSession.GameStorage("map.dat", false);
                this.RunningGameSession.LoadContent(this.Content, storage, mapstorage);
            }
            else
            {
                this.RunningGameSession.LoadContent(this.Content);
            }


            doneLoading = true;
            this.RunningGameSession.ChangeGameState(this.RunningGameSession.FreeLookState);
        }
示例#7
0
        public void Restore(GameSession.GameStorage reader)
        {
            leftrightRot = reader.ReadSingle();
            updownRot    = reader.ReadSingle();

            cameraPosition = reader.ReadVector3();

            cameraHeight = reader.ReadSingle();

            LookAt = reader.ReadVector3();

            sideVector = reader.ReadVector3();

            _DrawDistance = reader.ReadSingle();
            AspectRatio   = reader.ReadSingle();

            viewMatrix = reader.ReadMatrix();

            viewMatrixBackShifted = reader.ReadMatrix();

            projectionMatrix = reader.ReadMatrix();

            BigProjectionMatrix = reader.ReadMatrix();
        }
示例#8
0
        public void Store(GameSession.GameStorage writer)
        {
            writer.Write(leftrightRot);
            writer.Write(updownRot);

            writer.Write(cameraPosition);

            writer.Write(cameraHeight);

            writer.Write(LookAt);

            writer.Write(sideVector);

            writer.Write(_DrawDistance);
            writer.Write(AspectRatio);

            writer.Write(viewMatrix);

            writer.Write(viewMatrixBackShifted);

            writer.Write(projectionMatrix);

            writer.Write(BigProjectionMatrix);
        }