diff options
author | chai <chaifix@163.com> | 2020-12-30 20:59:04 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2020-12-30 20:59:04 +0800 |
commit | e9ea621b93fbb58d9edfca8375918791637bbd52 (patch) | |
tree | 19ce3b1c1f2d51eda6878c9d0f2c9edc27f13650 /Client/Assembly-CSharp/NavigationMinigame.cs |
+init
Diffstat (limited to 'Client/Assembly-CSharp/NavigationMinigame.cs')
-rw-r--r-- | Client/Assembly-CSharp/NavigationMinigame.cs | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/NavigationMinigame.cs b/Client/Assembly-CSharp/NavigationMinigame.cs new file mode 100644 index 0000000..6e789e2 --- /dev/null +++ b/Client/Assembly-CSharp/NavigationMinigame.cs @@ -0,0 +1,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; + } +} |