Beispiel #1
0
        public PrimitiveRender(GraphicsDevice graphicsDevice, SpriteBatch spriteBatch, ContentManager contentManager, Camera camera)
        {
            mCamera = camera;
            const int initalCapacity = 10240;//Начальный размер массива
            mVertecesCount = 0;
            mVerteces = new VertexPositionColor[initalCapacity];
            mGraphicsDevice = graphicsDevice;
            mBufferVerteces = new VertexPositionColor[initalCapacity];
            mPointBuffer = new Vector2[initalCapacity];

            mSpriteBatch = spriteBatch;
            mTextures = new Dictionary<string, Texture2D>();
            Texture2D texture = contentManager.Load<Texture2D>("textures\\block3");
            mTextures.Add("block", texture);
            texture = contentManager.Load<Texture2D>("textures\\block7");
            mTextures.Add("block2", texture);
            texture = contentManager.Load<Texture2D>("textures\\block8");
            mTextures.Add("block3", texture);
            texture = contentManager.Load<Texture2D>("textures\\base_block");
            mTextures.Add("base-block", texture);
            texture = contentManager.Load<Texture2D>("textures\\block1");
            mTextures.Add("disableblock", texture);
            texture = contentManager.Load<Texture2D>("textures\\gun");
            mTextures.Add("gun", texture);
            texture = contentManager.Load<Texture2D>("textures\\barrel");
            mTextures.Add("barrel", texture);
            texture = contentManager.Load<Texture2D>("textures\\bullet");
            mTextures.Add("bullet", texture);
        }
Beispiel #2
0
        public Builder(World world, Camera camera, GameObjectCollection gameObjectCollection)
        {
            mWorld = world;
            mCamera = camera;
            mGameObjectCollection = gameObjectCollection;

            IsActive = false;
            mTexture = "block3";
        }
Beispiel #3
0
        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();
        }