override public void BuildStateList() { base.BuildStateList(); _character.GetStateDic().Add(Character.eState.IDLE, new IdleState()); for (int i = 0; i < _character.GetStateDic().Count; i++) { Character.eState state = (Character.eState)i; _character.GetStateDic()[state].SetCharacter(_character); } _character.ChangeState(Character.eState.IDLE); }
override public void UpdateAI() { base.UpdateAI(); // 키 입력에 따라 8방향으로 이동 (WASD) Vector3 curPos = _character.transform.position; Vector3 destPos = curPos; if (true == Input.GetKey(KeyCode.D)) // 우 { destPos.x = destPos.x + 1; } else if (true == Input.GetKey(KeyCode.A)) // 좌 { destPos.x = destPos.x - 1; } if (true == Input.GetKey(KeyCode.W)) // 전 { destPos.z = destPos.z + 1; } else if (true == Input.GetKey(KeyCode.S)) // 후 { destPos.z = destPos.z - 1; } _character.SetDestination(destPos); Character.eState nextState = Character.eState.IDLE; if (false == curPos.Equals(destPos)) { nextState = Character.eState.RUN; } if (nextState != _character.GetStateType()) { _character.ChangeState(nextState); } // 총알 발사 (마우스 왼쪽 버튼) if (true == Input.GetMouseButton(0)) { _character.Fire(0); } }
// Start is called before the first frame update override public void BuildStateList() { base.BuildStateList(); _character.GetStateDic().Add(Character.eState.IDLE, new PlayerIdleState()); /* * _character.GetStateDic().Add(Character.eState.WAIT, new WaitState()); * _character.GetStateDic().Add(Character.eState.KICK, new KickState()); * _character.GetStateDic().Add(Character.eState.WALK, new WalkState()); * _character.GetStateDic().Add(Character.eState.RUN, new RunState()); * _character.GetStateDic().Add(Character.eState.SLIDE, new SlideState()); * _character.GetStateDic().Add(Character.eState.PATROL, new PatrolState()); * _character.GetStateDic().Add(Character.eState.DEATH, new DeathState()); */ for (int i = 0; i < _character.GetStateDic().Count; i++) { Character.eState state = (Character.eState)i; _character.GetStateDic()[state].SetCharacter(_character); } _character.ChangeState(Character.eState.IDLE); }
virtual public void ChangeState(Character.eState nextState) { _character.ChangeState(nextState); }
override public void ChangeState(Character.eState nextState) { //_character.ChangeState(nextState); // 도착했으면 // 체인지 스테이트 작동 }