コード例 #1
0
ファイル: Builder.cs プロジェクト: ASOIU/BlockWars
        public Builder(World world, Camera camera, GameObjectCollection gameObjectCollection)
        {
            mWorld = world;
            mCamera = camera;
            mGameObjectCollection = gameObjectCollection;

            IsActive = false;
            mTexture = "block3";
        }
コード例 #2
0
ファイル: Game1.cs プロジェクト: ASOIU/BlockWars
        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();
        }