protected override void Initialize() { spriteBatch = new SpriteBatch(GraphicsDevice); mImmortalBoxes = new List <Box>(); mBullets = new List <Bullet>(); mBasicEffect = new BasicEffect(graphics.GraphicsDevice); mBasicEffect.VertexColorEnabled = true; mCamera = new Camera(GraphicsDevice.Viewport, mBasicEffect); mPrimitiveRender = new PrimitiveRender(graphics.GraphicsDevice, Content, mCamera); mPlayer = new Player(); Vector2 gravity = new Vector2(0, -10f); mWorld = new World(gravity, true); mContactListener = new ContactListener(); mWorld.ContactListener = mContactListener; Vector2 pos = new Vector2(0, 30); Vector2 size = new Vector2(2, 2); mBoxes = new List <Box>(); AddPyramid(300, -19.5f, 12); pos = new Vector2(0, -20); size = new Vector2(10000, 1); Box groundBox = new Box(mWorld, pos, size, "block", true, mPlayer); mImmortalBoxes.Add(groundBox); pos = new Vector2(-20, -15); mGun = new Gun(mWorld, pos, mPlayer); mBuilder = new Builder(mWorld, mCamera, mPlayer); mBuilder.Activate(); mUiManager = new UIManager(spriteBatch, Content, mBuilder, mGun); base.Initialize(); }
protected override void Initialize() { mGameObjectCollection = new GameObjectCollection(); spriteBatch = new SpriteBatch(GraphicsDevice); mImmortalBoxes = new List<Box>(); mBasicEffect = new BasicEffect(graphics.GraphicsDevice); mBasicEffect.VertexColorEnabled = true; mCamera = new Camera(GraphicsDevice.Viewport, mBasicEffect); mPrimitiveRender = new PrimitiveRender(graphics.GraphicsDevice, spriteBatch, Content, mCamera); Vector2 gravity = new Vector2(0, -10f); mWorld = new World(gravity, true); mContactListener = new ContactListener(); mWorld.ContactListener = mContactListener; mTerrain = new Terrain(mWorld); mBuilder = new Builder(mWorld, mCamera, mGameObjectCollection); mUiManager = new UIManager(spriteBatch, Content, mBuilder); mGameplay = new Gameplay.Gameplay(mCamera, mUiManager); mPlayer = mGameplay.Player1; Vector2 pos = new Vector2(0, 30); Vector2 size = new Vector2(2, 2); pos = new Vector2(-150, -7); Gun gunPlayer1 = new Gun(mWorld, pos, mPlayer); mGameObjectCollection.Guns.Add(gunPlayer1); mPlayer.Guns.Add(gunPlayer1); pos = new Vector2(140, -7); Gun gunPlayer2 = new Gun(mWorld, pos, mGameplay.Player2); mGameObjectCollection.Guns.Add(gunPlayer2); mGameplay.Player2.Guns.Add(gunPlayer2); List<Box> baseBoxes = PlayerBaseFactory.CreateBuilding(mWorld, mGameplay, EntityCategory.Player1); mGameObjectCollection.Boxes.AddRange(baseBoxes); baseBoxes = PlayerBaseFactory.CreateBuilding(mWorld, mGameplay, EntityCategory.Player2); mGameObjectCollection.Boxes.AddRange(baseBoxes); mGameplay.StartGame(); mBuilder.Activate(); base.Initialize(); }