private void SetHealthUI(float amount) { Debug.Log(amount); fillSlider.transform.localPosition -= new Vector3((amount * 0.66f) / StartingHealth, 0, 0); fillSlider.transform.localScale -= new Vector3((amount * 1) / StartingHealth, 0, 0); UnityNightPool.PoolObject poolTextHealthZombie = UnityNightPool.PoolManager.Get(idTextHealthZombie); poolTextHealthZombie.transform.position = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y - 0.5f, gameObject.transform.position.z); if (ColorR < 255 - (255 * amount) / StartingHealth) { ColorR += (255 * amount) / StartingHealth; } if (ColorR > 0 + (255 * amount) / StartingHealth) { ColorG -= (255 * amount) / StartingHealth; } Debug.Log(ColorR + " COLOR_R " + ColorG + " COLOR_G"); fillSliderColor.color = new Color32((byte)ColorR, (byte)ColorG, 0, 255); foreach (Transform child in poolTextHealthZombie.transform) { child.GetComponent <TextMesh>().text = "-" + amount.ToString(); } }
private void Start() { poolObject = GetComponent <UnityNightPool.PoolObject>(); //Start the remove/destroy coroutine StartCoroutine(RemoveCasing()); //Set random rotation at start transform.rotation = Random.rotation; //Start play sound coroutine StartCoroutine(PlaySound()); }
protected virtual void Shot() { CurrentAmmo--; shootAudioSource.clip = soundClips.shootSound; shootAudioSource.Play(); anim.Play(FIRE, 0, 0f); if (!randomMuzzleflash && enableMuzzleflash == true) { muzzleParticles.Emit(1); StartCoroutine(MuzzleFlashLight()); } else if (randomMuzzleflash) { if (randomMuzzleflashValue == 1) { if (enableSparks == true) { sparkParticles.Emit(Random.Range(minSparkEmission, maxSparkEmission)); } if (enableMuzzleflash == true) { muzzleParticles.Emit(1); StartCoroutine(MuzzleFlashLight()); } } } UnityNightPool.PoolObject poolBullet = UnityNightPool.PoolManager.Get(idPoolBullet); poolBullet.transform.position = spawnPoints.bulletSpawnPoint.transform.position; poolBullet.transform.rotation = spawnPoints.bulletSpawnPoint.transform.rotation; poolBullet.GetComponent <Rigidbody>().velocity = poolBullet.transform.forward * bulletForce; UnityNightPool.PoolObject poolCaseBullet = UnityNightPool.PoolManager.Get(idPoolCase); poolCaseBullet.transform.position = spawnPoints.casingSpawnPoint.transform.position; poolCaseBullet.transform.rotation = spawnPoints.casingSpawnPoint.transform.rotation; if (CurrentAmmo <= 0) { outOfAmmo = true; if (!isReloading) { StartCoroutine(AutoReload()); } } }
private void Start() { poolObject = GetComponent <UnityNightPool.PoolObject>(); }