private void OnTriggerEnter(Collider other)
    {
        // handle any damage here!
        if (!entity.IsOwner)
        {
            return;
        }
        if (other.tag == Tags.ATTACK_TAG)
        {
            if (!other.transform.IsChildOf(transform) && !Hit)          // line to not hurt yourself. Also, do not run this code if you have already been hurt.
            {
                PlayerController.MajorDamage();
                var evnt = SuccessfulAttackEvent.Create();      // successfully attacked!
                evnt.WeaponDamage = other.transform.parent.parent.parent.GetComponent <WeaponAttack>().Damage;
                evnt.WeaponEntity = other.transform.parent.parent.parent.GetComponent <BoltEntity>();
                evnt.Send();
            }
        }
        else if (other.tag == Tags.PUSH_TAG)
        {
            if (!other.transform.IsChildOf(transform) && !Hit)          // line to not hurt yourself. Also, do not run this code if you have already been hurt.
            {
                Hit = true;
                Invoke("ResetHit", StunTime);
                PlayerController.MinorDamage();
            }
        }
        else if (other.tag == Tags.SHIELD_TAG)
        {
            //print("Got ITEM!!");
            var new_Item = ItemPickedUpEvent.Create();
            new_Item.PlayerEntity = GetComponent <BoltEntity>();
            new_Item.ItemEntity   = other.GetComponent <BoltEntity>();
            new_Item.Send();
            CurrentShield = MaxPlayerShield;
            if (AudioManager.Instance != null)
            {
                AudioManager.Instance.PlaySFX(ShieldGetSFX);
            }
            GameUI.UserInterface.InitializeShield(CurrentShield);
            // add callback here.
            // run shield here.
        }

        else if (other.tag == Tags.WEAPON_TAG && state.Weapon == null)               // pick up an item if you have no weapon or trap.
        {
            //print("Got ITEM!!");
            var new_Item = ItemPickedUpEvent.Create();
            new_Item.PlayerEntity = GetComponent <BoltEntity>();                                    // get the player who picked up the  entity.
            new_Item.ItemEntity   = other.GetComponent <BoltEntity>();                              // get Itembox for the host to destroy
            new_Item.ItemType     = c_Item_Types.Items[other.GetComponent <Hover>().TypeOfItem];    // get Item ID
            new_Item.Send();
        }
        else if (other.tag == Tags.DEATHZONE_TAG)
        {
            LoseGame();
        }
    }
Beispiel #2
0
 public override void OnEvent(SuccessfulAttackEvent evnt) // for sender, get the attack and call the damage function in health.cs. For weapon owner, subtract 1 from their uses.
 {
     if (evnt.FromSelf)                                   // caller
     {
         FindObjectOfType <Camera>().GetComponentInParent <Health>().DamagedByWeapon(evnt.WeaponDamage);
     }
     else if (evnt.WeaponEntity)                                                                             // THIS CAUSES AN ERROR.
     {
         if (evnt.WeaponEntity.IsOwner)
         {
             evnt.WeaponEntity.GetComponent <WeaponAttack>().UseAttacK();     // decrease 1 from their available weapon uses.
         }
     }
 }