summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/SortMinigame.cs
blob: 829f527686107d0d0907b157afeca23b799781a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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;
			}
			}
		}
	}
}