예제 #1
0
    void DoingAction()
    {
        if (this.IsStatus(GlobalCharacterInfo.CHAR_STATUS.DEAD))
        {
            //사망 시 1순위 이벤트
        }
        else
        {
            if (this.IsStatus(GlobalCharacterInfo.CHAR_STATUS.HIT))
            {
                //피격 시 2순위 이벤트
            }
            else
            {
                //나머지 3순위 이벤트 모두 동일
                if (this.IsStatus(GlobalCharacterInfo.CHAR_STATUS.MOVE) || this.IsStatus(GlobalCharacterInfo.CHAR_STATUS.DASH_MOVE))
                {
                    transform.localScale = new Vector3(this.moveValue.moveWeight > 0 ? 1 : -1, 1, 1);
                    //이동
                    if (isBlink && this.IsStatus(GlobalCharacterInfo.CHAR_STATUS.DASH_MOVE))
                    {
                        RaycastHit2D rayHitData = Physics2D.Raycast(
                            new Vector2(transform.position.x, transform.position.y),
                            new Vector2(IsRight() ? 1 : -1, 0),
                            m_stPlayerMove.m_fBlinkDistance, 1 << GlobalLayerMask.TERRIAN_MASK);
                        bool    canMaxBlink   = rayHitData.collider ? false : true;
                        Vector3 startPosition = gameObject.transform.position;
                        Vector3 nextPosition  = new Vector3(
                            canMaxBlink ?
                            startPosition.x + (IsRight() ? m_stPlayerMove.m_fBlinkDistance : -m_stPlayerMove.m_fBlinkDistance) :
                            rayHitData.point.x,
                            startPosition.y,
                            startPosition.z);

                        //Blink Action
                        this.transform.position = nextPosition;
                        //Clear Data Blink 직후 멈춰야함.
                        nowStatus           &= ~GlobalCharacterInfo.CHAR_STATUS.DASH_MOVE;
                        moveValue.prevValue  = KeyCode.None;
                        moveValue.moveWeight = 0;

                        StartCoroutine(BlinkAnimation(startPosition, nextPosition, IsRight()));
                    }
                    else
                    {
                        this.transform.Translate(moveValue.moveWeight, 0, 0);
                    }
                }

                if (this.IsStatus(GlobalCharacterInfo.CHAR_STATUS.JUMP))
                {
                    // 점프
                    this.rigid2D.AddForce(transform.up * JUMP_FORCE);
                    nowStatus &= ~GlobalCharacterInfo.CHAR_STATUS.JUMP;
                }

                if (isRavitate && IsStatus(GlobalCharacterInfo.CHAR_STATUS.RAVITATE))
                {
                    float yVel = (rigid2D.velocity.y + Physics.gravity.y) * rigid2D.gravityScale;
                    //Howering
                    rigid2D.AddForce(new Vector2(0, -yVel), ForceMode2D.Force);
                }

                if (this.IsStatus(GlobalCharacterInfo.CHAR_STATUS.ATTACK))
                {
                    // 공격
                    weaponController.AttackMotion();
                    nowStatus &= ~GlobalCharacterInfo.CHAR_STATUS.ATTACK;
                }

                if (this.IsStatus(GlobalCharacterInfo.CHAR_STATUS.SKILL))
                {
                    // 스킬
                    skillController.ActionSkill(selectedCharacterType);
                    nowStatus &= ~GlobalCharacterInfo.CHAR_STATUS.SKILL;
                }
            }
        }
    }