public void ChangeState(IPlayerState state) { if (currentState != null) { currentState.Exit(); previousState = currentState; } currentState = state; currentState.Enter(playerData); }
public void ChangeState(IPlayerState newState) { if (currentState != null) { currentState.Exit(); } currentState = newState; currentState.Enter(); }
public void SetState(IPlayerState state) { if (m_state != null) { m_state.Exit(); } m_state = state; m_state.Enter(); }
private void UpdateState(GameTime gameTime) { if (_state != null) { IPlayerState newState = _state.Update(this, gameTime); if (newState != null && _state != newState) { _state.Exit(this); _state = newState; _state.Enter(this); } } }
public void ChangeState(IPlayerState newState) { if (this.PlayerState != null) { PlayerState.Exit(); } PlayerState = newState; if (newState != null) { PlayerState.Enter(); } }
public void ChangeToState(IPlayerState state) { if (m_CurrentState != null) { m_CurrentState.Exit(); } m_CurrentState = state; if (m_CurrentState == null) { return; } m_CurrentState.Enter(this); }
public void HandleInput(KeyboardState input) { IPlayerState newState = _state.HandleInput(this, input); if (newState != null && _state != newState) { if (_state != null) { _state.Exit(this); } _state = newState; _state.Enter(this); } }
public void EnterState(IPlayerState state) { if (_currentState != null) { _currentState.Exit(); } if (!(state is RewindingPlayerState)) { StateStack.Push(state); } _previousState = _currentState; _currentState = state; _currentState.Enter(this); }
protected override void LoadContent() { Texture2D texture = this.Game.Content.Load <Texture2D>(SpriteTexture); Animation = new AnimatedSprite(texture, SpriteMap, AnimationFps); Origin = new Vector2(Animation.FrameWidth / 2f, Animation.FrameHeight / 2f); //Body = BodyFactory.CreateRectangle((Game as BazingaGame).World, ConvertUnits.ToSimUnits(Animation.FrameWidth), ConvertUnits.ToSimUnits(Animation.FrameHeight), 1f); Body = BodyFactory.CreateBody((Game as BazingaGame).World); Body.BodyType = BodyType.Dynamic; Body.Position = ConvertUnits.ToSimUnits(_initialX, _initialY); Body.FixedRotation = true; Body.Friction = 0.7f; Body.Restitution = 0.2f; Body.CollisionCategories = Category.Cat1; Body.CollidesWith = Category.All; _spriteBatch = new SpriteBatch(this.Game.GraphicsDevice); _state.Enter(this); base.LoadContent(); }
/// <summary> /// 狀態改變 /// </summary> /// <param name="nextState">下一個狀態</param> public void ChangeState(IPlayerState nextState) { StateHandle.Exit(); StateHandle = nextState; StateHandle.Enter(); }
public void TransitionToState(IPlayerState state) { CurrentState = state; CurrentState.Enter(this); }
void Awake() { mCurrentState = new StandingState(); mCurrentState.Enter(this); }