void OnTriggerEnter2D(Collider2D coll) { if (coll.gameObject.GetComponent <BarrierController>() && coll.gameObject.GetComponent <BarrierController>().isSpicky) { bubble.BrokenOut(); } else if (coll.gameObject.GetComponent <BarrierController>()) { Stop(); } else if (coll.gameObject.GetComponent <RubbishController>()) { RubbishController sampahController = coll.gameObject.GetComponent <RubbishController>(); if (bubble.CanLift(sampahController) && !bubble.thrownRubbishes.Contains(sampahController)) { bubble.LiftRubbish(sampahController); } else if (bubble.CanLiftWithThrowFirst(sampahController) && !bubble.thrownRubbishes.Contains(sampahController)) { bubble.ThrowFirstRubbish(); bubble.LiftRubbish(sampahController); } else { Stop(); Physics2D.IgnoreCollision(bubble.realCollider, coll); } } }
private Level CreateLevel() { Level level = new Level(); level.ScoreFor1Star = 0; level.ScoreFor2Star = 0; level.ScoreFor3Star = 0; for (int i = 0; i < ParentObject.Background.transform.childCount; i++) { if (ParentObject.Background.transform.GetChild(i).gameObject.activeInHierarchy) { level.Place = ParentObject.Background.transform.GetChild(i).gameObject.name; } } for (int i = 0; i < ParentObject.Rubbish.transform.childCount; i++) { RubbishController controller = ParentObject.Rubbish.transform.GetChild(i).gameObject.GetComponent <RubbishController>(); level.Rubbishes.Add(new Sampah(controller.PackageName, controller.Size, controller.transform.GetComponent <RectTransform>().localPosition, controller.Rotation, controller.RotationSpeed)); } for (int i = 0; i < ParentObject.Barrier.transform.childCount; i++) { BarrierController controller = ParentObject.Barrier.transform.GetChild(i).gameObject.GetComponent <BarrierController>(); level.Barriers.Add(new Penghalang(controller.PackageName, controller.Name, controller.transform.GetComponent <RectTransform>().localPosition, controller.Rotation, controller.RotationSpeed)); } for (int i = 0; i < ParentObject.Bubble.transform.childCount; i++) { ItemGelembungController controller = ParentObject.Bubble.transform.GetChild(i).gameObject.GetComponent <ItemGelembungController>(); level.Bubbles.Add(new Gelembung(controller.PackageName, controller.Type)); } return(level); }
void OnTriggerEnter2D(Collider2D coll) { if (coll.gameObject.GetComponent <BarrierController>() && coll.gameObject.GetComponent <BarrierController>().isSpicky) { bubble.BrokenOut(); } else if (coll.gameObject.GetComponent <BarrierController>()) { Stop(); } else if (coll.gameObject.GetComponent <RubbishController>()) { RubbishController sampahController = coll.gameObject.GetComponent <RubbishController>(); if (bubble.CanLift(sampahController) && !bubble.thrownRubbishes.Contains(sampahController) && !bubble.rubbishes.Contains(sampahController)) { bubble.LiftRubbish(sampahController); } else if (bubble.CanLiftWithThrowFirst(sampahController) && !bubble.thrownRubbishes.Contains(sampahController) && !bubble.rubbishes.Contains(sampahController)) { bubble.ThrowFirstRubbish(); bubble.LiftRubbish(sampahController); } else if (!bubble.rubbishes.Contains(sampahController)) { this.StickyOnRubbish(coll.gameObject); } } else if (coll.gameObject.GetComponent <OrangeBubbleController>()) { this.MergeBubble(coll.gameObject.GetComponent <BubbleController>()); } }
public void LiftRubbish(RubbishController rubbishController) { if (rubbishController.IsLifted()) { rubbishController.ThrowFromAnyBubble(); PlayManager.Score += BubbleController.SkillScore; PlayManager.SkillScore += BubbleController.SkillScore; } DistanceJoint2D djSampah = rubbishController.gameObject.AddComponent <DistanceJoint2D>(); djSampah.connectedBody = rigidbody2D; djSampah.distance = 0f; djSampah.collideConnected = false; djSampah.maxDistanceOnly = true; rubbishes.Add(rubbishController); DistanceJoint2D djGelembung = gameObject.AddComponent <DistanceJoint2D>(); djGelembung.connectedBody = rubbishController.rigidbody2D; djGelembung.distance = 0f; djGelembung.collideConnected = false; djGelembung.maxDistanceOnly = true; distanceJoints.Add(djGelembung); if (HaveBeenBouncing && !HaveBeenLiftRubbish) { PlayManager.Score += BubbleController.RedSkillScore; PlayManager.SkillScore += BubbleController.RedSkillScore; HaveBeenLiftRubbish = true; } }
public void ThrowRubbish(RubbishController RubbishController) { int index = rubbishes.IndexOf(RubbishController); if (index != -1) { Destroy(rubbishes[index].GetComponent <DistanceJoint2D>()); thrownRubbishes.Add(rubbishes[index]); rubbishes.RemoveAt(index); Destroy(distanceJoints[index]); distanceJoints.RemoveAt(index); } }
public void ThrowAllRubbishes() { foreach (RubbishController RubbishController in rubbishes) { Destroy(RubbishController.GetComponent <DistanceJoint2D>()); Physics2D.IgnoreCollision(realCollider, RubbishController.collider2D); Physics2D.IgnoreCollision(detectorCollider, RubbishController.collider2D); thrownRubbishes.Add(RubbishController); } rubbishes.Clear(); foreach (DistanceJoint2D distanceJoint in distanceJoints) { Destroy(distanceJoint); } distanceJoints.Clear(); }
public void OnChange(float value) { if (willChange != null) { if (scrollBar.value <= 0.55 && scrollBar.value >= 0.45) { if (willChange.tag == "Rubbish") { RubbishController rubbish = willChange.GetComponent <RubbishController>(); rubbish.RotationSpeed = 0; } else if (Selected.tag == "Barrier") { BarrierController barrier = willChange.GetComponent <BarrierController>(); barrier.RotationSpeed = 0; } } else if (scrollBar.value > 0.55) { if (willChange.tag == "Rubbish") { RubbishController rubbish = willChange.GetComponent <RubbishController>(); rubbish.RotationSpeed = (scrollBar.value - 0.55f) / 0.45f * rubbish.MAX_ROTATION_SPEED; } else if (willChange.tag == "Barrier") { BarrierController barrier = willChange.GetComponent <BarrierController>(); barrier.RotationSpeed = (scrollBar.value - 0.55f) / 0.45f * barrier.MAX_ROTATION_SPEED; } } else if (scrollBar.value < 0.45) { if (willChange.tag == "Rubbish") { RubbishController rubbish = willChange.GetComponent <RubbishController>(); rubbish.RotationSpeed = (scrollBar.value - 0.45f) / 0.45f * rubbish.MAX_ROTATION_SPEED; } else if (willChange.tag == "Barrier") { BarrierController barrier = willChange.GetComponent <BarrierController>(); barrier.RotationSpeed = (scrollBar.value - 0.45f) / 0.45f * barrier.MAX_ROTATION_SPEED; } } } }
void OnTriggerEnter2D(Collider2D coll) { if (coll.gameObject.GetComponent <BarrierController>() && coll.gameObject.GetComponent <BarrierController>().isSpicky) { bubble.BrokenOut(); } else if (coll.gameObject.GetComponent <RubbishController>()) { RubbishController sampahController = coll.gameObject.GetComponent <RubbishController>(); if (!sampahController.IsLifted() && bubble.CanLift(sampahController) && !bubble.thrownRubbishes.Contains(sampahController)) { bubble.LiftRubbish(sampahController); } else if (!sampahController.IsLifted() && bubble.CanLiftWithThrowFirst(sampahController) && !bubble.thrownRubbishes.Contains(sampahController)) { bubble.ThrowFirstRubbish(); bubble.LiftRubbish(sampahController); } } }
public bool CanLiftWithThrowFirst(RubbishController RubbishController) { return(SizeInInt >= this.SizeOfAllRubbishes() + RubbishController.SizeInInt - this.SizeOfFirstRubbish()); }
public bool CanLift(RubbishController RubbishController) { return(SizeInInt >= this.SizeOfAllRubbishes() + RubbishController.SizeInInt); }
public void Shoot() { Debug.Log(poraController.IsPreparation); Debug.Log(State); if (poraController.IsPreparation && State == GameplayState.Playing) { BubbleController.BubbleSize size = poraController.Shoot(); Vector2 bubblePosition = poraController.GetShootPosition(); InstansiateBubble(size, bubblePosition); if (size == BubbleController.BubbleSize.One || size == BubbleController.BubbleSize.Two) { soundSmall.Play(); } else if (size == BubbleController.BubbleSize.Three) { soundMiddle.Play(); } else { soundLarge.Play(); } } else { } ScreenShot Clue = new ScreenShot(); Clue.Pora = new ScreenShot.CluePora(Pora.GetComponent <RectTransform>().localPosition); Clue.Place = new ScreenShot.PlaceClue(dataStaticLevel.Place); for (int i = 0; i < ParentObject.Barrier.transform.childCount; i++) { BarrierController controller = ParentObject.Barrier.transform.GetChild(i).gameObject.GetComponent <BarrierController>(); ScreenShot.CluePenghalang CluePenghalang = new ScreenShot.CluePenghalang(); CluePenghalang.Packagename = controller.PackageName; CluePenghalang.Nama = controller.Name; CluePenghalang.Posisi = controller.GetComponent <RectTransform>().localPosition; CluePenghalang.KecepatanRotasi = controller.RotationSpeed; CluePenghalang.Rotasi = controller.Rotation; Clue.Barries.Add(CluePenghalang); } for (int i = 0; i < ParentObject.Bubble.transform.childCount; i++) { BubbleController controller = ParentObject.Bubble.transform.GetChild(i).gameObject.GetComponent <BubbleController>(); ScreenShot.ClueGelembung ClueGelembung = new ScreenShot.ClueGelembung(); ClueGelembung.Posisi = controller.GetComponent <RectTransform>().localPosition; ClueGelembung.Size = controller.SizeInInt; ClueGelembung.Type = controller.Type; Clue.Bubbles.Add(ClueGelembung); } for (int i = 0; i < ParentObject.Rubbish.transform.childCount; i++) { RubbishController controller = ParentObject.Rubbish.transform.GetChild(i).gameObject.GetComponent <RubbishController>(); ScreenShot.ClueSampah ClueSampah = new ScreenShot.ClueSampah(); ClueSampah.KecepatanRotasi = controller.RotationSpeed; ClueSampah.Rotasi = controller.Rotation; ClueSampah.Packagename = controller.PackageName; ClueSampah.Posisi = controller.GetComponent <RectTransform>().localPosition; ClueSampah.Size = controller.SizeInInt; Clue.Rubbish.Add(ClueSampah); } ListOfClue.Add(Clue); }