示例#1
0
    void OnCollisionEnter(Collision collision)
    {
        //Debug.Log(transform.name + "얘랑" + collision.gameObject.name);
        // 점프 해제
        if (collision.gameObject.CompareTag("Ground"))
        {
            Ani_State_Jump = ANI_TYPE.IDEL;
        }



        // 문 충돌
        if (collision.gameObject.CompareTag("Door"))
        {
            isItem = true;

            if (Input.GetKey(KeyCode.F))
            {
                isPick = true;
                isItem = false;
            }
        }

        // 몬스터 충돌
        if (collision.gameObject.CompareTag("Monster"))
        {
            isMon = true;
        }

        // 지붕등 충돌
        if (collision.gameObject.CompareTag("wall"))
        {
            SetLayersRecursively(collision.gameObject.transform, "wall");
        }
    }
示例#2
0
    // Update is called once per frame
    void Update()
    {
        if (ID == Game.Network.NetWork.Client_id)
        {
            if (hp <= 1)
            {
                GameObject.Find("Canvas/UI_outline/dead").SetActive(true);
                //dead
                is_move = false;
                isdie   = true;
                // 사망 애니메이션
                Ani_State = ANI_TYPE.DIE;
            }

            if (is_move)
            {
                MoveStatus();
            }
        }
        RecvStatus();
    }
示例#3
0
    void MoveStatus()
    {
        // 방향에 따라 Direction 변화
        if (Input.GetKeyDown(KeyCode.W))
        {
            Direction_Z = 1;
        }
        if (Input.GetKeyDown(KeyCode.S))
        {
            Direction_Z = -1;
        }
        if (Input.GetKeyDown(KeyCode.A))
        {
            Direction_X = -1;
        }
        if (Input.GetKeyDown(KeyCode.D))
        {
            Direction_X = 1;
        }
        if (Input.GetKeyDown(KeyCode.Q))
        {
            Direction_Z = 1;
            Direction_X = -0.1f;
        }
        if (Input.GetKeyDown(KeyCode.E))
        {
            Direction_Z = 1;
            Direction_X = 0.1f;
        }

        if (Input.GetKeyUp(KeyCode.W) || Input.GetKeyUp(KeyCode.S))
        {
            Direction_Z = 0;
        }
        if (Input.GetKeyUp(KeyCode.D) || Input.GetKeyUp(KeyCode.A))
        {
            Direction_X = 0;
        }
        //if (Input.GetKeyUp(KeyCode.Q) || Input.GetKeyUp(KeyCode.E)) Direction_X = 0;

        // 걷기
        if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.Q) || Input.GetKey(KeyCode.E))
        {
            // idle 상태일때 키를 누르면 walk 상태로 전환
            if (Ani_State == ANI_TYPE.IDEL)
            {
                Ani_State = ANI_TYPE.WALK;
            }


            if (Input.GetKey(KeyCode.W))
            {
                Direction_Z = 1;
                if (Input.GetKey(KeyCode.A))
                {
                    Direction_X = -1;
                }
                if (Input.GetKey(KeyCode.D))
                {
                    Direction_X = 1;
                }
            }
            if (Input.GetKey(KeyCode.S))
            {
                Direction_Z = -1;
                if (Input.GetKey(KeyCode.A))
                {
                    Direction_X = -1;
                }
                if (Input.GetKey(KeyCode.D))
                {
                    Direction_X = 1;
                }
            }
            if (Input.GetKey(KeyCode.A))
            {
                Direction_X = -1;
                if (Input.GetKey(KeyCode.W))
                {
                    Direction_Z = 1;
                }
                if (Input.GetKey(KeyCode.S))
                {
                    Direction_Z = -1;
                }
            }
            if (Input.GetKey(KeyCode.D))
            {
                Direction_X = 1;
                if (Input.GetKey(KeyCode.W))
                {
                    Direction_Z = 1;
                }
                if (Input.GetKey(KeyCode.S))
                {
                    Direction_Z = -1;
                }
            }

            // 반대 방향키를 같이 누르고 있으면 제자리 서기
            if ((Input.GetKey(KeyCode.W) && Input.GetKey(KeyCode.S)) || (Input.GetKey(KeyCode.A) && Input.GetKey(KeyCode.D)) || (Input.GetKey(KeyCode.Q) && Input.GetKey(KeyCode.E)))
            {
                Ani_State   = ANI_TYPE.IDEL;
                Direction_X = 0;
                Direction_Z = 0;
            }

            // walk인지 run인지에 따라 속도 변화
            if ((Ani_State == ANI_TYPE.WALK) && speedT < Player_Max_Walk_Speed)
            {
                speedT += 0.2f;
            }
            else if (Ani_State == ANI_TYPE.RUN)
            {
                speedT = 8f;
            }
            else
            {
                speedT = Player_Max_Walk_Speed;
            }
        }
        else
        {
            Ani_State   = ANI_TYPE.IDEL;
            Direction_X = 0;
            Direction_Z = 0;
            speedT      = 0;
        }

        if ((Input.GetKeyDown(KeyCode.LeftShift)) && (Ani_State <= ANI_TYPE.WALK))
        {
            Ani_State = ANI_TYPE.RUN;
        }
        if ((Input.GetKey(KeyCode.LeftShift)) && (Ani_State <= ANI_TYPE.WALK))
        {
            Ani_State = ANI_TYPE.RUN;
        }
        if ((Input.GetKeyUp(KeyCode.LeftShift)) && (Ani_State == ANI_TYPE.RUN))
        {
            Ani_State = ANI_TYPE.WALK;
        }

        // Shift 키를 누르고 있는데 방향키는 안누른 상태 --> 달리기 멈추기
        if (Input.GetKey(KeyCode.LeftShift) && Direction_X == 0 && Direction_Z == 0)
        {
            Ani_State = ANI_TYPE.IDEL;
        }

        // 점프
        if ((Input.GetKeyDown(KeyCode.Space)) && (Ani_State_Jump == ANI_TYPE.IDEL))
        {
            Debug.Log("점프1");
            Ani_State_Jump = ANI_TYPE.JUMP;
        }

        CheatKey();
    }