Exemplo n.º 1
0
    private void OnEntityDeath(DeathResult result)
    {
        FightingEntity deadFighter = result.deadEntity.fighter;

        GameManager.Instance.time.GetController().StartCoroutine(deadFighter.Die());

        bool isEnemy = deadFighter.isEnemy();

        if (isEnemy)
        {
            GameManager.Instance.gameState.enemyParty.SetFighter(deadFighter.targetId, null);

            bool          stillHasEnemies = false;
            EnemyObject[] enemies         = GameManager.Instance.battleComponents.field.GetEnemyObjects();
            for (int i = 0; i < enemies.Length; i++)
            {
                if (enemies[i] != null)
                {
                    stillHasEnemies = true;
                    break;
                }
            }

            if (!stillHasEnemies)
            {
                OnWaveComplete();
            }
        }
        else
        {
            if (deadFighter.targetId == 0)
            {
                OnHeroDeath(result);
            }
            else
            {
                GameManager.Instance.gameState.playerParty.EvictPlayer(deadFighter.targetId, true);
            }
        }

        GameManager.Instance.battleComponents.ui.statusBarsUI.UpdateStatusBars();

        // Note: How we determine this part may change depending on how we do Mook deaths:
        List <PlayerObject> allPlayers = GameManager.Instance.battleComponents.field.GetActivePlayerObjects();

        if (allPlayers.Count == 1 && GameManager.Instance.battleComponents.field.GetHeroPlayer().HasModifier(ModifierAilment.MODIFIER_DEATH))
        {
            GameManager.Instance.battleComponents.stageController.LoadDeathScene();
        }
    }