示例#1
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag == "PlayerSword")
     {
         PlayerSwordControl sword = other.GetComponent <PlayerSwordControl>();
         health    -= sword.FinalDamage();
         fireTime   = sword.fireDuration;
         fireDamage = sword.fireDamage;
         Transform opponent           = other.transform.parent.parent;
         Vector3   knockbackDirection = opponent.position - transform.position;
         knockbackDirection.Normalize();
         GetComponent <Rigidbody>().AddForce(knockbackDirection);
         if (sword.IsShock())
         {
             stunDuration = sword.shockDuration;
         }
     }
     else if (other.tag == "EnemySword")
     {
         EnemySwordControl sword = other.GetComponent <EnemySwordControl>();
         health -= sword.FinalDamage();
         Transform opponent           = other.transform.parent.parent;
         Vector3   knockbackDirection = opponent.position - transform.position;
         knockbackDirection.Normalize();
         GetComponent <Rigidbody>().AddForce(knockbackDirection);
     }
 }
示例#2
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag == "EnemySword")
     {
         EnemySwordControl sword = other.GetComponent <EnemySwordControl>();
         if (currentShield > 0)
         {
             currentShield -= sword.FinalDamage();
         }
         else
         {
             currentHealth -= sword.FinalDamage();
         }
         fireTime   = sword.fireDuration;
         fireDamage = sword.fireDamage;
         Transform opponent           = other.transform.parent.parent;
         Vector3   knockbackDirection = opponent.position - transform.position;
         knockbackDirection.Normalize();
         GetComponent <Rigidbody>().AddForce(knockbackDirection);
         sword.hitState = HitState.Hit;
     }
     //Add multiplayer?
 }