示例#1
0
 public void Init()
 {
     rad        = this.GetComponent <RectTransform>().sizeDelta.y * 0.3f;
     defaultPos = this.transform.position;
     isDrag     = false;
     scr_player = _player.transform.GetChild(0).GetComponent <cPlayer>();
     scr_player.SetDir(Vector2.right);
     scr_player.SetCurMoveSpeed(0);
     stickDir = JOYSTICKDIR.IDLE;
 }
示例#2
0
    private void Update()
    {
        //위
        if (Mathf.Abs(joyDir.x) < 0.3f && joyDir.y > 0.7f)
        {
            stickDir = JOYSTICKDIR.UP;
        }
        //오른
        else if (Mathf.Abs(joyDir.y) < 0.7f && joyDir.x > 0.3f)
        {
            stickDir = JOYSTICKDIR.RIGHT;
        }
        //아래
        else if (Mathf.Abs(joyDir.x) < 0.3f && joyDir.y < -0.7f)
        {
            stickDir = JOYSTICKDIR.DOWN;
        }
        //왼
        else if (Mathf.Abs(joyDir.y) < 0.7f && joyDir.x < -0.3f)
        {
            stickDir = JOYSTICKDIR.LEFT;
        }
        else
        {
            stickDir = JOYSTICKDIR.IDLE;
        }
#if UNITY_EDITOR
        //점프
        if (Input.GetKeyDown(KeyCode.Space))
        {
            if (scr_player.GetStatus() != CHARACTERSTATUS.ATTACK)
            {
                scr_player.isJumpStart = true;

                // 점프 횟수 증가
                scr_player.jumpCount++;
                if (scr_player.jumpCount > 2)
                {
                    return;
                }
                Jump();
            }
        }
        //대쉬
        if (Input.GetKeyDown(KeyCode.D))
        {
            Dash();
        }
        //공격
        if (Input.GetKeyDown(KeyCode.A))
        {
            if (scr_player.GetStatus() != CHARACTERSTATUS.ATTACK)
            {
                Attack();
            }
        }
        else if (Input.GetKey(KeyCode.A))
        {
            if (scr_player.GetStatus() != CHARACTERSTATUS.ATTACK)
            {
                Attack();
            }
        }
#endif
        ////////////////////////////////안드로이드///////////////////////////////////
        if (scr_player.GetIsGrounded().Equals(true))
        {
            scr_player.SetIsClimbing(false);
        }

        if (scr_player.GetStatus() == CHARACTERSTATUS.ATTACK)
        {
            if (scr_player.GetIsMoveAttack().Equals(false))
            {
                scr_player.SetCurMoveSpeed(0);
            }
        }
        else
        {
            if (isDrag.Equals(true))
            {
                //위
                if (stickDir == JOYSTICKDIR.UP)
                {
                    CalcDir(0);
                }
                //오른
                else if (stickDir == JOYSTICKDIR.RIGHT)
                {
                    CalcDir(1);
                }
                //아래
                else if (stickDir == JOYSTICKDIR.DOWN)
                {
                    CalcDir(2);
                }
                //왼
                else if (stickDir == JOYSTICKDIR.LEFT)
                {
                    CalcDir(3);
                }
            }
        }
    }