예제 #1
0
    private void SendEventPlayerHit(float amount)
    {
        PlayerHitEventArgs playerHitEventArgs = new PlayerHitEventArgs();

        playerHitEventArgs.damage_amount = amount;
        if (OnPlayerHit != null)
        {
            OnPlayerHit(this, playerHitEventArgs);
        }
    }
예제 #2
0
 //handling the event of being hit. If health>0 (i.e. alive) lowers health. If it caused death, calls "Death()"
 private void EventHandler_OnPlayerHit(object sender, PlayerHitEventArgs e)
 {
     if (health > 0)
     {
         health -= e.damage_amount;
         UpdateTextHealth();
         if (health <= 0 && ALIVE)
         {
             ALIVE = false;
             Death();
         }
     }
     //Do more Stuff
 }
예제 #3
0
    public virtual void Damage(float damage, int damagerId)
    {
        if (!alive)
        {
            return;
        }

        float damageToShip = 0;
        damageToShip = DamageShield(damage);
        damageToShip = DamageArmor(damageToShip);
        currentHealth -= damageToShip;
        if (currentHealth <= 0)
        {
            alive = false;
            KillShip(damagerId);
        }

        PlayerHitEventArgs args = new PlayerHitEventArgs { playerId = 1, damageDelt = damageToShip };
        GameEventSystem.PublishEvent(typeof(PlayerDamagedSubscriber), args);
        if (damageToShip > 0)
            InfoBlurbManager.CreateInfoBlurb(this.transform.position, "" + damageToShip.ToString("0.0"), Color.red);
    }