Inheritance: IOObserver
コード例 #1
0
        public ScoreBoard(MyGame game)
            : base(game)
        {
            this.camera = game.camera;
            myGame = game;
            game.mediator.register(this, MyEvent.M_DIE);
            events = new List<Event>();

            spriteBatch = new SpriteBatch(game.GraphicsDevice);
        }
コード例 #2
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();
            this.camera = new Camera(new Vector2(0), 1f, 0, this.graphics, inputManager);

            SpriteBatch spriteBatch = new SpriteBatch(GraphicsDevice);
            myGraphicsObject = new MyGraphicsClass(this.graphics, spriteBatch, this.camera);

            gameObjectCollection = new GameObjectCollection(worldSize);
        }
コード例 #3
0
        int width, length; // Number of vertices on x and z axes

        #endregion Fields

        #region Constructors

        public Terrain(Game game,Camera camera, Texture2D HeightMap, float CellSize, float Height,
            Texture2D BaseTexture, float TextureTiling, Vector3 LightDirection/*,Vector2 pos*/)
            : base(game)
        {
            this.baseTexture = BaseTexture;
            this.camera = camera;
            this.textureTiling = TextureTiling;
            this.lightDirection = LightDirection;
            this.heightMap = HeightMap;
            this.width = HeightMap.Width;
            this.length = HeightMap.Height;
            this.cellSize = CellSize;
            this.height = Height;
            //this.pos = pos;

            effect = Game.Content.Load<Effect>("TerrainEffect");

            // 1 vertex per pixel
            nVertices = width * length;

            // (Width-1) * (Length-1) cells, 2 triangles per cell, 3 indices per triangle
            nIndices = (width - 1) * (length - 1) * 6;

            vertexBuffer = new VertexBuffer(Game.GraphicsDevice, typeof(VertexPositionNormalTexture),
                nVertices, BufferUsage.WriteOnly);

            indexBuffer = new IndexBuffer(Game.GraphicsDevice, IndexElementSize.ThirtyTwoBits,
                nIndices, BufferUsage.WriteOnly);

            getHeights();
            createVertices();
            createIndices();
            genNormals();

            vertexBuffer.SetData<VertexPositionNormalTexture>(vertices);
            indexBuffer.SetData<int>(indices);
        }
コード例 #4
0
        private void initializeGame1()
        {
            switch (StartScreen.Difficulty)
            {
                case Constants.Difficulties.Novice: difficultyConstants = new NoviceConstants(); break;
                case Constants.Difficulties.Advanced: difficultyConstants = new AdvancedConstants(); break;
                case Constants.Difficulties.Xtreme: difficultyConstants = new XtremeConstants(); break;
            }
            //camera = new FreeCamera(this, new Vector3(0, 0, 0), 0, 0, 0 , 0);
            //camera = new FreeCamera(new Vector3(400, 600, 400), MathHelper.ToRadians(45), MathHelper.ToRadians(-30), GraphicsDevice);
            camera = new ChaseCamera(this, Constants.CAMERA_POSITION_THIRD_PERSON, Constants.CAMERA_TARGET_THIRD_PERSON, Vector3.Zero);

            //for (int i = 0; i < Constants.NUM_OF_TERRAINS; i++)
            //{
                terrain = new Terrain(this, camera, Content.Load<Texture2D>("terrain"+currentLevel), Constants.TERRAIN_CELL_SIZE,
                    Constants.TERRAIN_HEIGHT, Content.Load<Texture2D>("grass"), Constants.TERRAIN_TEXTURE_TILING,
                    new Vector3(1, -1, 0)/*,new Vector2(i%2*-1,i/2*-1)*/);
                terrain.WeightMap = Content.Load<Texture2D>("weightMap"+currentLevel);
                terrain.RTexture = Content.Load<Texture2D>("sand");
                terrain.GTexture = Content.Load<Texture2D>("rock");
                terrain.BTexture = Content.Load<Texture2D>("snow");
                terrain.DetailTexture = Content.Load<Texture2D>("noise_texture");
            //}
            player = initializePlayer();
            sky = intitializeSky();
            initializeClouds();

            initializeTrees();
            //trees = initializeBillBoard(100, "tree_billboard", true, Constants.TREE_SIZE,true);
            grass = initializeBillBoard(300, "grass_billboard", false, Constants.GRASS_SIZE,false);

            weapon = new Weapon(this, player, Content.Load<Model>("model//WeaponMachineGun"),
                new Unit(this, Vector3.Zero, Vector3.Zero, Vector3.One));
            bullets = new BulletsManager(this);
            scoreBoard = new ScoreBoard(this);
            monsters = new MonstersManager(this);
            firstAidManger = new FirstAidManager(this);

            //testing = new CDrawableComponent(this, new Unit(this, new Vector3(0,terrain.GetHeightAtPosition(0,0),0),
            //    Vector3.Zero,new Vector3(5f)),
            //    new CModel(this, Content.Load<Model>("firtree1")));

            //waterMesh = new CModel(game.Content.Load<Model>("plane"), position,
            //   Vector3.Zero, new Vector3(size.X, 1, size.Y), game.GraphicsDevice);
            water = new Water(this,Content.Load<Model>("plane"),
                new WaterUnit(this, new Vector3(0,Constants.WATER_HEIGHT,0), Vector3.Zero, new Vector3(10240,1,10240)));
            ((WaterUnit)water.unit).Objects.Add(sky);
            //((WaterUnit)water.unit).Objects.Add(terrain);
            stateManager = new StateManager(this);
            audioManager = new AudioManager(this);

            frameRateCounter = new FrameRateCounter(this);

            kinectManager = new KinectManager(this);
            //CDrawableComponent test = new CDrawableComponent(this,
            //    new Unit(this, new Vector3(0, 80, 0), Vector3.Zero, Vector3.One * .5f),
            //    new CModel(this, Content.Load<Model>(@"model/First Aid Kit2")));
            //mediator.fireEvent(MyEvent.G_StartGame);
        }
