Exemplo n.º 1
0
 //Use the pistol
 private void UsePistol()
 {
     if (GrabedObject != null)
     {
         if (this_grabedObjectType == GrabedObjectType.Belt || this_grabedObjectType == GrabedObjectType.Magazine)
         {
             GrabedObject.transform.parent = null;
             GrabedObject.GetComponent <Rigidbody>().useGravity  = true;
             GrabedObject.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.None;
             GrabedObject          = null;
             this_grabedObjectType = GrabedObjectType.None;
         }
         else if (this_grabedObjectType == GrabedObjectType.Bomb)
         {
             UnUseBomb();
         }
         else if (this_grabedObjectType == GrabedObjectType.Pistol)
         {
             return;
         }
     }
     isGrabbedPistol = true;
     Hand_animator.SetBool("Catch", false);
     this_grabedObjectType = GrabedObjectType.Pistol;
     GrabedObject          = stateModels[0].ob;
     setSate(HandAnimationStateType.Pistol);
 }
Exemplo n.º 2
0
 //UnLoad the pistol from hand
 public void UnLoadPistol()
 {
     isGrabbedPistol = false;
     Hand_animator.SetBool("Catch", false);
     this_grabedObjectType = GrabedObjectType.None;
     GrabedObject          = null;
     setSate(HandAnimationStateType.None);
 }
Exemplo n.º 3
0
 public void UnUseBomb()
 {
     m_IsUseBomb = false;
     Destroy(GrabedObject);
     GrabedObject          = null;
     this_grabedObjectType = GrabedObjectType.None;
     Hand_animator.SetBool("Catch", false);
 }
Exemplo n.º 4
0
 /// <summary>
 /// 1. set the catch animation
 /// 2. if the other hand is in the catch anmation, release its catch animation
 /// </summary>
 /// <param name="value"></param>
 public void KeepCatchAnimation(bool value)
 {
     if (GrabedObject != null)
     {
         GrabedObject          = null;
         this_grabedObjectType = GrabedObjectType.None;
     }
     Hand_animator.SetBool("Catch", value);
 }
Exemplo n.º 5
0
 //To see if the object can be grabbed and make abimator play catch animation
 private void IsCanCatch(bool iscatch)
 {
     if (iscatch == false)
     {
         if (GrabedObject != null && this_grabedObjectType == GrabedObjectType.Bomb)
         {
             //代表拿的是炸弹
             ThrowBomb();
         }
     }
     if (iscatch)//release the grabed object
     {
         if (GrabedObject != null)
         {
             if (this_grabedObjectType == GrabedObjectType.Other)
             {
                 GrabedObject.transform.parent = null;
                 GrabedObject          = null;
                 this_grabedObjectType = GrabedObjectType.None;
             }
             else if (this_grabedObjectType == GrabedObjectType.Book)
             {//if the grabbed the object is book, make it return to its original position or the bookstand
                 if (GrabedObject.GetComponent <Book>().isTriggered)
                 {
                     GrabedObject.GetComponent <Book>().putbookOnBookStand();
                 }
                 else
                 {
                     GrabedObject.transform.parent   = null;
                     GrabedObject.transform.position = GrabedObject.GetComponent <Book>().original_position;
                     GrabedObject.transform.rotation = GrabedObject.GetComponent <Book>().original_rotation;
                 }
                 GrabedObject          = null;
                 this_grabedObjectType = GrabedObjectType.None;
             }
             else if (this_grabedObjectType == GrabedObjectType.Belt || this_grabedObjectType == GrabedObjectType.Magazine)
             {
                 GrabedObject.transform.parent = null;
                 GrabedObject.GetComponent <Rigidbody>().useGravity  = true;
                 GrabedObject.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.None;
                 GrabedObject          = null;
                 this_grabedObjectType = GrabedObjectType.None;
             }
             return;
         }
     }
     if (GrabedObject == null)
     {
         Hand_animator.SetBool("Catch", iscatch);
     }
     isGripButtonPressed = iscatch;
     PistolSwitchHand();
 }
