Ejemplo n.º 1
0
 public Player()
 {
     Hand = new Hand();
 }
Ejemplo n.º 2
0
 protected virtual void OnTriggerEnter(Collider other)
 {
     if (mState == State.held)
     {
         if (other.transform.gameObject.layer == LayerMask.NameToLayer("Wall"))
         {
             isInWall = other.transform;
         }
         else
         {
             //Debug.Log("碰撞到的物体" + other.gameObject.name);
             Instrument adsorbInstrument = other.gameObject.GetComponentInParent <Instrument>();
             //Debug.Log(adsorbInstrument);
             //碰到的对象不是仪器,变红
             if (adsorbInstrument == null)
             {
                 if (other.gameObject.layer == LayerMask.NameToLayer("Player"))
                 {
                     if (other.GetComponentInParent <Valve.VR.InteractionSystem.HandCollider>())
                     {
                         if (other.GetComponentInParent <Valve.VR.InteractionSystem.HandCollider>().transform.name == "HandColliderLeft(Clone)")
                         {
                             ScaleHand = LeftHand.Instance.GetComponent <HandBase>();
                             ScaleHand.ScaleInstrument = this;
                         }
                         //else if (other.GetComponentInParent<Valve.VR.InteractionSystem.HandCollider>().transform.name == "HandColliderRight(Clone)")
                         //{
                         //    ScaleHand = RightHand.Instance.GetComponent<HandBase>();
                         //    ScaleHand.ScaleInstrument = this;
                         //}
                     }
                     return;
                 }
                 SetRenderer(HeldState.red);
                 isHeldCollision = true;
             }
             else
             {//碰到的对象是仪器
                 if (groupInstrumentList != null && groupInstrumentList.Contains(adsorbInstrument))
                 {
                     //是自己的内部仪器,什么都不做
                 }
                 else
                 {
                     isHeldCollision = true;
                     //不是自己的内部仪器
                     //判断是否可以吸附
                     if (adsorbTypeList != null && adsorbInstrument.adsorbCollider == other && adsorbTypeList.Contains(adsorbInstrument.type))
                     {
                         //可以吸附
                         curAdsorbInstrument = adsorbInstrument;
                         SetRenderer(HeldState.green);
                     }
                     else
                     {
                         //不可以吸附
                         SetRenderer(HeldState.red);
                     }
                 }
             }
         }
     }
 }