void Start() { CurrentState = new CapsuleIdle(gameObject); gameObject.GetComponent <NPCStatus>().OnDeath += DeathActions; if (!isGhost) { ghostEmmision.Stop(); } }
public void SetState(BaseState state) { if (CurrentState != null) { CurrentState.OnStateLeave(); } CurrentState = (NPCBaseState)state; if (CurrentState != null) { CurrentState.OnStateEnter(); } }
//Representing the current state of Crowley aka black angel public void NPCShowState(NPCBaseState state) { //Check if current state is idle state if (state.GetType() == typeof(NPCIdleState)) { setButtonDown(NPCIdleStateButton); //Is currently idle setButtonUp(NPCKissingStateButton); //Not currently kissing setButtonUp(NPCTransformStateButton); //Not currently transforming setButtonUp(NPCTalkingStateButton); //Not currently talking setButtonUp(NPCUncomfortableStateButton); //Not currently uncomfortable } else if (state.GetType() == typeof(NPCKissingState)) { setButtonUp(NPCIdleStateButton); //Not currently idle setButtonDown(NPCKissingStateButton); //Is currently kissing setButtonUp(NPCTransformStateButton); //Not currently transforming setButtonUp(NPCTalkingStateButton); //Not currently talking setButtonUp(NPCUncomfortableStateButton); //Not currently uncomfortable } else if (state.GetType() == typeof(NPCTransformState)) { setButtonUp(NPCIdleStateButton); //Not currently idle setButtonUp(NPCKissingStateButton); //Not currently kissing setButtonDown(NPCTransformStateButton); //Is currently transforming setButtonUp(NPCTalkingStateButton); //Not currently talking setButtonUp(NPCUncomfortableStateButton); //Not currently uncomfortable } else if (state.GetType() == typeof(NPCTalkingState)) { setButtonUp(NPCIdleStateButton); //Not currently idle setButtonUp(NPCKissingStateButton); //Not currently kissing setButtonUp(NPCTransformStateButton); //Not currently transforming setButtonDown(NPCTalkingStateButton); //Is currently talking setButtonUp(NPCUncomfortableStateButton); //Not currently uncomfortable } else if (state.GetType() == typeof(NPCUncomfortableState)) { setButtonUp(NPCIdleStateButton); //Not currently idle setButtonUp(NPCKissingStateButton); //Not currently kissing setButtonUp(NPCTransformStateButton); //Not currently transforming setButtonUp(NPCTalkingStateButton); //Not currently talking setButtonDown(NPCUncomfortableStateButton); //Is currently uncomfortable } }
public void TransitionToState(NPCBaseState state) { //Store and set current concrete state currentState = state; //set the state as the current state currentState.EnterState(this); //Activate the EnterState function of a new state for player avatar when a transition is triggered }
void Start() { CurrentState = new NPCIdle(gameObject); }
// Start is called before the first frame update void Start() { CurrentState = new WarriorIdle(gameObject); gameObject.GetComponent <NPCStatus>().OnDeath += () => { SetState(new NPCDead(gameObject)); StartCoroutine(death()); }; }