public static void Initialize() { Globals.texturesAtlas = Globals.contentManager.Load <Texture2D>("BlocksTextures/TexturesAtlas"); BlockTexturesManager.blockTypesStrings = Enum.GetNames(typeof(BlockType)).ToList(); Globals.blockBasicEffect.Texture = Globals.texturesAtlas; Globals.waterBasicEffect.Texture = Globals.blockBasicEffect.Texture; BlockTexturesManager.textureHeight = (float)texturePixelsAmount / Globals.texturesAtlas.Height; BlockTexturesManager.textureWidth = 1f / 6f; BlockTexturesManager.pixelHeight = 1f / Globals.texturesAtlas.Height; BlockTexturesManager.pixelWidth = 1f / Globals.texturesAtlas.Width; BlockTexturesManager.SetupBlockTexturesDictionary(); }
public static void Initialize(ContentManager contentManager, GraphicsDevice graphicsDevice) { Globals.contentManager = contentManager; Globals.graphicsDevice = graphicsDevice; Globals.depthStencilState = new DepthStencilState(); Globals.middleOfTheScreen = new Vector2(Globals.graphicsDevice.Viewport.Width / 2, Globals.graphicsDevice.Viewport.Height / 2); Globals.Splash_Screen = true; Globals.Splash_HasGameStart = false; Globals.Splash_GameOver = false; Globals.mouseLock = true; Globals.depthStencilState.DepthBufferEnable = true; Globals.texturesAtlas = Globals.contentManager.Load <Texture2D>("BlocksTextures/TexturesAtlas"); Globals.random = new Random(); Globals.perlin_noise = new Perlin_Noise(); Globals.addableBlockTypes = new BlockType[] { BlockType.Grass, BlockType.Stone, BlockType.Snow, BlockType.Sand, BlockType.Wood_Trunk, BlockType.Leaf, BlockType.Israel, BlockType.Squares, BlockType.Brick_Wall }; Globals.spriteBatch = new SpriteBatch(Globals.graphicsDevice); Globals.block_Xoffset = Settings.BLOCK_SIZE.X * 2; Globals.block_Yoffset = Settings.BLOCK_SIZE.Y * 2; Globals.block_Zoffset = Settings.BLOCK_SIZE.Z * 2; Globals.nextEnemieSpawnTime = 0; Globals.enemiesAmount = 0; Globals.statusFont = contentManager.Load <SpriteFont>("Fonts/myFont"); Globals.chunksBuffer = new VertexBuffer(Globals.graphicsDevice, VertexPositionNormalTexture.VertexDeclaration, 36 * Settings.CHUNK_SIZE * Settings.CHUNK_SIZE * Settings.CHUNK_SIZE, BufferUsage.None); Globals.block_ColorPosition_VertexBuffer = new VertexBuffer(Globals.graphicsDevice, VertexPositionColor.VertexDeclaration, 36, BufferUsage.WriteOnly); Globals.blockBasicEffect = new BasicEffect(Globals.graphicsDevice); Globals.blockBasicEffect.TextureEnabled = true; Globals.blockBasicEffect.EnableDefaultLighting(); Globals.blockBasicEffect.FogColor = Color.Blue.ToVector3(); Globals.blockBasicEffect.FogStart = -10; Globals.blockBasicEffect.FogEnd = 40; Globals.waterBasicEffect = new BasicEffect(Globals.graphicsDevice); Globals.waterBasicEffect.Alpha = Settings.water_transparency; Globals.waterBasicEffect.TextureEnabled = true; Globals.waterBasicEffect.EnableDefaultLighting(); Globals.enemieBasicEffect = new BasicEffect(Globals.graphicsDevice); Globals.enemieBasicEffect.TextureEnabled = false; Globals.enemieBasicEffect.VertexColorEnabled = true; BlockTexturesManager.Initialize(); GameDictionaries.Initialize(); }