コード例 #1
0
 void OnDestroy()
 {
     dead = true;
     if (onDeath != null)
     {
         onDeath.Invoke(gameObject);
     }
     if (gameEventChannel != null)
     {
         gameEventChannel.Raise(GameRecord.BotDied(gameObject, null));
     }
 }
コード例 #2
0
 void OnTakeDamage(GameObject from, int amount)
 {
     onChange.Invoke(health);
     onChangePercent.Invoke(healthPercent);
     if (healthPercent <= 0 && !dead)
     {
         onDeath.Invoke(gameObject);
         dead = true;
         if (gameEventChannel != null)
         {
             gameEventChannel.Raise(GameRecord.BotDied(gameObject, from));
         }
     }
     // notify channel
     if (gameEventChannel != null)
     {
         gameEventChannel.Raise(GameRecord.BotTookDamage(gameObject, from, amount));
     }
 }