private IEnumerator checkIfPlayerHasAbility() { // Wait for a couple frames. yield return(null); yield return(null); GameObject pl = GameObject.FindGameObjectWithTag("Player"); if (pl == null) { Debug.LogError("AbilityTrigger " + gameObject.name + " can't find the Player GameObject (no GameObject found with the tag 'Player'."); } else { PlayerAbilityManager am = pl.GetComponent <PlayerAbilityManager>(); if (am == null) { Debug.LogError("AbilityTrigger " + gameObject.name + " can't get 'PlayerAbilityManager' component on the Player GameObject."); } else { // set this to disabled if the player has this ability already if (am.getEnabledAbilities().Contains(abilityName)) { gameObject.SetActive(false); } } } }
// Returns a PlayerStats object containing the extra stats that the player has. // The regular ObjectStats should be in 'stats' already. private static PlayerStats SavePlayerStats(ObjectStats stats, GameObject player, string scene) { PlayerStats plStats = new PlayerStats(stats); PlayerAbilityManager abilityManager = player.GetComponent <PlayerAbilityManager>(); if (abilityManager != null) { plStats.enabledAbilities = abilityManager.getEnabledAbilities(); } PlayerHealth plHealth = player.GetComponent <PlayerHealth>(); if (plHealth != null) { plStats.health = plHealth.getHealth(); } plStats.sceneName = scene; return(plStats); }