private void OnDisable() { foreach (var obj in FindObjectsOfType <GameObject>()) { if (obj.tag == TagStatics.GetPickupTag()) { obj.GetComponent <SphereHandler>().OnPickupCollectedEvent -= UpdatePickupList; } } }
private void Awake() { _pickupList = new List <GameObject>(); _pickupPosList = new List <Vector3>(); _pickupBoolList = new List <bool>(); NumPickupsCollected = 0; NumPickupsLost = 0; LastCollectedPos = new Vector3(0.0f, 0.0f, 0.0f); LastPickupBool = false; var end = GameDataSerializer._gameDataList.Count - 1; var gmData = GameDataSerializer.LoadGameData(end); if (gmData.playerScore > 0) { PlayerScore = gmData.playerScore; } else { PlayerScore = 0; } foreach (var obj in FindObjectsOfType <GameObject>()) { if (obj.tag == TagStatics.GetPickupTag()) { _pickupPosList.Add(obj.transform.position); _pickupList.Add(obj); obj.GetComponent <SphereHandler>().OnPickupCollectedEvent += UpdatePickupList; } } NumPickupsInLevel = _pickupList.Count; if (_pickupList.Count <= 0) { Debug.LogWarning("PickupManager didn't find any valid pickups within the current level"); Debug.LogWarning("Did you forget to tag any Pickup prefab instances in the scene as Pickup?"); } Debug.Log("Pickup list contains " + _pickupList.Count + " pickups"); }
private void OnTriggerEnter(Collider other) { // We detect a pickup in our radius if (other.gameObject.tag == TagStatics.GetPickupTag()) { if (InLineOfSight(other.gameObject)) { OnTargetClearLOS?.Invoke(other.gameObject); OnTargetInRadius?.Invoke(other.gameObject); _isTrackingTarget = true; } else { OnTargetInRadius?.Invoke(other.gameObject); _isTrackingTarget = false; } } if (other.gameObject.tag == TagStatics.GetMobTag() && other.gameObject.name == TagStatics.GetPlayerName()) { //The mob is within our LoS if (InLineOfSight(other.gameObject)) { OnTargetClearLOS?.Invoke(other.gameObject); OnTargetInRadius?.Invoke(other.gameObject); _isTrackingTarget = true; } else { OnTargetInRadius?.Invoke(other.gameObject); _isTrackingTarget = false; return; } currentTarget = other.gameObject; } //We heard a noise if (other.gameObject.tag == "Audible") { OnHeardSound?.Invoke(other.gameObject); } }