void Awake() { anim = GetComponent <Animator>(); goal_pos = Vector3.zero; state = CHAR_STATE.IDLE; speed = 3.0f; atk_numeric = 0; }
public static void Main(string[] args) { CHAR_STATE charState = CHAR_STATE.IDLE; Console.WriteLine("캐릭터 상태 {0} {1}", charState, (int)charState); charState = CHAR_STATE.DIE; Console.WriteLine("캐릭터 상태 {0} {1}", charState, (int)charState); }
void OnCollisionEnter(Collision col) { if (col.transform.name.Equals("Crash_Obstacle")) { if (state == CHAR_STATE.RUN) { anim.SetBool("is_run", false); anim.SetTrigger("is_damage"); state = CHAR_STATE.DAMAGE; } } }
void Update_Actions() { switch (state) { case CHAR_STATE.IDLE: break; case CHAR_STATE.RUN: Vector3 move_pos = Vector3.zero; if (Vector3.Distance(goal_pos, Get_Pos()) > .02f) { move_pos = Vector3.Normalize(goal_pos - Get_Pos()); } else { anim.Play("Idle"); anim.SetBool("is_run", false); Set_Pos(goal_pos); state = CHAR_STATE.IDLE; } Add_Pos(move_pos * speed * Time.deltaTime); if (rigid.isKinematic == true) { rigid.isKinematic = false; } break; case CHAR_STATE.ATTACK: if (anim.GetCurrentAnimatorStateInfo(0).IsName("Idle")) { ; } { state = CHAR_STATE.IDLE; } break; case CHAR_STATE.DAMAGE: if (anim.GetCurrentAnimatorStateInfo(0).IsName("Idle")) { state = CHAR_STATE.IDLE; } break; case CHAR_STATE.NONE: default: break; } }
static void Main(string[] args) { CHAR_STATE charState = CHAR_STATE.IDLE; Console.WriteLine("캐릴터 상태: {0} {1}", charState, (int)charState); charState = CHAR_STATE.RUN; Console.WriteLine("캐릴터 상태: {0} {1}", charState, (int)charState); charState = CHAR_STATE.DIE; Console.WriteLine("캐릴터 상태: {0} {1}", charState, (int)charState); Console.WriteLine("CLICK_STATE: {0} {1}", CLICK_STATE.NONE, (int)CLICK_STATE.NONE); Console.WriteLine("CLICK_STATE: {0} {1}", CLICK_STATE.CLICK, (int)CLICK_STATE.CLICK); Console.WriteLine("CLICK_STATE: {0} {1}", CLICK_STATE.DOUBLE_CLICK, (int)CLICK_STATE.DOUBLE_CLICK); Console.WriteLine("CLICK_STATE: {0} {1}", CLICK_STATE.UP, (int)CLICK_STATE.UP); }
void Update_Inputs() { Ray ray; RaycastHit hit; if (Input.GetMouseButton(0)) { ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { anim.Play("Run"); anim.SetBool("is_run", true); state = CHAR_STATE.RUN; goal_pos = hit.point; transform.localRotation = Quaternion.LookRotation(goal_pos - Get_Pos()); } } if (Input.GetKeyDown("1")) { if (state == CHAR_STATE.RUN) { anim.SetBool("is_run", false); } state = CHAR_STATE.ATTACK; anim.SetTrigger("is_attack_jab"); } else if (Input.GetKeyDown("2")) { if (state == CHAR_STATE.RUN) { anim.SetBool("is_run", false); } state = CHAR_STATE.ATTACK; anim.SetTrigger("is_attack_hikick"); } }