Skip to content

Commit 18f154e

Browse files
committed
style: clean up
1 parent faa430d commit 18f154e

File tree

7 files changed

+73
-90
lines changed

7 files changed

+73
-90
lines changed

Assets/JCSUnity/Scripts/Interfaces/JCS_Instance.cs

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public abstract class JCS_Instance<T> : MonoBehaviour
2424

2525
/* Setter & Getter */
2626

27-
public Dictionary<Scene, T> instances { get { return mInstances; } }
27+
public static Dictionary<Scene, T> instances { get { return mInstances; } }
2828

2929
/* Functions */
3030

@@ -66,16 +66,16 @@ public void DeregisterInstance(Scene scene)
6666
/// <summary>
6767
/// Clean up unused instances.
6868
/// </summary>
69-
public void CleanInstances()
69+
public static void CleanInstances()
7070
{
7171
List<Scene> scenes = new();
7272

7373
foreach (Scene scene in mInstances.Keys)
7474
{
75-
if (!scene.isLoaded)
76-
{
77-
scenes.Add(scene);
78-
}
75+
if (scene.isLoaded)
76+
continue;
77+
78+
scenes.Add(scene);
7979
}
8080

8181
foreach (Scene scene in scenes)
@@ -102,24 +102,6 @@ public static T GetInstance()
102102
{
103103
return GetInstance(SceneManager.GetActiveScene());
104104
}
105-
public static T GetInstance(uint id)
106-
{
107-
List<Scene> scenes = JCS_SceneManager.GetAllScenes();
108-
109-
Scene scene = scenes.Where((scene) =>
110-
{
111-
string name = scene.name;
112-
113-
if (!name.StartsWith("Arena"))
114-
return false;
115-
116-
string[] splits = name.Split(":");
117-
118-
return splits.Last() == id.ToString();
119-
}).First();
120-
121-
return GetInstance(scene);
122-
}
123105
public static T GetInstance(Component comp)
124106
{
125107
return GetInstance(comp.transform);

Assets/JCSUnity/Scripts/JCS_Camera.cs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -96,31 +96,31 @@ public abstract class JCS_Camera : MonoBehaviour
9696

9797
/* Setter & Getter */
9898

99-
public Vector3 positionOffset { get { return this.mPositionOffset; } set { this.mPositionOffset = value; } }
100-
public Vector3 camRectSize { get { return this.mCamRectSize; } set { this.mCamRectSize = value; } }
101-
public Rect camRect { get { return this.mCamRect; } }
102-
public Camera GetCamera() { return this.mCamera; }
103-
public float fieldOfView { get { return this.mCamera.fieldOfView; } set { this.mCamera.fieldOfView = value; } }
104-
public Vector3 velocity { get { return this.mVelocity; } set { this.mVelocity = value; } }
105-
public bool following { get { return this.mFollowing; } set { this.mFollowing = value; } }
106-
public bool smoothTrack { get { return this.mSmoothTrack; } set { this.mSmoothTrack = value; } }
107-
108-
public virtual void SetFollowTarget(Transform trans) { this.mTargetTransform = trans; }
99+
public Vector3 positionOffset { get { return mPositionOffset; } set { mPositionOffset = value; } }
100+
public Vector3 camRectSize { get { return mCamRectSize; } set { mCamRectSize = value; } }
101+
public Rect camRect { get { return mCamRect; } }
102+
public Camera GetCamera() { return mCamera; }
103+
public float fieldOfView { get { return mCamera.fieldOfView; } set { mCamera.fieldOfView = value; } }
104+
public Vector3 velocity { get { return mVelocity; } set { mVelocity = value; } }
105+
public bool following { get { return mFollowing; } set { mFollowing = value; } }
106+
public bool smoothTrack { get { return mSmoothTrack; } set { mSmoothTrack = value; } }
107+
108+
public virtual void SetFollowTarget(Transform trans) { mTargetTransform = trans; }
109109
public virtual Transform GetFollowTarget() { return mTargetTransform; }
110110

111111
public float screenAspect { get { return (float)mCamera.pixelWidth / (float)mCamera.pixelHeight; } }
112112

113-
public JCS_TimeType timeType { get { return this.mTimeType; } set { this.mTimeType = value; } }
113+
public JCS_TimeType timeType { get { return mTimeType; } set { mTimeType = value; } }
114114

115-
public JCS_Boundary boundary { get { return this.mBoundary; } set { this.mBoundary = value; } }
115+
public JCS_Boundary boundary { get { return mBoundary; } set { mBoundary = value; } }
116116

117117
/* Functions */
118118

119119
protected virtual void Awake()
120120
{
121121
main = this;
122122

123-
this.mCamera = this.GetComponent<Camera>();
123+
mCamera = GetComponent<Camera>();
124124
}
125125

126126
protected virtual void Start()
@@ -303,7 +303,7 @@ private Vector3 GameDepthRect(Vector3 depth)
303303
/// <summary>
304304
/// Square inside the game editor screen. Display
305305
/// the screen width and height in current game depth.
306-
/// 2D Game probably need this. 3D Game is optional.
306+
/// 2D Game probably need 3D Game is optional.
307307
/// </summary>
308308
private void DisplayGameDepthCamera()
309309
{
@@ -625,10 +625,10 @@ public Vector3 CanvasToWorldSpace(Vector2 targetCanvasPos)
625625
/// <param name="yPos"> y position </param>
626626
public void SetPosition(float xPos, float yPos)
627627
{
628-
Vector3 newPos = this.transform.position;
628+
Vector3 newPos = transform.position;
629629
newPos.x = xPos + mPositionOffset.x;
630630
newPos.y = yPos + mPositionOffset.y;
631-
this.transform.position = newPos;
631+
transform.position = newPos;
632632
}
633633

634634
/// <summary>
@@ -650,11 +650,11 @@ public void SetPosition(Vector2 vec)
650650
/// <param name="zPos"> z position </param>
651651
public void SetPosition(float xPos, float yPos, float zPos)
652652
{
653-
Vector3 newPos = this.transform.position;
653+
Vector3 newPos = transform.position;
654654
newPos.x = xPos + mPositionOffset.x;
655655
newPos.y = yPos + mPositionOffset.y;
656656
newPos.z = zPos + mPositionOffset.z;
657-
this.transform.position = newPos;
657+
transform.position = newPos;
658658
}
659659

660660
/// <summary>
@@ -694,9 +694,9 @@ private void DoBoundaries()
694694

695695
Bounds bounds = mBoundary.GetBounds();
696696

697-
Vector3 camPos = this.transform.position;
697+
Vector3 camPos = transform.position;
698698

699-
this.transform.position = bounds.ClosestPoint(camPos);
699+
transform.position = bounds.ClosestPoint(camPos);
700700
}
701701

702702
/// <summary>

Assets/JCSUnity/Scripts/JCS_ColliderObject.cs

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ public class JCS_ColliderObject : MonoBehaviour
3535

3636
/* Setter & Getter */
3737

38-
public JCS_ColliderType colliderType { get { return this.mColliderType; } }
38+
public JCS_ColliderType colliderType { get { return mColliderType; } }
3939

40-
public CharacterController characterController { get { return this.mCharacterController; } }
41-
public BoxCollider boxCollider { get { return this.mBoxCollider; } }
42-
public SphereCollider sphereCollider { get { return this.mSphereCollider; } }
43-
public CapsuleCollider capsuleCollider { get { return this.mCapsuleCollider; } }
44-
public BoxCollider2D boxCollider2D { get { return this.mBoxCollider2D; } }
45-
public CircleCollider2D circleCollider2D { get { return this.mCircleCollider2D; } }
46-
public CapsuleCollider2D capsuleCollider2D { get { return this.mCapsuleCollider2D; } }
40+
public CharacterController characterController { get { return mCharacterController; } }
41+
public BoxCollider boxCollider { get { return mBoxCollider; } }
42+
public SphereCollider sphereCollider { get { return mSphereCollider; } }
43+
public CapsuleCollider capsuleCollider { get { return mCapsuleCollider; } }
44+
public BoxCollider2D boxCollider2D { get { return mBoxCollider2D; } }
45+
public CircleCollider2D circleCollider2D { get { return mCircleCollider2D; } }
46+
public CapsuleCollider2D capsuleCollider2D { get { return mCapsuleCollider2D; } }
4747

4848
/* Functions */
4949

@@ -60,23 +60,23 @@ protected virtual void Awake()
6060
/// </returns>
6161
public JCS_ColliderType DetectColliderOnce()
6262
{
63-
this.mCharacterController = this.GetComponent<CharacterController>();
64-
this.mBoxCollider = this.GetComponent<BoxCollider>();
65-
this.mSphereCollider = this.GetComponent<SphereCollider>();
66-
this.mCapsuleCollider = this.GetComponent<CapsuleCollider>();
67-
this.mBoxCollider2D = this.GetComponent<BoxCollider2D>();
68-
this.mCircleCollider2D = this.GetComponent<CircleCollider2D>();
69-
this.mCapsuleCollider2D = this.GetComponent<CapsuleCollider2D>();
63+
mCharacterController = GetComponent<CharacterController>();
64+
mBoxCollider = GetComponent<BoxCollider>();
65+
mSphereCollider = GetComponent<SphereCollider>();
66+
mCapsuleCollider = GetComponent<CapsuleCollider>();
67+
mBoxCollider2D = GetComponent<BoxCollider2D>();
68+
mCircleCollider2D = GetComponent<CircleCollider2D>();
69+
mCapsuleCollider2D = GetComponent<CapsuleCollider2D>();
7070

71-
if (mCharacterController) this.mColliderType = JCS_ColliderType.CHARACTER_CONTROLLER;
72-
if (mBoxCollider) this.mColliderType = JCS_ColliderType.BOX;
73-
if (mSphereCollider) this.mColliderType = JCS_ColliderType.SPHERE;
74-
if (mCapsuleCollider) this.mColliderType = JCS_ColliderType.CAPSULE;
75-
if (mBoxCollider2D) this.mColliderType = JCS_ColliderType.BOX_2D;
76-
if (mCircleCollider2D) this.mColliderType = JCS_ColliderType.CIRCLE_2D;
77-
if (mCapsuleCollider2D) this.mColliderType = JCS_ColliderType.CAPSULE_2D;
71+
if (mCharacterController) mColliderType = JCS_ColliderType.CHARACTER_CONTROLLER;
72+
if (mBoxCollider) mColliderType = JCS_ColliderType.BOX;
73+
if (mSphereCollider) mColliderType = JCS_ColliderType.SPHERE;
74+
if (mCapsuleCollider) mColliderType = JCS_ColliderType.CAPSULE;
75+
if (mBoxCollider2D) mColliderType = JCS_ColliderType.BOX_2D;
76+
if (mCircleCollider2D) mColliderType = JCS_ColliderType.CIRCLE_2D;
77+
if (mCapsuleCollider2D) mColliderType = JCS_ColliderType.CAPSULE_2D;
7878

79-
return this.mColliderType;
79+
return mColliderType;
8080
}
8181

8282
/// <summary>
@@ -89,7 +89,7 @@ public JCS_ColliderType DetectColliderOnce()
8989
/// </returns>
9090
public bool IsColliderType(JCS_ColliderType type)
9191
{
92-
return this.mColliderType == type;
92+
return mColliderType == type;
9393
}
9494

9595
public Vector3 center
@@ -116,16 +116,16 @@ public Vector3 center
116116
switch (mColliderType)
117117
{
118118
case JCS_ColliderType.CHARACTER_CONTROLLER:
119-
this.mCharacterController.center = value;
119+
mCharacterController.center = value;
120120
break;
121121
case JCS_ColliderType.BOX:
122-
this.mBoxCollider.center = value;
122+
mBoxCollider.center = value;
123123
break;
124124
case JCS_ColliderType.SPHERE:
125-
this.mSphereCollider.center = value;
125+
mSphereCollider.center = value;
126126
break;
127127
case JCS_ColliderType.CAPSULE:
128-
this.mCapsuleCollider.center = value;
128+
mCapsuleCollider.center = value;
129129
break;
130130
default:
131131
Debug.LogWarning("No collider found");
@@ -156,13 +156,13 @@ public Vector3 offset
156156
switch (mColliderType)
157157
{
158158
case JCS_ColliderType.BOX_2D:
159-
this.mBoxCollider2D.offset = value;
159+
mBoxCollider2D.offset = value;
160160
break;
161161
case JCS_ColliderType.CIRCLE_2D:
162-
this.mCircleCollider2D.offset = value;
162+
mCircleCollider2D.offset = value;
163163
break;
164164
case JCS_ColliderType.CAPSULE_2D:
165-
this.mCapsuleCollider2D.offset = value;
165+
mCapsuleCollider2D.offset = value;
166166
break;
167167
default:
168168
Debug.LogWarning("No collider found");
@@ -193,13 +193,13 @@ public Vector3 size
193193
switch (mColliderType)
194194
{
195195
case JCS_ColliderType.BOX:
196-
this.mBoxCollider.size = value;
196+
mBoxCollider.size = value;
197197
break;
198198
case JCS_ColliderType.BOX_2D:
199-
this.mBoxCollider2D.size = value;
199+
mBoxCollider2D.size = value;
200200
break;
201201
case JCS_ColliderType.CAPSULE_2D:
202-
this.mCapsuleCollider2D.size = value;
202+
mCapsuleCollider2D.size = value;
203203
break;
204204
default:
205205
Debug.LogWarning("No collider found");
@@ -235,13 +235,13 @@ public float radius
235235
mCharacterController.radius = value;
236236
break;
237237
case JCS_ColliderType.SPHERE:
238-
this.mSphereCollider.radius = value;
238+
mSphereCollider.radius = value;
239239
break;
240240
case JCS_ColliderType.CAPSULE:
241-
this.mCapsuleCollider.radius = value;
241+
mCapsuleCollider.radius = value;
242242
break;
243243
case JCS_ColliderType.CIRCLE_2D:
244-
this.mCircleCollider2D.radius = value;
244+
mCircleCollider2D.radius = value;
245245
break;
246246
default:
247247
Debug.LogWarning("No collider found");
@@ -269,10 +269,10 @@ public float height
269269
switch (mColliderType)
270270
{
271271
case JCS_ColliderType.CHARACTER_CONTROLLER:
272-
this.mCharacterController.height = value;
272+
mCharacterController.height = value;
273273
break;
274274
case JCS_ColliderType.CAPSULE:
275-
this.mCapsuleCollider.height = value;
275+
mCapsuleCollider.height = value;
276276
break;
277277
default:
278278
Debug.LogWarning("No collider found");

Assets/JCSUnity/Scripts/JCS_UniqueObject.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public class JCS_UniqueObject : MonoBehaviour
2424
private void Awake()
2525
{
2626
// only the root object can do this.
27-
if (this.transform.parent == null)
28-
DontDestroyOnLoad(this.gameObject);
27+
if (transform.parent == null)
28+
DontDestroyOnLoad(gameObject);
2929
else
3030
{
3131
Debug.LogWarning("Only the root object can be use DontDestoryOnLoad");

Assets/JCSUnity/Scripts/UI/JCS_InputField.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public class JCS_InputField : JCS_InputFieldObject
6060

6161
/* Setter & Getter */
6262

63-
public string realText { get { return this.mRealText; } }
63+
public string realText { get { return mRealText; } }
6464

6565
/* Functions */
6666

@@ -138,6 +138,7 @@ public void UpdateInputFieldData()
138138
int firstReplacePos = centerLetterPos - halfDotCount;
139139

140140
int secondReplacePos = firstReplacePos;
141+
141142
if (JCS_Mathf.IsOdd(mDotCount))
142143
{
143144
if (mApproachSec)

Assets/JCSUnity/Scripts/UI/JCS_Marquee.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ public class JCS_Marquee : MonoBehaviour
5454

5555
/* Setter & Getter */
5656

57-
public Text textContainer { get { return this.mTextContainer; } set { this.mTextContainer = value; } }
57+
public Text textContainer { get { return mTextContainer; } set { this.mTextContainer = value; } }
5858

5959
/* Functions */
6060

6161
private void Awake()
6262
{
6363
if (mTextContainer == null)
64-
mTextContainer = this.GetComponentInChildren<Text>();
64+
mTextContainer = GetComponentInChildren<Text>();
6565

6666
mDistanceTileAction = JCS_Util.ForceGetComponent<JCS_3DDistanceTileAction>(mTextContainer);
6767
}

Assets/_Project/Scripts/UI/FT_TextMesh.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class FT_TextMesh : MonoBehaviour
2626

2727
private void Awake()
2828
{
29-
this.textMesh = GetComponent<TextMeshPro>();
30-
this.tmpText = GetComponent<TMP_Text>();
29+
textMesh = GetComponent<TextMeshPro>();
30+
tmpText = GetComponent<TMP_Text>();
3131
}
3232
}

0 commit comments

Comments
 (0)