public DefaultPlayer(Texture2D texture, Vector2 position) : base(texture, position) { //Set up the keyboard movement/shooting events EnableKeyboardEvents(true); int hitboxWidth = 11, hitboxHeight = 11; int hitboxX = this.TextureBox.X + (int)((float)(this.TextureBox.Width) / 2 - (float)(hitboxWidth) / 2); int hitboxY = this.TextureBox.Y + (int)((float)(this.TextureBox.Height) / 2- (float)(hitboxHeight) / 2); this.HitBoxRadius = 8; this.HitBoxVertRatio = 0.4f; this.Health = 5; this.MaxHealth = this.Health; _drawHitbox = true; _weapons = new List<IWeapon>(); //Init to pellet gun? _currentGunUpgrade = GunUpgradeState.None; UpgradeGun(typeof(PelletGun)); }
public void UpgradeGun(System.Type weaponType) { bool gunChanged = false; bool missileChanged = false; if (weaponType == typeof(PelletGun)) { if (_currentGunUpgrade != GunUpgradeState.SinglePellet && _currentGunUpgrade != GunUpgradeState.DoublePellet && _currentGunUpgrade != GunUpgradeState.TriplePellet) { gunChanged = true; _currentGunUpgrade = GunUpgradeState.SinglePellet; } else if (_currentGunUpgrade == GunUpgradeState.SinglePellet) { gunChanged = true; _currentGunUpgrade = GunUpgradeState.DoublePellet; } else if (_currentGunUpgrade == GunUpgradeState.DoublePellet) { gunChanged = true; _currentGunUpgrade = GunUpgradeState.TriplePellet; } } else if (weaponType == typeof(MissileLauncher)) { if (_currentMissileUpgrade != MissileUpgradeState.SingleMissile && _currentMissileUpgrade != MissileUpgradeState.DoubleMissile) { missileChanged = true; _currentMissileUpgrade = MissileUpgradeState.SingleMissile; } else if (_currentMissileUpgrade == MissileUpgradeState.SingleMissile) { missileChanged = true; _currentMissileUpgrade = MissileUpgradeState.DoubleMissile; } } if (gunChanged) { _weapons.RemoveAll(x => x.GetType() == typeof(PelletGun)); switch (_currentGunUpgrade) { case GunUpgradeState.SinglePellet: _weapons.Add(new PelletGun(this.centerPosition, new Vector2(0, -this.Height / 3), new Vector2(0, -350), 100, true)); break; case GunUpgradeState.DoublePellet: _weapons.Add(new PelletGun(this.centerPosition, new Vector2(-this.Width / 3, -this.Height / 3), new Vector2(0, -350), 100, true)); _weapons.Add(new PelletGun(this.centerPosition, new Vector2(this.Width / 3, -this.Height / 3), new Vector2(0, -350), 100, true)); break; case GunUpgradeState.TriplePellet: _weapons.Add(new PelletGun(this.centerPosition, new Vector2(0, -this.Height / 3), new Vector2(0, -350), 100, true)); _weapons.Add(new PelletGun(this.centerPosition, new Vector2(-this.Width / 3, -this.Height / 3), new Vector2(-100, -300), 100, true)); _weapons.Add(new PelletGun(this.centerPosition, new Vector2(this.Width / 3, -this.Height / 3), new Vector2(100, -300), 100, true)); break; } } else if (missileChanged) { _weapons.RemoveAll(x => x.GetType() == typeof(MissileLauncher)); switch (_currentMissileUpgrade) { case MissileUpgradeState.SingleMissile: _weapons.Add(new MissileLauncher(this.centerPosition, new Vector2(0, 0), new Vector2(0, -200), 500, true)); break; case MissileUpgradeState.DoubleMissile: _weapons.Add(new MissileLauncher(this.centerPosition, new Vector2(-this.Width / 3, 0), new Vector2(0, -200), 500, true)); _weapons.Add(new MissileLauncher(this.centerPosition, new Vector2(this.Width / 3, 0), new Vector2(0, -200), 500, true)); break; } } }
public void ResetGuns() { _currentGunUpgrade = GunUpgradeState.None; UpgradeGun(typeof(PelletGun)); _currentMissileUpgrade = MissileUpgradeState.None; _weapons.RemoveAll(x => x.GetType() == typeof(MissileLauncher)); }