void Update() { if (fireTimer > 0) { if (!infinite) { fireTimer -= Time.deltaTime; } if (fireTimer <= 0) { StopBurning(); } fireSpreadTimer += Time.deltaTime; if (fireSpreadTimer > spreadInterval) { print("Spread fire!"); fireSpreadTimer = 0f; Collider[] nearbyColliders = Physics.OverlapSphere(transform.position, fireSpreadRadius); foreach (Collider colliderToMakeBurn in nearbyColliders) { Flammable flammable = colliderToMakeBurn.GetComponent <Flammable>(); if (flammable != null && flammable.gameObject != gameObject && !flammable.IsBurning()) { flammable.StartBurning(); } } } } }
virtual public void TakeDamage(DamageParams args) { if (health > 0) { if (!squash.inSquash && iFramesTimer <= 0) { if (args.amount > 0) { SetHealth(health - args.amount); if (args.damageType == DamageType.Squash) { squash.DoSquash(health > 0); } else if (args.damageType == DamageType.Hit) { iFramesTimer = iFramesDuration; knockbackVector = knockbackMultiplier * args.knockback; StartCoroutine(Flasher()); } ExtraTakeDamage(args); } CameraEffects.Get.FreezeFrames(0.15f, 0.01f); switch (args.element) { case Element.None: break; case Element.Fire: if (flammable) { flammable.StartBurning(); if (!audioSource.isPlaying) { audioSource.PlayOneShot(burn, 0.5f); } } break; case Element.Ice: if (freezable) { freezable.FreezeStart(); if (!audioSource.isPlaying) { audioSource.PlayOneShot(slow, 1f); } } break; case Element.Poison: poisonStatus = poisonStatusDuration; if (poisonStatus > 0) { poisonEffectIndex = ParticleEffectsManager.GetEffect("Poison").Spawn(GetComponent <MeshRenderer>()); if (!audioSource.isPlaying) { audioSource.PlayOneShot(poisoned, 1f); } } break; case Element.Lightning: if (electracuted) { electracuted.ElcStart(); if (!audioSource.isPlaying) { audioSource.PlayOneShot(paralysis, 0.10f); } } break; } if (health <= 0) { Die(); if (Random.Range(1, 5) == 1) { Instantiate(powerUps[Random.Range(0, powerUps.Count - 1)], transform.position, Quaternion.identity); } } } } }