public void Die() { DifficultyManager.instance.SetAvgLifeTime(Time.time - spawnTime); ParticleManager.instance.SpawnEnemyExplodeParticle(transform.position); AudioManager.instance.PlaySoundWithRandomPitch(deathSounds[Random.Range(0, deathSounds.Length)], 0.75f, 1.25f); DropExperience(); DropHealth(); SplineTracer tracer = GetComponent <SplineTracer>(); if (tracer != null) //is this enemy using a spline? { tracer.RemoveFromTrack(); //remove this enemy from the list in the splinetracer } if (poolBehaviour != null) //is this enemy pooled? { poolBehaviour.DisableInPool(); //disable this enemy if (!ignoreEnemyCount) //does this enemy count toward the wave's enemy count? { SpawnManager.instance.DecreaseEnemyCount(1); //decrease enemy count StatManager.instance.IncreaseKillCount(); //increase kill count } } StatManager.instance.IncreaseScore((int)scoreValue); }
// Update is called once per frame void Update() { if (speed > 0 && !GameManager.instance.GetPaused()) { float moveTime = (10 / (speed + boost)) * Vector3.Distance(track.GetPoint(t), track.GetPoint(t + Time.deltaTime)); if (moveTime == 0) { moveTime = 0.001f; //prevent divide by zero } Vector3 nextPosition; t += Time.deltaTime / moveTime; if (t >= 1) { if (loop) { t = 0; } else { PooledObjectBehaviour poolObj = GetComponent <PooledObjectBehaviour>(); if (poolObj != null) { poolObj.DisableInPool(); RemoveFromTrack(); } else { Destroy(this.gameObject); RemoveFromTrack(); } } } nextPosition = track.GetPoint(t + Time.deltaTime / moveTime); nextPosition += (transform.right * offset); Vector3 position = track.GetPoint(t); transform.position = position + (transform.right * offset); if (rotateWithSpline) { transform.LookAt(nextPosition, transform.up); } } }
// Update is called once per frame void Update() { timer -= Time.deltaTime; if (timer <= 0) { if (!overrideDisableFunction) { if (pooledBehaviour != null) { pooledBehaviour.DisableInPool(); Reset(); } else { Destroy(gameObject); } } else if (altDestroyFunction != null) { altDestroyFunction.Invoke(); } } }