Пример #1
0
        //bullet collision detection goes here
        public Boolean isCollided(RandomMap randomMap)
        {
            for (int i = 0; i < randomMap.getNumXBlocks(); i++)
            {
                for (int j = 0; j < randomMap.getNumYBlocks(); j++)
                {
                    //if there is a block
                    if (randomMap.map[i, j] != null)
                    {
                        Block block = randomMap.map[i, j];

                        //if bullet collides with block
                        if (this.boundingBox.Intersects(block.boundingBox))
                        {
                            //decrease block's health
                            randomMap.map[i, j].hardness -= this.damage;
                            if (randomMap.map[i, j].hardness < 0)
                            {
                                randomMap.map[i, j] = null;
                            }

                            return true;
                        }
                    }
                }
            }
            return false;
        }
Пример #2
0
        protected RandomMap randomMap; //holds the level

        #endregion Fields

        #region Constructors

        public Character(Game game, RandomMap randomMap, string imageName, float xPos, float yPos, int width, int height)
            : base(game, imageName, xPos, yPos, width, height)
        {
            this.randomMap = randomMap;
            this.velocity.X = 205.0f;
            this.velocity.Y = 250.0f;
            this.inventory = new Item[9];
        }
Пример #3
0
 public AssaultRifle(Game game, RandomMap randomMap, float xPos, float yPos, int width, int height)
     : base(game, randomMap, "images/assaultBasicBullet", "images/empty_icon", xPos, yPos, width, height)
 {
     this.name = "Assault Rifle";
     this.fireRate = 0.1f;
     this.currentAmmo = 100;
     this.maxAmmo = 400;
     this.roundsPerMag = 30;
 }
Пример #4
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()
        {
            randomMap = new RandomMap(this, 3200, 300);
            player = new AssaultSoldier(this, randomMap, (this.GraphicsDevice.Viewport.Width / 2) - 32, 0f, 64, 128);
            camera = new Camera(this);
            Components.Add(player);

            this.bottomItemBar = new InventoryToolbar(this); //bottom inventory bar

            base.Initialize();
        }
Пример #5
0
 public AssaultSoldier(Game game, RandomMap randomMap, float xPos, float yPos, int width, int height)
     : base(game, randomMap, "images/stance", xPos, yPos, width, height)
 {
     this.gun = new AssaultRifle(game, randomMap, 50f, 50f, 32, 32);
     this.inventory[0] = this.gun;
 }