示例#1
0
        /// <summary>
        /// Prevents a default instance of the <see cref="WeaponHandler"/> class from being created.
        /// </summary>
        private WeaponHandler()
        {
            // This demonstrates the power of OOP. To add a weapon, with it's own attributes, simply add it to the
            // list (making sure the name matches a folder in the Weapon folder, to load textures and sounds)
            this.weapons = new[]
                {
                    new Weapon("Minigun", 10000, 1000, 50, true, true), new Weapon("Pistol", 10, 100, 5, false, false),
                    new Weapon("Rifle", 30, 50, 10, true, false)
                };
            #if XBOX
            this.ReticulePosition = new Vector2(Game1.GameScreenWidth / 2, Game1.GameScreenHeight / 2);
            #endif
            // If godmode is active, use the minigun. If not, use the normal weapon
            if (!Tools.GameConstants.GodMode)
            {
                this.currentWeaponIndex = 1;
            }

            this.currentWeapon = this.weapons[this.currentWeaponIndex];
        }
示例#2
0
        /// <summary>
        /// Changes the current weapon
        /// </summary>
        private void ChangeWeapon()
        {
            // If going to the next weapon takes you out of the array, start over
            if (this.currentWeaponIndex + 1 == this.weapons.Count())
            {
                // If God-mode is activated, allow the use of the god weapon. If not, start at index 1
                this.currentWeaponIndex = Tools.GameConstants.GodMode ? 0 : 1;
            }
            else
            {
                this.currentWeaponIndex++;
            }

            this.currentWeapon = this.weapons[this.currentWeaponIndex];
        }