void OnTriggerEnter2D(Collider2D other) { Seed seed = other.GetComponent <Seed>(); Spore spore = other.GetComponent <Spore>(); if (null != seed && seed.IsCaptured) { return; } if ((IsFertil || GameManager.Instance.IsNewFlowerReplaceOldOne) && null != seed) { seed.IsCaptured = true; int previousLevel = 0; if (GameManager.Instance.IsNewFlowerReplaceOldOne) { if (null != PlantedFlower) { FlowerRoot flower = PlantedFlower.GetComponent <FlowerRoot>(); FlowerRoot seedFlower = seed.Flower.GetComponent <FlowerRoot>(); if (flower.Level == seedFlower.Level && flower.GrowthLevel < 3) { previousLevel = flower.GrowthLevel; PlantedFlower.GetComponent <FlowerRoot>().Kill(); CreateTheFlower(seed, previousLevel + 1, this.transform); } } else { CreateTheFlower(seed, 1, this.transform); } seed.StopFade(); ScaleObject scale = seed.gameObject.AddComponent <ScaleObject>(); scale.GetComponent <Rigidbody2D>().isKinematic = true; scale.Scale(0.2f, Vector3.zero, true, Center.position, AbsorbIsFinish); } } if (null != spore) { if ((Time.time - spore.BirthTime) > 1f) { spore.Kill(); } } }
void OnCollisionEnter2D(Collision2D coll) { Seed seed = coll.gameObject.GetComponent <Seed>(); if (null != seed) { coll.gameObject.GetComponent <Rigidbody2D>().AddForce(Vector2.up * 2f); GameObject.Destroy(coll.gameObject, 0.4f); } Spore spore = coll.gameObject.GetComponent <Spore>(); if (null != spore && spore.IsFlying) { spore.Kill(); } }
void OnCollisionEnter2D(Collision2D coll) { Seed seed = coll.gameObject.GetComponent <Seed>(); if (null != seed) { coll.gameObject.GetComponent <Rigidbody2D>().AddForce(Vector2.up * 0.1f); seed.Kill(); } Spore spore = coll.gameObject.GetComponent <Spore>(); if (null != spore && spore.IsFlying) { if ((Time.time - spore.BirthTime) > 1f) { spore.Kill(); } } }
public void CreateSeed(Spore s1, Spore s2) { if (s1.Level == s2.Level && s1.Flower != s2.Flower && !s1.HasCollided && !s2.HasCollided) { s1.HasCollided = true; s2.HasCollided = true; int newLevel = s1.Level + 1; if (newLevel < Flowers.Length) { GameObject go = GameObject.Instantiate(Seeds[newLevel]); go.transform.position = s1.transform.position; var component = GameObject.FindGameObjectWithTag("SFXPlayerPollen").GetComponent <FX>(); component.PlaySound(); } s1.Kill(); s2.Kill(); /*foreach (var seedSpawn in s1.Flower.SeedSpawns) * { * foreach (Transform child in seedSpawn.transform) * { * * GameObject.Destroy(child.gameObject); * } * } * foreach (var seedSpawn in s2.Flower.SeedSpawns) * { * foreach (Transform child in seedSpawn.transform) * { * * GameObject.Destroy(child.gameObject); * } * }*/ } else { Physics2D.IgnoreCollision(s1.GetComponent <Collider2D>(), s2.GetComponent <Collider2D>()); } }
public void CreateSeed(Spore s1, Spore s2) { if (s1.Level == s2.Level && s1.Flower != s2.Flower && !s1.HasCollided && !s2.HasCollided) { //print("Level created = " + s1.Level); if (s1.Level == 0 && TutoSecondStep) { TutoSecondStep = false; var findGameObjectsWithTag = GameObject.FindGameObjectsWithTag("TutoTwo"); foreach (var o in findGameObjectsWithTag) { Image image = o.GetComponent <Image>(); if (image == null) { Destroy(o); } else { image.gameObject.SendMessage(FadeTutorial.DESACTIVATE_TUTORIAL); } } } s1.HasCollided = true; s2.HasCollided = true; int newLevel = s1.Level + 1; if (newLevel < Flowers.Length) { GameObject go = GameObject.Instantiate(Seeds[newLevel]); go.transform.position = s1.transform.position; var direction = go.transform.position - PlanetObject.position; direction.Normalize(); go.GetComponent <Rigidbody2D>().velocity = direction * 2f; go.GetComponent <Seed>().firstParent = s1.FlowerHead; go.GetComponent <Seed>().secondParent = s2.FlowerHead; go.GetComponent <Seed>().AnimatCircle(); var component = GameObject.FindGameObjectWithTag("SFXPlayerPollen").GetComponent <FX>(); component.PlaySound(); } s1.Kill(); s2.Kill(); /*foreach (var seedSpawn in s1.Flower.SeedSpawns) * { * foreach (Transform child in seedSpawn.transform) * { * * GameObject.Destroy(child.gameObject); * } * } * foreach (var seedSpawn in s2.Flower.SeedSpawns) * { * foreach (Transform child in seedSpawn.transform) * { * * GameObject.Destroy(child.gameObject); * } * }*/ } else { Physics2D.IgnoreCollision(s1.GetComponent <Collider2D>(), s2.GetComponent <Collider2D>()); } }