diff options
Diffstat (limited to 'Client/Assembly-CSharp/SortMinigame.cs')
-rw-r--r-- | Client/Assembly-CSharp/SortMinigame.cs | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/SortMinigame.cs b/Client/Assembly-CSharp/SortMinigame.cs new file mode 100644 index 0000000..829f527 --- /dev/null +++ b/Client/Assembly-CSharp/SortMinigame.cs @@ -0,0 +1,72 @@ +using System; +using UnityEngine; + +public class SortMinigame : Minigame +{ + public SortGameObject[] Objects; + + public BoxCollider2D AnimalBox; + + public BoxCollider2D PlantBox; + + public BoxCollider2D MineralBox; + + private Controller myController = new Controller(); + + public void Start() + { + this.Objects.Shuffle<SortGameObject>(); + for (int i = 0; i < this.Objects.Length; i++) + { + this.Objects[i].transform.localPosition = new Vector3(Mathf.Lerp(-2f, 2f, (float)i / ((float)this.Objects.Length - 1f)), FloatRange.Next(-1.75f, -1f), -1f); + } + } + + public void Update() + { + if (this.amClosing != Minigame.CloseState.None) + { + return; + } + this.myController.Update(); + for (int i = 0; i < this.Objects.Length; i++) + { + SortGameObject sortGameObject = this.Objects[i]; + switch (this.myController.CheckDrag(sortGameObject.Collider, false)) + { + case DragState.Dragging: + { + Vector2 dragPosition = this.myController.DragPosition; + sortGameObject.Collider.attachedRigidbody.position = dragPosition; + break; + } + case DragState.Released: + { + bool flag = true; + for (int j = 0; j < this.Objects.Length; j++) + { + SortGameObject sortGameObject2 = this.Objects[j]; + switch (sortGameObject2.MyType) + { + case SortGameObject.ObjType.Plant: + flag &= sortGameObject2.Collider.IsTouching(this.PlantBox); + break; + case SortGameObject.ObjType.Mineral: + flag &= sortGameObject2.Collider.IsTouching(this.MineralBox); + break; + case SortGameObject.ObjType.Animal: + flag &= sortGameObject2.Collider.IsTouching(this.AnimalBox); + break; + } + } + if (flag) + { + this.MyTask.Complete(); + base.StartCoroutine(base.CoStartClose(0.75f)); + } + break; + } + } + } + } +} |