void Start() { _rgb = gameObject.GetComponent <Rigidbody>(); _level = DungeonStates.instance._playerLevel; _currentLevelExp = DungeonStates.instance._playerCurrentLevelExp; _nextLevelExp = DungeonStates.instance._playerNextLevelExp; _enemyKill = new EnemyKillEvent(); _enemyKill.AddListener(enemyExp); _health = DungeonStates.instance._playerHealth; anim = GetComponent <Animator>(); _healthBar = GameObject.FindGameObjectWithTag("Canvas").GetComponent <hUDScript>()._healthBar; _dash1 = GameObject.FindGameObjectWithTag("Canvas").GetComponent <hUDScript>()._dash1; _dash2 = GameObject.FindGameObjectWithTag("Canvas").GetComponent <hUDScript>()._dash2; _dash3 = GameObject.FindGameObjectWithTag("Canvas").GetComponent <hUDScript>()._dash3; _lvlText = GameObject.FindGameObjectWithTag("Canvas").GetComponent <hUDScript>()._lvlText; _lvlText = GameObject.FindGameObjectWithTag("Canvas").GetComponent <hUDScript>()._lvlText; moneyText = GameObject.FindGameObjectWithTag("Canvas").GetComponent <hUDScript>()._money; healthPotsText = GameObject.FindGameObjectWithTag("Canvas").GetComponent <hUDScript>()._healthPots; healthPotsText.text = DungeonStates.instance._healthPots.ToString(); staminaPotsText = GameObject.FindGameObjectWithTag("Canvas").GetComponent <hUDScript>()._staminaPots; staminaPotsText.text = DungeonStates.instance._staminaPots.ToString(); _health = DungeonStates.instance.maxHealth; refreshHUD(); }
void OnEnemyKill(EnemyKillEvent e) { m_livingEnemy.Remove(e.enemy); if (m_livingEnemy.Count == 0) { Event <AllEnemyKilledEvent> .Broadcast(new AllEnemyKilledEvent()); } }
//注销敌人 public void UnregisterEnemy(EnemyController enemyKilled) { int enemiesRemainingNotification = NumberOfEnemiesRemaining - 1; EnemyKillEvent evt = Events.EnemyKillEvent; evt.Enemy = enemyKilled.gameObject; evt.RemainingEnemyCount = enemiesRemainingNotification; EventManager.Broadcast(evt); // removes the enemy from the list, so that we can keep track of how many are left on the map Enemies.Remove(enemyKilled); }
void OnEnemyKilled(EnemyKillEvent evt) { if (IsCompleted) { return; } m_KillTotal++; if (MustKillAllEnemies) { KillsToCompleteObjective = evt.RemainingEnemyCount + m_KillTotal; } int targetRemaining = MustKillAllEnemies ? evt.RemainingEnemyCount : KillsToCompleteObjective - m_KillTotal; // update the objective text according to how many enemies remain to kill if (targetRemaining == 0) { CompleteObjective(string.Empty, GetUpdatedCounterAmount(), "Objective complete : " + Title); } else if (targetRemaining == 1) { string notificationText = NotificationEnemiesRemainingThreshold >= targetRemaining ? "One enemy left" : string.Empty; UpdateObjective(string.Empty, GetUpdatedCounterAmount(), notificationText); } else { // create a notification text if needed, if it stays empty, the notification will not be created string notificationText = NotificationEnemiesRemainingThreshold >= targetRemaining ? targetRemaining + " enemies to kill left" : string.Empty; UpdateObjective(string.Empty, GetUpdatedCounterAmount(), notificationText); } }