Skip to content

Commit e59dbc3

Browse files
committed
style: improve readability
1 parent 19c8f69 commit e59dbc3

File tree

5 files changed

+80
-28
lines changed

5 files changed

+80
-28
lines changed

Assets/JCSUnity/Scripts/Actions/2D/Shooting/JCS_2DCursorShootAction.cs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,14 @@ private void LookAtMouse()
7474
{
7575
Camera cam = JCS_Camera.main.GetCamera();
7676

77-
// Set Mouse Position in world
78-
Vector3 Mouse = cam.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y,
79-
Input.mousePosition.z - cam.transform.position.z));
77+
Vector3 mousePosition = Input.mousePosition;
78+
79+
// Set `mouse` Position in world
80+
var mouse = cam.ScreenToWorldPoint(
81+
new Vector3(
82+
mousePosition.x,
83+
mousePosition.y,
84+
mousePosition.z - cam.transform.position.z));
8085

8186
// line connect with curosr pos and this pos.
8287
Vector3 lockPos;
@@ -88,17 +93,17 @@ private void LookAtMouse()
8893
if (JCS_Mathf.IsPositive(transform.localScale.x))
8994
{
9095
lockPos = new Vector3(0, 0,
91-
Mathf.Atan2((Mouse.y - mShootAction.SpawnPoint.position.y),
92-
(Mouse.x - mShootAction.SpawnPoint.position.x)) * Mathf.Rad2Deg);
96+
Mathf.Atan2((mouse.y - mShootAction.SpawnPoint.position.y),
97+
(mouse.x - mShootAction.SpawnPoint.position.x)) * Mathf.Rad2Deg);
9398
}
9499
else
95100
{
96101
lockPos = new Vector3(0, 0,
97-
Mathf.Atan2((-Mouse.y + mShootAction.SpawnPoint.position.y),
98-
(-Mouse.x + mShootAction.SpawnPoint.position.x)) * Mathf.Rad2Deg);
102+
Mathf.Atan2((-mouse.y + mShootAction.SpawnPoint.position.y),
103+
(-mouse.x + mShootAction.SpawnPoint.position.x)) * Mathf.Rad2Deg);
99104
}
100105

101-
// Have the Gun Object look at the Mouse Var
106+
// Have the Gun Object look at the `mouse` Var
102107
mShootAction.SpawnPoint.eulerAngles = lockPos;
103108
}
104109

