Пример #1
0
 void RunCheck()
 {
     //달리기 관련 부분
     //-----------------------------------------
     if (Input.GetKey(KeyCode.LeftShift))
     {
         if (x != 0 || z != 0)
         {
             moveSpeed += Constants.AddMoveSpeed;
             //달리기가 빨라지다가 최대속도를 넘을 시 최대 속도를 유지
             if (moveSpeed >= Constants.MaxMoveSpeed)
             {
                 moveSpeed = Constants.MaxMoveSpeed;
             }
             run = true;
             if (sbm.HangerBarSlider.value <= 0.001f)
             {
                 sbm.beShotImg.color = sbm.beShotImgColor;
                 ps.currHp          -= 1;
                 ps.playerStateUpdate(PhotonNetwork.player.ID);
             }
         }
     }
     else
     {
         if (run)
         {
             StartCoroutine(sbm.delayTime(2.0f));
         }
         //달리기가 빨라지다가 최대속도를 넘을 시 최대 속도를 유지
         moveSpeed -= Constants.AddMoveSpeed;
         //suc.HangerBarSlider.value += 0.3f;
         if (moveSpeed <= Constants.DefaultMoveSpeed)
         {
             moveSpeed = Constants.DefaultMoveSpeed;
         }
         run = false;
     }
 }
    private void OnCollisionEnter(Collision other)
    {
        if (!pv.isMine || ps.playerStateNum == Constants.DEAD)
        {
            return;
        }

        int collisionLayer = other.gameObject.layer;

        if (collisionLayer == LayerMask.NameToLayer("Empty"))
        {
            Destroy(other.gameObject);
        }
        else if (collisionLayer == LayerMask.NameToLayer("Bullet"))
        {
            sbm.beShotImg.color = sbm.beShotImgColor;
            //suc.beShotImg.color = suc.beShotImgColor;
            Destroy(other.gameObject);
            if (this.gameObject.name == "HeadCollider")
            {
                if (ps.currHp > 0)
                {
                    ps.currHp = 0;
                }
            }
            else if (this.gameObject.name == "RFootCollider" || this.gameObject.name == "LFootCollider")
            {
                if (ps.currHp > 0)
                {
                    ps.currHp -= 10;
                }
            }
            else if (this.gameObject.name == "LCalfCollider" || this.gameObject.name == "RCalfCollider")
            {
                if (ps.currHp > 0)
                {
                    ps.currHp -= 12;
                }
            }
            else if (this.gameObject.name == "BodyCollider")
            {
                if (ps.currHp > 0)
                {
                    ps.currHp -= 20;
                }
            }
            ps.playerStateUpdate(other.gameObject.GetComponent <BulletCheckCollider>().masterViewNum);
            pm.Action(this.gameObject.name);
            StartCoroutine(sbm.delayTime(2.0f));
        }
        else if (collisionLayer == LayerMask.NameToLayer("Knife"))// && !transform.root.gameObject) // cm.melee_attack)
        {
            Debug.Log("긁은 놈 : " + other.gameObject.GetComponent <KnifeCheckCollider>().masterViewNum);
            sbm.beShotImg.color = sbm.beShotImgColor;
            if (this.gameObject.name == "HeadCollider")
            {
                if (ps.currHp > 0)
                {
                    Debug.Log("머리 맞음");
                    ps.currHp = 0;
                }
            }
            else if (this.gameObject.name == "RFootCollider" || this.gameObject.name == "LFootCollider")
            {
                if (ps.currHp > 0)
                {
                    Debug.Log("종아리 맞음");
                    ps.currHp -= 20;
                }
            }
            else if (this.gameObject.name == "LCalfCollider" || this.gameObject.name == "RCalfCollider")
            {
                if (ps.currHp > 0)
                {
                    Debug.Log("허벅지 맞음");
                    ps.currHp -= 24;
                }
            }
            else if (this.gameObject.name == "BodyCollider")
            {
                if (ps.currHp > 0)
                {
                    Debug.Log("몸 맞음");
                    ps.currHp -= 30;
                }
            }
            ps.playerStateUpdate(other.gameObject.GetComponent <KnifeCheckCollider>().masterViewNum);
            pm.Action(this.gameObject.name);
            StartCoroutine(sbm.delayTime(2.0f));
        }
        else if (collisionLayer == LayerMask.NameToLayer("Ground2") && !ps.isGrounded)
        {
            if (this.gameObject.name == "LFootCollider" || this.gameObject.name == "RFootCollider")
            {
                //Debug.Log("발 닿음");
                ps.isGrounded = true;
            }
        }
    }