Exemplo n.º 6
0
 private void OnTriggerStay(Collider other)//Collide the object that can be grabed and stay in that collider
 {
     if (other.tag == "Others" || other.tag == "Book" || other.tag == "Pistol" || other.tag == "Belt" || other.tag == "Magazine")
     {
         isHandeCollideST = true;
     }
     //make the other pbject highlighted
     if (other.GetComponent <Highlighter>() != null)
     {
         other.GetComponent <Highlighter>().On(Color.green);
     }
     if (other.tag == "Others" && isGripButtonPressed && GrabedObject == null)
     {
         ProcessGrab(other);
         this_grabedObjectType = GrabedObjectType.Other;
     }
     else if (other.tag == "Book" && isGripButtonPressed && GrabedObject == null)
     {
         ProcessGrab(other);
         this_grabedObjectType = GrabedObjectType.Book;
     }
     else if (other.tag == "Pistol" && isGripButtonPressed && GrabedObject == null)
     {
         Destroy(other.gameObject);
         UsePistol();
     }
     else if (other.tag == "Belt" && isGripButtonPressed && GrabedObject == null)
     {
         ProcessGrab(other);
         other.GetComponent <Rigidbody>().useGravity  = false;
         other.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeAll;
         this_grabedObjectType = GrabedObjectType.Belt;
     }
     else if (other.tag == "Magazine" && isGripButtonPressed && GrabedObject == null)
     {
         ProcessGrab(other);
         other.GetComponent <Rigidbody>().useGravity  = false;
         other.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeAll;
         this_grabedObjectType = GrabedObjectType.Magazine;
     }
 }
Exemplo n.º 7
0
    private void ThrowBomb()
    {
        //更新炸弹数量
        AmmoUI.Instance.UpdateBombNumber();

        GrabedObject.transform.parent = null;
        GrabedObject.AddComponent <Rigidbody>();
        Hand_animator.SetBool("Catch", false);
        this_grabedObjectType = GrabedObjectType.None;

        Vector3 velocity        = controllerEvents.GetVelocity();
        Vector3 angularVelocity = controllerEvents.GetAngularVelocity();

        GrabedObject.GetComponent <Rigidbody>().velocity        = transform.parent.parent.TransformDirection(velocity) * m_ThrowMulitiple;
        GrabedObject.GetComponent <Rigidbody>().angularVelocity = transform.parent.parent.TransformDirection(angularVelocity);
        GrabedObject.GetComponent <Bomb>().IsThrow = true;
        GrabedObject = null;
        m_IsUseBomb  = false;

        //UsePistol();
    }
Exemplo n.º 8
0
    private void UseBomb()
    {
        if (AmmoUI.Instance.isHasBomb() == false)
        {
            return;
        }
        if (GrabedObject != null)
        {
            if (this_grabedObjectType == GrabedObjectType.Pistol)
            {
                UnLoadPistol();
            }
            else if (this_grabedObjectType == GrabedObjectType.Belt || this_grabedObjectType == GrabedObjectType.Magazine)
            {
                GrabedObject.transform.parent = null;
                GrabedObject.GetComponent <Rigidbody>().useGravity  = true;
                GrabedObject.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.None;
                GrabedObject          = null;
                this_grabedObjectType = GrabedObjectType.None;
            }
            else if (this_grabedObjectType == GrabedObjectType.Bomb)
            {
                return;
            }
        }
        Transform  target = transform.parent.Find("BombTarget");
        GameObject bomb   = Instantiate(go_Bomb, transform.parent);

        bomb.transform.localPosition = target.localPosition;
        bomb.transform.localRotation = target.localRotation;
        bomb.transform.localScale    = target.localScale;

        GrabedObject          = bomb;
        this_grabedObjectType = GrabedObjectType.Bomb;
        Hand_animator.SetBool("Catch", true);
        m_IsUseBomb = true;
    }