public override void Update(Player0 player) { base.Update(player); // nothing to do player.Velocity = Vector2f.Zero; }
public void AddObservers(IViewPlayer viewPlayer0, IViewPlayer viewPlayer1, IViewLog viewLog) { Player0.AddLogObserver(viewLog); Player1.AddLogObserver(viewLog); Player0.AddPlayerObserver(viewPlayer0); Player1.AddPlayerObserver(viewPlayer1); Start += viewLog.StartGameLog; NextTurn += viewPlayer0.SwitchControls; NextTurn += viewPlayer1.SwitchControls; }
public override void Update(Player0 player) { base.Update(player); player.Velocity = CurrentDashVelocity; CurrentDashVelocity *= 0.5; if (player.Velocity.X < DashEndThreshold) { player.ChangeToPreviousMovement(); } }
public Game(BasicGame other) : base(new Simulation.Board(other.Board), (other.Player0 == null) ? null : other.Player0.Clone(), (other.Player1 == null) ? null : other.Player1.Clone()) { if (Player0.IsOfType <Human>()) { Player0 = new SimpleAI(other.Player0); } if (Player1.IsOfType <Human>()) { Player1 = new SimpleAI(other.Player1); } }
public void NextStep(BodyPart bodyPart) { roundIndex++; if (roundIndex % 2 == 0) { Player0.Blocked = bodyPart; Player0.GetHit(Bot.choseBodyPart()); } else { Player1.Blocked = Bot.choseBodyPart(); Player1.GetHit(bodyPart); } NextTurn?.Invoke(this, new EventArgs()); }
public override void Update(Player0 player) { base.Update(player); if (Jump.Y == 0 && player.ObstacleAt(Side.Down)) { player.ChangeToPreviousMovement(); } else { if (Jump != Vector2f.Zero) { player.Velocity = Jump; Jump = Vector2f.Zero; } // air control player.Velocity.X = Freeze ? 0 : Direction.X * AirStep * RunMultiplier; player.Velocity.Y += Gravity; } }
public abstract void HandleButton(InputButton button, InputButtonState state, Player0 player);
public override void HandleButton(InputButton button, InputButtonState state, Player0 player) { // dashing is uncontrollable if (state == InputButtonState.Released) { if ((button == InputButton.Right && Direction.X > 0) || (button == InputButton.Left && Direction.X < 0)) { player.AddMovement(new Idle()); } else if (button == Settings.Instance.InputMappings.Run) { player.AddMovement(new Walking(Direction.Normalize())); } } }
public override void HandleButton(InputButton button, InputButtonState state, Player0 player) { if (state == InputButtonState.Pressed) { // if direction was changed in air if (button == InputButton.Left || button == InputButton.Right) { // if opposite direction is pressed if ((button == InputButton.Left && Direction.X > 0) || (button == InputButton.Right && Direction.X < 0)) { Freeze = true; player.AddMovement(new Walking(this)); } else { // set new direction Direction = new Vector2f(button == InputButton.Right ? 1 : -1, Direction.Y); player.AddMovement(new Walking(Direction)); } } else if (button == Settings.Instance.InputMappings.Crouch) { player.ChangeMovement(new Diving(this), false); } else if (button == Settings.Instance.InputMappings.Jump) { if (ExtraJump > 0) { ExtraJump--; Jump = new Vector2f(0, JumpImpulse * DoubleJumpMultiplier); } } else if (button == Settings.Instance.InputMappings.Dash) { if (!Freeze && Math.Abs(Direction.X) > 0) { player.ChangeMovement(new Dashing(this), false); } } } else if (state == InputButtonState.Released) { if (button == InputButton.Right || button == InputButton.Left) { if (Freeze) { // player should continue moving in the one that is still pressed Direction = new Vector2f(button == InputButton.Right ? -1 : 1, Direction.Y); Freeze = false; player.AddMovement(new Walking(Direction)); } else { Direction = new Vector2f(0, Direction.Y); player.AddMovement(new Idle()); } } else if (button == Settings.Instance.InputMappings.Jump) { if (player.Velocity.Y > 0) { player.Velocity.Y = 0.0; } } else if (button == Settings.Instance.InputMappings.Run) { RunMultiplier = 1.0; player.AddMovement(new Walking(this)); } } }
public override void HandleButton(InputButton button, InputButtonState state, Player0 player) { }
public override void HandleButton(InputButton button, InputButtonState state, Player0 player) { if (state == InputButtonState.Released) { if (button == Settings.Instance.InputMappings.Crouch) { player.ChangeMovement(new Falling(this), false); } else if (button == InputButton.Left || button == InputButton.Right) { if (Freeze) { // player should continue moving in the one that is still pressed Direction = new Vector2f(button == InputButton.Right ? -1 : 1, Direction.Y); Freeze = false; player.AddMovement(new Walking(this)); } else { Direction = new Vector2f(0, Direction.Y); player.AddMovement(new Idle()); } } } }
public override void Update(Player0 player) { }