From 071edce23d95a45b06de633da98d8aaad92b686d Mon Sep 17 00:00:00 2001 From: tyrosine1153 Date: Thu, 9 Dec 2021 19:13:41 +0900 Subject: [PATCH] Add "YuJeongMin211209" --- .../YuJeongMin211209/CharacterControl.cs | 44 +++++++++ YuJeongMin/YuJeongMin211209/CharacterState.cs | 95 +++++++++++++++++++ 2 files changed, 139 insertions(+) create mode 100644 YuJeongMin/YuJeongMin211209/CharacterControl.cs create mode 100644 YuJeongMin/YuJeongMin211209/CharacterState.cs diff --git a/YuJeongMin/YuJeongMin211209/CharacterControl.cs b/YuJeongMin/YuJeongMin211209/CharacterControl.cs new file mode 100644 index 0000000..182dc20 --- /dev/null +++ b/YuJeongMin/YuJeongMin211209/CharacterControl.cs @@ -0,0 +1,44 @@ +using System; +using UniRx; +using UniRx.Triggers; +using UnityEngine; + +public partial class CharacterControl : MonoBehaviour +{ + private readonly State[] states = {new IdleState(), new SkillState(), new WalkState()}; + private State _curState; + + // Todo : 플레이어 캐릭터 기본 세팅(상태0, 히트박스0, 이동) + + private void Start() + { + _curState = states[(int)State.Idle]; + + this.UpdateAsObservable().Subscribe(_ => + { + _curState.Action(this); + var nextState = _curState.InputHandle(this); + + if (!_curState.Equals(nextState)) + { + _curState.Exit(this); + _curState = nextState; + _curState.Enter(this); + } + }).AddTo(this); + } + + // DamageCollider + public void OnCollisionEnterInChildren(Collision2D other) + { + throw new NotImplementedException(); + // ToDo : 피해 + } + + // ObjectCollider + public void OnTriggerEnterInChildren(Collider2D other) + { + throw new NotImplementedException(); + // ToDo : 오브젝트 교환 + } +} diff --git a/YuJeongMin/YuJeongMin211209/CharacterState.cs b/YuJeongMin/YuJeongMin211209/CharacterState.cs new file mode 100644 index 0000000..89b2d16 --- /dev/null +++ b/YuJeongMin/YuJeongMin211209/CharacterState.cs @@ -0,0 +1,95 @@ +using UnityEngine; + +public partial class CharacterControl +{ + public enum State + { + Idle, + Skill, + Walk + } + + public class IdleState : State + { + public override State InputHandle(CharacterControl t) + { + throw new System.NotImplementedException(); + // ToDo [Status조건 설정]: Idle -> Skill => 스킬 준비 조작을 했을 때 + return t.states[(int)State.Skill]; + // ToDo [Status조건 설정]: Idle -> Walk => 이동 조작을 했을 때 + return t.states[(int)State.Walk]; + } + + // ToDo : 상태별 동작 설정 + public override void Enter(CharacterControl t) + { + base.Enter(t); + // ToDo : 애니메이션 재생 + } + + public override void Update(CharacterControl t) + { + base.Update(t); + } + + public override void Exit(CharacterControl t) + { + base.Exit(t); + } + } + + public class SkillState : State + { + public override State InputHandle(CharacterControl t) + { + throw new System.NotImplementedException(); + // ToDo [Status조건 설정]: Skill -> Idle => 스킬을 취소했을 때 or 스킬 시전이 완료 되었을 때 + return t.states[(int)State.Idle]; + } + + // ToDo : 상태별 동작 설정 + public override void Enter(CharacterControl t) + { + base.Enter(t); + // ToDo : 애니메이션 재생 + } + + public override void Update(CharacterControl t) + { + base.Update(t); + } + + public override void Exit(CharacterControl t) + { + base.Exit(t); + } + } + + public class WalkState : State + { + public override State InputHandle(CharacterControl t) + { + throw new System.NotImplementedException(); + // ToDo [Status조건 설정]: Walk -> Idle => 이동 조이스틱에서 손을 땠을 때 or 이동 조이스틱 중앙에 손가락이 위치할 때 + return t.states[(int)State.Idle]; + } + + // ToDo : 상태별 동작 설정 + public override void Enter(CharacterControl t) + { + base.Enter(t); + // ToDo : 애니메이션 재생 + } + + public override void Update(CharacterControl t) + { + base.Update(t); + } + + public override void Exit(CharacterControl t) + { + base.Exit(t); + } + } + +} \ No newline at end of file