コード例 #5
0
ファイル: Game1.cs プロジェクト: TommyAlexander/drunken-cyril
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.

            spriteBatch = new SpriteBatch(GraphicsDevice);
            Texture2D line = Content.Load<Texture2D>("line");
            camera = new Camera(new Vector2(0), .25f, 0, graphics);
            myGraphicsObject = new DrawingUtils.MyGraphicsClass(graphics, spriteBatch, camera);
            DrawingUtils.MyGraphicsClass.LoadContent(Content);
            Textures.LoadContent(Content);
            // TODO: use this.Content to load your game content here
        }
コード例 #6
0
        private void initializeGame1()
        {
            switch (StartScreen.Difficulty)
            {
                case Constants.Difficulties.Novice: difficultyConstants = new NoviceConstants(); break ;
                case Constants.Difficulties.Advanced: difficultyConstants = new AdvancedConstants(); break;
                case Constants.Difficulties.Xtreme: difficultyConstants = new XtremeConstants(); break;

            }
            //camera = new FreeCamera(this, new Vector3(0, 0, 0), 0, 0, 0 , 0);
            //camera = new FreeCamera(new Vector3(400, 600, 400), MathHelper.ToRadians(45), MathHelper.ToRadians(-30), GraphicsDevice);
            camera = new ChaseCamera(this, Constants.CAMERA_POSITION, Constants.CAMERA_TARGET, Vector3.Zero);
            terrain = new Terrain(this, camera, Content.Load<Texture2D>("terrain"), Constants.TERRAIN_CELL_SIZE,
                Constants.TERRAIN_HEIGHT, Content.Load<Texture2D>("grass"), Constants.TERRAIN_TEXTURE_TILING, new Vector3(1, -1, 0));

            player = initializePlayer();
            sky = intitializeSky();

            weapon = new Weapon(this, player, Content.Load<Model>("model//WeaponMachineGun"),
                new Unit(this, Vector3.Zero, Vector3.Zero, Vector3.One));
            bullets = new BulletsManager(this);
            scoreBoard = new ScoreBoard(this);
            monsters = new MonstersManager(this);
               firstAidManger = new FirstAidManager(this);

            stateManager = new StateManager(this);
            audioManager = new AudioManager(this);

            //CDrawableComponent test = new CDrawableComponent(this,
            //    new Unit(this, new Vector3(0, 80, 0), Vector3.Zero, Vector3.One * .5f),
            //    new CModel(this, Content.Load<Model>(@"model/First Aid Kit2")));
        }
コード例 #7
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();
            this.camera = new Camera(new Vector2(0), 1f, 0, this.graphics);

            SpriteBatch spriteBatch = new SpriteBatch(GraphicsDevice);
            myGraphicsObject = new DrawingUtils.MyGraphicsClass(this.graphics, spriteBatch, this.camera);

            backGround = new BackGround(worldSize);
            gameObjectCollection = new GameObjectCollection(worldSize);
        }