public void Update(Player p) { if (_shootingTime >= MAX_SHOOTING_TIME) { Console.WriteLine("Shooting done... Going back to previous state: " + _stateStack.Peek()); p.ChangeState(_stateStack.Pop()); } }
public IPlayerState HandleInput(Player p, Input input) { if (input == Input.DPad_Up) return new StandingState(); if (input == Input.JumpButton_Down) return new Jumping(); return this; }
public IPlayerState HandleInput(Player p, Input input) { if (input == Input.JumpButton_Down) return new Jumping(); if (input == Input.DPad_Down) return new DuckingState(); if (input == Input.Shooting) return new ShootingState(this); return this; }
public void Update(Player p) { if (_hasExploded) return; _chargeTime++; Console.Write(_chargeTime); if (_chargeTime > MAX_CHARGE) { p.SuperBomb(); _hasExploded = true; } }
static void Main(string[] args) { Player p = new Player("Mario"); Input input = Input.Idle; bool quit = false; while (!quit) { //Console.WriteLine(input); p.Update(); input = InputHandler.HandleInput(); p.HandleInput(input); if (input == Input.Quit) quit = true; } }
public void EnterState(Player p) { Random r = new Random(); int a = r.Next(10); p.SetGraphics("IMAGE_STANDING " + a); }
public void Update(Player p) { Console.WriteLine("Standing..."); }
public void ExitState(Player p) { }
public void EnterState(Player p) { p.SetGraphics("IMAGE_DUCKING"); }
public IPlayerState HandleInput(Player p, Input input) { return this; }
public void ExitState(Player p) { Console.ForegroundColor = ConsoleColor.Gray; }
public void EnterState(Player p) { Console.WriteLine("Popping: " + _stateStack.Pop()); p.SetGraphics("SHOOTING_IMAGE"); Console.ForegroundColor = ConsoleColor.DarkGray; }
public static bool Is(this State.Player a, State.Player b) { return((a & b) > 0); }
public static bool Isnot(this State.Player a, State.Player b) { return((a & b) == 0); }