public void ChangeState(IPlayerState state) { _state.ExitState(this); _state = null; // delete old state (not sure if this works?) _state = state; _state.EnterState(this); }
public void SetState(IPlayerState newstate) { if (_state != newstate) { Log.AddLog(LogType.GENERAL, "change state: old={0} new={1}", _state.StateName(), newstate.StateName()); _state = newstate; _state.EnterState(this); if (_state.StateName() == "in-base-state") { Ship.IsDestroyed = false; } } }
/// <summary> /// At object creation time we assume that the freelancer player has connected to the /// proxy server and is expecting the normal freelancer server login sequence. This /// class manages this message exchange until they select a character at which point /// the controller will establish a connection to a slave freelancer server and /// forward traffic between the two. /// </summary> /// <param name="dplayid"></param> /// <param name="log"></param> /// <param name="flplayerid"></param> /// <param name="runner"></param> public Player(Session dplayid, ILogController log, uint flplayerid, DPGameRunner runner) { DPSess = dplayid; Log = log; FLPlayerID = flplayerid; Runner = runner; Ship = new Old.Object.Ship.Ship(runner) { player = this }; Wgrp = new WeaponGroup(); _state = DPCLoginState.Instance(); _state.EnterState(this); }
public void HandleInput(Input input) { IPlayerState temp = _state.HandleInput(this, input); if (temp != _state) { _state.ExitState(this); _state = null; // delete old state (not sure if this works?) _state = temp; _state.EnterState(this); } if (input == Input.Idle) { _state.TimePass(1); Console.WriteLine("Time has passed by 1"); } if (input == Input.TimeFastForward) { _state.TimePass(10); Console.WriteLine("Time has passed by 10"); } }
private void HandleInput() { if (!disableInput) { IPlayerState newState = state.HandleInput(this); if (newState != null) { state.ExitState(this); state = newState; state.EnterState(this); } IAttack newAttackState = attackState.HandleInput(this); if (newAttackState != null) { attackState.ExitState(this); attackState = newAttackState; attackState.EnterState(this); } } }
IPlayerState SwitchState(IPlayerState newState) { if (newState != movementState) { newState.EnterState(this); } return newState; }