From e9ea621b93fbb58d9edfca8375918791637bbd52 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 30 Dec 2020 20:59:04 +0800 Subject: +init --- Client/Assembly-CSharp/DialBehaviour.cs | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Client/Assembly-CSharp/DialBehaviour.cs (limited to 'Client/Assembly-CSharp/DialBehaviour.cs') diff --git a/Client/Assembly-CSharp/DialBehaviour.cs b/Client/Assembly-CSharp/DialBehaviour.cs new file mode 100644 index 0000000..d306e24 --- /dev/null +++ b/Client/Assembly-CSharp/DialBehaviour.cs @@ -0,0 +1,46 @@ +using System; +using UnityEngine; + +public class DialBehaviour : MonoBehaviour +{ + public FloatRange DialRange; + + public Collider2D collider; + + public Controller myController = new Controller(); + + public float Value; + + public bool Engaged; + + public Transform DialTrans; + + public Transform DialShadTrans; + + public void Update() + { + this.Engaged = false; + this.myController.Update(); + DragState dragState = this.myController.CheckDrag(this.collider, false); + if (dragState == DragState.Dragging) + { + Vector2 vector = this.myController.DragPosition - base.transform.position; + float num = Vector2.up.AngleSigned(vector); + if (num < -180f) + { + num += 360f; + } + num = this.DialRange.Clamp(num); + this.SetValue(num); + this.Engaged = true; + } + } + + public void SetValue(float angle) + { + this.Value = angle; + Vector3 localEulerAngles = new Vector3(0f, 0f, angle); + this.DialTrans.localEulerAngles = localEulerAngles; + this.DialShadTrans.localEulerAngles = localEulerAngles; + } +} -- cgit v1.1-26-g67d0