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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
using System;
using System.Collections;
using UnityEngine;
public class NavigationMinigame : Minigame
{
public MeshRenderer TwoAxisImage;
public SpriteRenderer CrossHairImage;
public Collider2D hitbox;
private Controller myController = new Controller();
private Vector2 crossHair;
private Vector2 half = new Vector2(0.5f, 0.5f);
public override void Begin(PlayerTask task)
{
base.Begin(task);
this.crossHair = UnityEngine.Random.insideUnitCircle.normalized / 2f * 0.6f;
Vector3 localPosition = new Vector3(this.crossHair.x * this.TwoAxisImage.bounds.size.x, this.crossHair.y * this.TwoAxisImage.bounds.size.y, -2f);
this.CrossHairImage.transform.localPosition = localPosition;
this.TwoAxisImage.material.SetVector("_CrossHair", this.crossHair + this.half);
}
public void FixedUpdate()
{
if (this.MyNormTask && this.MyNormTask.IsComplete)
{
return;
}
this.myController.Update();
DragState dragState = this.myController.CheckDrag(this.hitbox, false);
if (dragState != DragState.Dragging)
{
if (dragState != DragState.Released)
{
return;
}
if ((this.crossHair - this.half).magnitude < 0.05f)
{
base.StartCoroutine(this.CompleteGame());
this.MyNormTask.NextStep();
}
}
else
{
Vector2 dragPosition = this.myController.DragPosition;
Vector2 a = dragPosition - (this.TwoAxisImage.transform.position - this.TwoAxisImage.bounds.size / 2f);
this.crossHair = a.Div(this.TwoAxisImage.bounds.size);
if ((this.crossHair - this.half).magnitude < 0.45f)
{
Vector3 localPosition = dragPosition - base.transform.position;
localPosition.z = -2f;
this.CrossHairImage.transform.localPosition = localPosition;
this.TwoAxisImage.material.SetVector("_CrossHair", this.crossHair);
return;
}
}
}
private IEnumerator CompleteGame()
{
WaitForSeconds wait = new WaitForSeconds(0.1f);
Color green = new Color(0f, 0.8f, 0f, 1f);
Color32 yellow = new Color32(byte.MaxValue, 202, 0, byte.MaxValue);
this.CrossHairImage.transform.localPosition = new Vector3(0f, 0f, -2f);
this.TwoAxisImage.material.SetVector("_CrossHair", this.half);
this.CrossHairImage.color = yellow;
this.TwoAxisImage.material.SetColor("_CrossColor", yellow);
yield return wait;
this.CrossHairImage.color = Color.white;
this.TwoAxisImage.material.SetColor("_CrossColor", Color.white);
yield return wait;
this.CrossHairImage.color = yellow;
this.TwoAxisImage.material.SetColor("_CrossColor", yellow);
yield return wait;
this.CrossHairImage.color = Color.white;
this.TwoAxisImage.material.SetColor("_CrossColor", Color.white);
yield return wait;
this.CrossHairImage.color = green;
this.TwoAxisImage.material.SetColor("_CrossColor", green);
yield return base.CoStartClose(0.75f);
yield break;
}
}
|