void Update() { #region Shields RemoveShields(); if (shield == Shield.normal) { normalShield.SetActive(true); } if (shield == Shield.electric) { elecShield.SetActive(true); electric.Play(); } else { electric.Stop(); } if (shield == Shield.fire) { fireShield.SetActive(true); fire.Play(); } else { fire.Stop(); } if (shield == Shield.water) { waterShield.SetActive(true); } #endregion for (int e = 0; e < rings.Count; e++) { rings[e] = new RingPoolObj(rings[e].ring, rings[e].ringRb, rings[e].timeleft - Time.deltaTime, rings[e].Ring); if (rings[e].timeleft <= 0f) { rings[e].ring.transform.position = theVoid; } } if (playerCore.playerAnimationManager.playerAnimator.GetCurrentAnimatorStateInfo(0).IsName("DamageGround") || playerCore.playerAnimationManager.playerAnimator.GetCurrentAnimatorStateInfo(0).IsName("Getup")) { playerCore.inputCore.InputLockForFrame(); } }
void SpawnRing(Vector3 position, Vector3 velocity) { for (int w = 0; w < rings.Count; w++) { if (rings[w].timeleft <= 0f) { //Debug.Log("Recycled an object!"); rings[w].ring.transform.position = position; rings[w].ringRb.velocity = velocity; rings[w].Ring.StartMain(); rings[w] = new RingPoolObj(rings[w].ring, rings[w].ringRb, ringNormalTimeLeft, rings[w].Ring); return; } } //Debug.Log("Spawned a ring obj into the pool"); GameObject r = Instantiate(ringObject, position, Quaternion.identity, ringObjParent); rings.Add(new RingPoolObj(r, r.GetComponent <Rigidbody>(), ringNormalTimeLeft, r.GetComponent <Ring>())); rings[0].ring.transform.position = position; rings[0].ringRb.velocity = velocity; rings[0].Ring.StartMain(); }
void OnTriggerEnter(Collider other) { if (playerCore.playerHpManager.attacking) { if (other.CompareTag("WaterCapsule")) { shield = Shield.water; playerCore.rb.velocity = Vector3.up * capsuleExplosionForce; Destroy(other.gameObject); } if (other.CompareTag("FireCapsule")) { shield = Shield.fire; playerCore.rb.velocity = Vector3.up * capsuleExplosionForce; Destroy(other.gameObject); } if (other.CompareTag("ElectricCapsule")) { shield = Shield.electric; playerCore.rb.velocity = Vector3.up * capsuleExplosionForce; Destroy(other.gameObject); } if (other.CompareTag("CapsuleNormalShield")) { shield = Shield.normal; playerCore.rb.velocity = Vector3.up * capsuleExplosionForce; Destroy(other.gameObject); } if (other.CompareTag("CapsuleRings")) { CapsuleRing cr = other.gameObject.GetComponent <CapsuleRing>(); playerCore.playerHpManager.hp += cr.amount; playerCore.playerHpManager.UpdateRings(); playerCore.rb.velocity = Vector3.up * capsuleExplosionForce; Destroy(other.gameObject); } } if (canCollectRings == true) { if (other.CompareTag("Ring")) { //shouldn't destroy, instead set free in pool //Destroy(other.gameObject) int t = 0; for (int r = 0; r < rings.Count; r++) { if (rings[r].ring == other.gameObject) { t++; rings[r] = new RingPoolObj(rings[r].ring, rings[r].ringRb, 0f, rings[r].Ring); } } if (t == 0) { Destroy(other.gameObject); } hp += 1; UpdateRings(); SpawnRingShine(other.transform.position); SoundCore.nonSpacialSource.PlayOneShot(DefaultSounds.MainDefSounds.defaultSounds.ring, 0.075f); } if (other.CompareTag("Static Ring")) { Destroy(other.gameObject); hp += 1; SpawnRingShine(other.transform.position); UpdateRings(); SoundCore.nonSpacialSource.PlayOneShot(DefaultSounds.MainDefSounds.defaultSounds.ring, 0.075f); } } }