private void LateUpdate() { if (PlayerController.GetKillsCount() <= 20) { if (!audioSource.isPlaying) { audioSource.clip = audioClips[0]; audioSource.Play(); } else if (audioSource.isPlaying && audioSource.clip != audioClips[0]) { audioSource.Stop(); } } if (PlayerController.GetKillsCount() > 20) { if (!audioSource.isPlaying) { audioSource.clip = audioClips[1]; audioSource.Play(); } else if (audioSource.isPlaying && audioSource.clip != audioClips[1]) { audioSource.Stop(); } } }
public void EnemySettings(IGolem _enemyData) { hp = golemData.HealthPoint * (1 + (float)PlayerController.GetKillsCount() / 100); speed = golemData.MoveSpeed * (1 + (float)PlayerController.GetKillsCount() / 100); col.enabled = true; UIHPbar.maxValue = hp; UIHPbar.value = UIHPbar.maxValue; audioSource.clip = spawnClips[Random.Range(0, spawnClips.Count - 1)]; audioSource.Play(); }
private void Update() { //UIHPbar.rectTransform.right = new Vector3(hp / fullhp, 0,0); //Debug.Log(animator.GetCurrentAnimatorStateInfo(0).length + " " + animator.GetCurrentAnimatorStateInfo(0).normalizedTime + " " + animator.GetCurrentAnimatorClipInfo(0).Length); if (hp <= 0) { if (!animator.GetCurrentAnimatorStateInfo(0).IsName("Death")) { animator.SetTrigger("Death"); } if (speed > 0) { speed -= .5f; } //transform.position = Vector3.forward / 100; col.enabled = false; } if (animator.GetCurrentAnimatorStateInfo(0).length < (animator.GetCurrentAnimatorStateInfo(0).normalizedTime * 3f) && animator.GetCurrentAnimatorStateInfo(0).IsName("Death")) { PlayerController.IncrementKills(); PlayerController.gold += 10 + PlayerController.GetKillsCount() / 10; gameObject.SetActive(false); startPosition = new Vector3(Random.Range(correctPointForStartPositionX.x, correctPointForStartPositionX.y), startPosition.y, startPosition.z); transform.position = startPosition; } if (Vector3.Distance(target.position, transform.position) < attackRange) { animator.SetBool("Attack", true); } //Debug.Log(Vector3.Distance(target.position, transform.position)); //Debug.Log(animator.GetCurrentAnimatorStateInfo(0).length + " " + animator.GetCurrentAnimatorStateInfo(0).normalizedTime); }