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(); 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; } } } } }