Exemple #1
0
 static Game()
 {
     Instances = new ConcurrentDictionary <string, WeakReference <Instance> >(StringComparer.Ordinal);
     Worlds    = new ConcurrentDictionary <IWorld, byte>();
     DataModel = new DataModel();
     Stats     = new DebugStats {
         Parent = DataModel, ParentLocked = true
     };
 }
Exemple #2
0
 public void Setup()
 {
   compiler = new Compiler();
   debugStats = compiler.stats;
 }
Exemple #3
0
        /// <summary>
        /// Constructor for the WorldViewScreen
        /// </summary>
        public WorldViewScreen(Game game, ScreenElement previousScreenElement) :
            base(previousScreenElement, game.GraphicsDevice)
        {
            this.content = game.Content;
            this.game    = game;

            // Set seed to build world with
            int mapSeed = 123;

            Noise.Simplex.Seed(mapSeed);

            // Load graphics resources/assets
            boxRenderer = new BoundingBoxRenderer(graphicsDevice);

            voxelEffect   = content.Load <Effect>("Effects/voxel");
            skydomeEffect = content.Load <Effect>("Effects/skydome");

            // Load initial data for the voxel sprite
            VoxelCache voxelCache = new VoxelCache(mapSeed, 32, 128);

            playerSprite = new VoxelSprite(graphicsDevice);
            playerSprite.Load(voxelCache, "chr_knight");

            // Attempt to load player save data
            gameData = new GameData();

            if (gameData.LoadGame(mapSeed))
            {
                player = new Player(playerSprite.Mesh, gameData.Player);
            }
            else
            {
                Player.PlayerData data = new Player.PlayerData()
                {
                    position    = new Vector3(200, 50, -20),
                    orientation = 0
                };
                player = new Player(playerSprite.Mesh, data);
            }

            // Set up voxel chunks and skydome
            chunkManager = new ChunkManager(graphicsDevice, 123);
            chunkManager.Initialize(graphicsDevice, player.playerData.position);
            skydome = new Skydome(graphicsDevice, content);

            // Set up cameras
            playerCamera  = new PlayerCamera(Vector3.Zero, Vector2.Zero);
            skydomeCamera = new PlayerCamera(Vector3.Zero, Vector2.Zero);

            InitializeGraphicsResources();

            // Set debug info
            debugStats = new DebugStats
            {
                vertexCount = this.vertexCount,
                cameraPos   = this.playerCamera.position,
                chunksAdded = this.chunkManager.ChunksAdded
            };

            // Testing console commands
            GUI.EntitySpawner spawner = new GUI.EntitySpawner();
            console.Command("test");

            // Set some non-standard effect parameters here
            Color skyColor = new Color(0.091f, 0.622f, 0.976f);

            voxelEffect.Parameters["skyColor"].SetValue(skyColor.ToVector3());
            voxelEffect.Parameters["skyTexture"].SetValue(skydome.Skymap);
            voxelEffect.Parameters["toggleColors"].SetValue(toggleColors);

            // Manage resources that need to be reset when graphics device is lost
            game.GraphicsDevice.DeviceReset += new EventHandler <EventArgs>(OnDeviceReset);

            // Add children screen with these stats
            children.Add(new ScreenElements.DebugViewScreen(this, content, graphicsDevice, debugStats, game));
        }
Exemple #4
0
 public void Setup()
 {
     compiler   = new Compiler();
     debugStats = compiler.stats;
 }