public void Plow() { if (this.m_Plant != null) { UnityEngine.Object.Destroy(this.m_Plant); this.m_Plant = null; } if (this.m_GrownPlant != null) { DestroyableObject component = this.m_GrownPlant.GetComponent <DestroyableObject>(); if (component) { component.DestroyMe(null, ""); } else { UnityEngine.Object.Destroy(this.m_GrownPlant); } this.m_GrownPlant = null; } if (this.m_ObjectWithTrunk != null) { UnityEngine.Object.Destroy(this.m_ObjectWithTrunk.gameObject); this.m_ObjectWithTrunk = null; } this.SetState(AcreState.Ready); this.m_WaterAmount = 0f; this.m_FertilizerAmount = 0f; this.m_AudioSource.PlayOneShot(Acre.s_PlowAudioClip); PlayerConditionModule.Get().GetDirtinessAdd(GetDirtyReason.Plow, null); }
private void HandleObjectDestroyed(string[] msg) { Scene currentScene = SceneManager.GetActiveScene(); if (currentScene.name == "ClientScene") { return; } string name = msg[1]; GameObject destroyableObject = GameObject.Find(name); if (!destroyableObject) { Debug.Log("Destroyable " + name + " does not exists"); return; } DestroyableObject destroyableController = destroyableObject.GetComponent <DestroyableObject>(); if (!destroyableController) { Debug.Log(name + " is not destroyable"); return; } destroyableController.DestroyMe(false); }
protected void DestroyObject(GameObject other) { DestroyableObject destroyable = other.GetComponent <DestroyableObject>(); if (destroyable.reinforced && !enhanced) { return; } destroyable.DestroyMe(true); }
private void HandleObjectDestroyed(string[] msg) { if (NotInClientScene()) { string name = msg[1]; GameObject destroyableObject = GameObject.Find(name); if (!destroyableObject) { Debug.Log("Destroyable " + name + " does not exists"); return; } else { if (destroyableObject.GetComponent <DestroyableObject>()) { DestroyableObject destroyableController = destroyableObject.GetComponent <DestroyableObject>(); destroyableController.DestroyMe(false); return; } else if (destroyableObject.GetComponent <PickUpExp>()) { PickUpExp pExp = destroyableObject.GetComponent <PickUpExp>(); pExp.DestroyMe(); return; } else if (destroyableObject.GetComponent <PickUpItem>()) { PickUpItem pItem = destroyableObject.GetComponent <PickUpItem>(); pItem.DestroyMe(); return; } else { Debug.Log(name + " is neither Destroyable, Exp or Item"); } } } }
protected virtual void OnTriggerEnter2D(Collider2D other) { if (other.GetComponent <DamagingObject>()) { if (!levelManager.GetMage().ProtectedByShield(gameObject)) { for (int i = 0; i < playerControllers.Length; i++) { if (playerControllers[i] != null) { PlayerController playerToRelease = playerControllers[i]; playerControllers[i] = null; playerToRelease.ResetTransform(); playerToRelease.TakeDamage(10, new Vector2(150f, 15f)); playerToRelease.parent = null; } } Destroy(parasiteParticle.gameObject); Destroy(gameObject); } } if (other.GetComponent <DestroyableObject>()) { if (levelManager.GetWarrior().IsWarriored(gameObject)) { DestroyableObject destroyable = other.GetComponent <DestroyableObject>(); destroyable.DestroyMe(true); } else { for (int i = 0; i < playerControllers.Length; i++) { if (playerControllers[i] != null) { PlayerController playerToRelease = playerControllers[i]; playerControllers[i] = null; playerToRelease.ResetTransform(); playerToRelease.TakeDamage(10, new Vector2(150f, 15f)); playerToRelease.parent = null; } } Destroy(parasiteParticle.gameObject); Destroy(gameObject); } } if (other.GetComponent <BurnableObject>()) { if (levelManager.GetWarrior().IsWarriored(gameObject)) { BurnableObject burnable = other.GetComponent <BurnableObject>(); burnable.Burn(); } else { for (int i = 0; i < playerControllers.Length; i++) { if (playerControllers[i] != null) { PlayerController playerToRelease = playerControllers[i]; playerControllers[i] = null; playerToRelease.ResetTransform(); playerToRelease.TakeDamage(10, new Vector2(150f, 15f)); playerToRelease.parent = null; } } Destroy(parasiteParticle.gameObject); Destroy(gameObject); } } if (other.GetComponent <KillingObject>() && other.GetComponent <KillingObject>().activated) { if (!other.GetComponent <DarkElectricity>()) { if (levelManager.GetMage().ProtectedByShield(gameObject)) { for (int i = 0; i < playerControllers.Length; i++) { if (playerControllers[i] != null) { PlayerController playerSaved = playerControllers[i]; Physics2D.IgnoreCollision(playerSaved.GetComponent <BoxCollider2D>(), other.GetComponent <Collider2D>(), true); } } } else if (!levelManager.GetMage().ProtectedByShield(gameObject)) { for (int i = 0; i < playerControllers.Length; i++) { if (playerControllers[i] != null) { PlayerController playerToRelease = playerControllers[i]; playerControllers[i] = null; playerToRelease.ResetTransform(); playerToRelease.parent = null; } } Destroy(parasiteParticle.gameObject); Destroy(gameObject); } } else if (other.GetComponent <DarkElectricity>()) { if (levelManager.GetEngineer().IsElectrified(gameObject)) { for (int i = 0; i < playerControllers.Length; i++) { if (playerControllers[i] != null) { PlayerController playerSaved = playerControllers[i]; Physics2D.IgnoreCollision(playerSaved.GetComponent <BoxCollider2D>(), other.GetComponent <Collider2D>(), true); } } } else { for (int i = 0; i < playerControllers.Length; i++) { if (playerControllers[i] != null) { PlayerController playerToRelease = playerControllers[i]; playerControllers[i] = null; playerToRelease.parent = null; playerToRelease.ResetTransform(); } } Destroy(parasiteParticle.gameObject); Destroy(gameObject); } } } }
protected override void OnCollisionEnter2D(Collision2D other) { if (GameObjectIsPlayer(other.gameObject)) { DealDamage(other.gameObject); DestroyMeAndParticles(); } if (GameObjectIsEnemy(other.gameObject)) { if (CheckIfImWarriored(gameObject)) { KillEnemy(other.gameObject); DestroyMeAndParticles(); } if (CheckIfImMaged()) { GetThisEnemyMaged(other.gameObject); DestroyMeAndParticles(); } DestroyMeAndParticles(); } if (GameObjectIsDestroyable(other.gameObject)) { if (CheckIfImWarriored(gameObject)) { DestroyableObject destroyable = other.gameObject.GetComponent <DestroyableObject>(); destroyable.DestroyMe(true); DestroyMeAndParticles(); } DestroyMeAndParticles(); } if (GameObjectIsDeactivableKillPlane(other.gameObject)) { if (CheckIfImWarriored(gameObject)) { KillingObject kObject = other.gameObject.GetComponent <KillingObject>(); kObject.HitByPoweredDamaging(); DestroyMeAndParticles(); } if (CheckIfImMaged()) { KillingObject kObject = other.gameObject.GetComponent <KillingObject>(); kObject.HitByPoweredDamaging(); DestroyMeAndParticles(); } } if (GameObjectIsBurnable(other.gameObject)) { if (CheckIfImWarriored(gameObject)) { BurnableObject bObject = other.gameObject.GetComponent <BurnableObject>(); bObject.Burn(); DestroyMeAndParticles(); } DestroyMeAndParticles(); } }