コード例 #1
0
ファイル: EnemyLogic.cs プロジェクト: IndieRonin/Dark-Cave
        public void TakeDamage(int damage)
        {
            EnemyDamageEvent enemyDamageEventInfo = new EnemyDamageEvent();

            enemyDamageEventInfo.Description = "Actor " + gameObject.name + " has taken damage.";
            enemyDamageEventInfo.enemy_go    = gameObject;
            enemyDamageEventInfo.FireEvent();

            //Do take damage animation
            stats.health -= damage;

            if (stats.health <= 0)
            {
                EnemyDie();
            }
        }
コード例 #2
0
 void OnEnemyDamaged(EnemyDamageEvent enemyDamage)
 {
     Debug.Log("I hear " + enemyDamage.enemy_go.name + " has taken damage - Report from the DamageListener");
 }
コード例 #3
0
 // Use this for initialization
 void Start()
 {
     PlayerDamageEvent.RegisterListener(OnPlayerDamaged);
     EnemyDamageEvent.RegisterListener(OnEnemyDamaged);
     TileDamageEvent.RegisterListener(OnTileDamaged);
 }
コード例 #4
0
 void OnDestroy()
 {
     PlayerDamageEvent.UnregisterListener(OnPlayerDamaged);
     EnemyDamageEvent.UnregisterListener(OnEnemyDamaged);
     TileDamageEvent.UnregisterListener(OnTileDamaged);
 }