public virtual void GotShoot(TC_weapon w) { if (ID != w.createdPlayerID) //test if the weapon is from the player and decrease the Health { Health -= w.damage; //decrease movement (implement later) } }
public virtual Weapon ShipUpdate(KeyboardState newState, KeyboardState oldState) { if (newState.IsKeyDown(Keys.W) && _position.Y > 32) //handle vertical movement { moveVector += new Vector2(0, -currentSpeed); newFireDirection += new Vector2(0, -1); //the direction to fire } else if (newState.IsKeyDown(Keys.S) && _position.Y < 736) { moveVector += new Vector2(0, currentSpeed); newFireDirection += new Vector2(0, 1); } if (newState.IsKeyDown(Keys.A) && _position.X > 32) //handle horizontal movement { moveVector += new Vector2(-currentSpeed, 0); newFireDirection += new Vector2(-1, 0); } else if (newState.IsKeyDown(Keys.D) && _position.X < 1252) { moveVector += new Vector2(currentSpeed, 0); newFireDirection += new Vector2(1, 0); } if (oldState != newState && newState.IsKeyDown(Keys.H) && weapon != null) firedWeapon = Shoot(weapon.createdPlayerID, weapon.speed); else firedWeapon = null; if (newState.IsKeyDown(Keys.W) || newState.IsKeyDown(Keys.S) || newState.IsKeyDown(Keys.D) || newState.IsKeyDown(Keys.A)) { angle = GetAngle(); currentFireDirection = newFireDirection; newFireDirection = Vector2.Zero; _position += moveVector; } moveVector = Vector2.Zero; return firedWeapon; }