Example #1
0
 // Use this for initialization
 void Start()
 {
     stuck          = false;
     m_Rigidbody    = GetComponent <Rigidbody>();
     anotherScript  = GetComponent <VRTK.Examples.Sword>();
     leftMugsScript = leftParent.GetComponent <leftMugs>();
     coffeeCounters = leftMugsScript.coffeeCounters;
     counter        = 0;
 }
Example #2
0
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.collider.tag == "Sword" && canBeHit)
     {
         VRTK.Examples.Sword sword = collision.gameObject.GetComponent <VRTK.Examples.Sword>();
         float toHit = UnityEngine.Random.Range(1, 20) + MeleeModifer;
         if (toHit >= AC)
         {
             anim.SetTrigger("GotHit");
             int damage = UnityEngine.Random.Range(1, 10);
             if (sword.glowing)
             {
                 Debug.Log("Extra Damage!");
                 damage += UnityEngine.Random.Range(1, 4);
             }
             float hapticStrength = damage / 10f;
             sword.Rumble(hapticStrength);
             HP = HP - damage;
         }
         else
         {
             int action = UnityEngine.Random.Range(0, 2);
             if (action != 2)
             {
                 anim.SetInteger("Action", action);
                 anim.SetTrigger("Dodging");
             }
         }
         canBeHit = false;
     }
     if (collision.collider.tag == "Bow" && canBeHit)
     {
         float toHit = UnityEngine.Random.Range(1, 20) + RangedModifer;
         if (toHit >= AC)
         {
             anim.SetTrigger("GotHit");
             int damage = UnityEngine.Random.Range(1, 10);
             HP = HP - damage;
         }
         else
         {
             int action = UnityEngine.Random.Range(0, 2);
             if (action != 2)
             {
                 anim.SetInteger("Action", action);
                 anim.SetTrigger("Dodging");
             }
         }
         canBeHit = false;
     }
 }