protected virtual void EnemyDeath() { PlayerExperience playerExperience = target.GetComponent <PlayerExperience>(); playerExperience.AddExp(xpGiveAmount); Destroy(gameObject); }
//go and activate /*IEnumerator WaitAndGather(Vector3 targetpos) * { * float timeToReach = (_playerMovement.CalculatePathLength(targetpos)) / (_playerNavMeshAgent.speed); * yield return new WaitForSeconds(timeToReach); * Collider[] hitColliders = Physics.OverlapSphere(_player.transform.position, 3f); * bool isNearObject = false; * foreach (var collider in hitColliders) * { * if (collider == resource.GetComponent<Collider>()) * { * isNearObject = true; * } * } * * if (_playerMovement.IsPathCompleted() & isNearObject) * { * Gather(); * } * }*/ private void Gather() { _animator.SetTrigger("chop"); _playerResources.AddResource(resourceID, toolEfficiency); resourceQuantity -= toolEfficiency; _playerExperience.AddExp(ExpID, Convert.ToUInt64(toolEfficiency)); var popup = Instantiate(resourcePopup, transform.position, Quaternion.identity); popup.GetComponent <ResourcePopup>().SetText(toolEfficiency); popup.GetComponent <ResourcePopup>().SetIcon(icon); if (resourceQuantity <= 0) { audioManager.Play(GenerateSoundName(true, 1)); resource.SetActive(false); depletedResource.SetActive(true); _playerNavMeshAgent.ResetPath(); StartRespawn(); } else { audioManager.Play(GenerateSoundName(false, 3)); } }
private void Gather() { if (!isDepleted) { int toolEff = _playerEq.toolEfficiency; _animator.SetTrigger("chop"); int gatherValue; int tmp = resourceQuantity - toolEff; if (tmp >= 0) { gatherValue = toolEff; } else { gatherValue = toolEff + tmp; } _playerResources.AddResource(resourceID, gatherValue); resourceQuantity -= gatherValue; _playerExperience.AddExp(ExpID, Convert.ToUInt64(gatherValue)); var popup = Instantiate(resourcePopup); popup.GetComponent <ResourcePopup>().SetText(gatherValue); popup.GetComponent <ResourcePopup>().SetIcon(icon); if (resourceQuantity <= 0) { audioManager.Play(GenerateSoundName(true, 1)); resource.SetActive(false); depletedResource.SetActive(true); meshCollider.isTrigger = true; StartRespawn(); isDepleted = true; } else { audioManager.Play(GenerateSoundName(false, 3)); } } }