Assets/JCSUnity/Scripts/Actions/JCS_LookAtMouseAction.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,19 @@ public class JCS_LookAtMouseAction : MonoBehaviour
4040
private void FixedUpdate()
4141
{
4242
// Generate a plane that intersects the transform's position with an upwards normal.
43-
Plane playerPlane = new Plane(Vector3.up, transform.position);
43+
var playerPlane = new Plane(Vector3.up, transform.position);
4444

4545
// Generate a ray from the cursor position
4646
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
4747

4848
// Determine the point where the cursor ray intersects the plane.
4949
// This will be the point that the object must look towards to be looking at the mouse.
50+
5051
// Raycasting to a Plane object only gives us a distance, so we'll have to take the distance,
51-
// then find the point along that ray that meets that distance. This will be the point
52-
// to look at.
52+
// then find the point along that ray that meets that distance. This will be the point
53+
// to look at.
5354
float hitdist = 0.0f;
55+
5456
// If the ray is parallel to the plane, Raycast will return false.
5557
if (playerPlane.Raycast(ray, out hitdist))
5658
{

Assets/JCSUnity/Scripts/GameObject/3D/JCS_3DDragDropObject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ private void OnMouseDown()
4747

4848
private void OnMouseDrag()
4949
{
50-
Vector3 curPos = new Vector3(Input.mousePosition.x - mPosX, Input.mousePosition.y - mPosY, mDistance.z);
50+
var curPos = new Vector3(Input.mousePosition.x - mPosX, Input.mousePosition.y - mPosY, mDistance.z);
5151

5252
Vector3 worldPos = Camera.main.ScreenToWorldPoint(curPos);
5353

Assets/JCSUnity/Scripts/UI/Cursor/JCS_2DCursor.cs

Lines changed: 61 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,69 @@ public class JCS_2DCursor : JCS_Cursor
3737

3838
[Header("- Cursor State")]
3939

40+
[Tooltip("Cursor custom type.")]
4041
[SerializeField]
4142
private JCS_CursorCustomizeType mCursorCustomizeType = JCS_CursorCustomizeType.NORMAL_SELECT;
42-
[SerializeField] private JCS_2DAnimation mNormalSelect = null;
43-
[SerializeField] private JCS_2DAnimation mHelpSelect = null;
44-
[SerializeField] private JCS_2DAnimation mWorkingInBackground = null;
45-
[SerializeField] private JCS_2DAnimation mBusy = null;
46-
[SerializeField] private JCS_2DAnimation mPrecisionSelect = null;
47-
[SerializeField] private JCS_2DAnimation mTextSelect = null;
48-
[SerializeField] private JCS_2DAnimation mHandwriting = null;
49-
[SerializeField] private JCS_2DAnimation mUnavaliable = null;
50-
[SerializeField] private JCS_2DAnimation mVerticalResize = null;
51-
[SerializeField] private JCS_2DAnimation mHorizontalResize = null;
52-
[SerializeField] private JCS_2DAnimation mDiagonalResize1 = null;
53-
[SerializeField] private JCS_2DAnimation mDiagonalResize2 = null;
54-
[SerializeField] private JCS_2DAnimation mMove = null;
55-
[SerializeField] private JCS_2DAnimation mAlternateSelect = null;
56-
[SerializeField] private JCS_2DAnimation mLinkSelect = null;
43+
44+
[Tooltip("Normal select")]
45+
[SerializeField]
46+
private JCS_2DAnimation mNormalSelect = null;
47+
48+
[Tooltip("Help select")]
49+
[SerializeField]
50+
private JCS_2DAnimation mHelpSelect = null;
51+
52+
[Tooltip("Working in background")]
53+
[SerializeField]
54+
private JCS_2DAnimation mWorkingInBackground = null;
55+
56+
[Tooltip("Busy")]
57+
[SerializeField]
58+
private JCS_2DAnimation mBusy = null;
59+
60+
[Tooltip("Precision select")]
61+
[SerializeField]
62+
private JCS_2DAnimation mPrecisionSelect = null;
63+
64+
[Tooltip("Text select")]
65+
[SerializeField]
66+
private JCS_2DAnimation mTextSelect = null;
67+
68+
[Tooltip("Handwriting")]
69+
[SerializeField]
70+
private JCS_2DAnimation mHandwriting = null;
71+
72+
[Tooltip("Unavaliable")]
73+
[SerializeField]
74+
private JCS_2DAnimation mUnavaliable = null;
75+
76+
[Tooltip("Vertical resize.")]
77+
[SerializeField]
78+
private JCS_2DAnimation mVerticalResize = null;
79+
80+
[Tooltip("Horizontal resize")]
81+
[SerializeField]
82+
private JCS_2DAnimation mHorizontalResize = null;
83+
84+
[Tooltip("Diagonal resize 1")]
85+
[SerializeField]
86+
private JCS_2DAnimation mDiagonalResize1 = null;
87+
88+
[Tooltip("Diagonal resize 2")]
89+
[SerializeField]
90+
private JCS_2DAnimation mDiagonalResize2 = null;
91+
92+
[Tooltip("Move")]
93+
[SerializeField]
94+
private JCS_2DAnimation mMove = null;
95+
96+
[Tooltip("Alternate select")]
97+
[SerializeField]
98+
private JCS_2DAnimation mAlternateSelect = null;
99+
100+
[Tooltip("Link select")]
101+
[SerializeField]
102+
private JCS_2DAnimation mLinkSelect = null;
57103

58104
/* Setter & Getter */
59105

Assets/_Project/Scripts/Others/FT_FollowMouse.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,5 @@ private void Update()
3030
Canvas myCanvas = JCS_Canvas.GuessCanvas().canvas;
3131
RectTransformUtility.ScreenPointToLocalPointInRectangle(myCanvas.transform as RectTransform, Input.mousePosition, myCanvas.worldCamera, out pos);
3232
transform.position = JCS_Input.CanvasMousePosition();
33-
3433
}
3534
}

0 commit comments

Comments
 (0)