33 * $Date: $
44 * $Revision: $
55 * $Creator: Jen-Chieh Shen $
6- * $Notice: See LICENSE.txt for modification and distribution information
6+ * $Notice: See LICENSE.txt for modification and distribution information
77 * Copyright (c) 2016 by Shen, Jen-Chieh $
88 */
99using UnityEngine ;
1313namespace JCSUnity
1414{
1515 /// <summary>
16- /// Simulate the walk action by the character itself .
16+ /// Action does the AI walk action in 2D .
1717 /// </summary>
1818 [ RequireComponent ( typeof ( JCS_CharacterControllerInfo ) ) ]
1919 [ RequireComponent ( typeof ( JCS_VelocityInfo ) ) ]
@@ -38,14 +38,12 @@ public enum Status
3838
3939 private JCS_VelocityInfo mVelocityInfo = null ;
4040
41+
4142 [ Header ( "** Runtime Varaibles (JCS_2DWalkAction) **" ) ]
4243
43- [ Tooltip ( "Speed of the action. (walk action) " ) ]
44+ [ Tooltip ( "Speed of the action." ) ]
4445 [ SerializeField ]
45- private float mWalkSpeed = 10 ;
46-
47-
48- [ Header ( "** Activate Variables **" ) ]
46+ private float mWalkSpeed = 10.0f ;
4947
5048 [ Tooltip ( "Possibility to walk LEFT way." ) ]
5149 [ SerializeField ] [ Range ( 0.0f , 100.0f ) ]
@@ -64,7 +62,7 @@ [SerializeField] [Range(0.0f, 100.0f)]
6462 private float mPossibility = 80.0f ;
6563
6664
67- [ Header ( "** Time Settings **" ) ]
65+ [ Header ( "** Time Settings (JCS_2DWalkAction) **" ) ]
6866
6967 [ Tooltip ( "Time to do one walk." ) ]
7068 [ SerializeField ] [ Range ( 0.0f , 10.0f ) ]
@@ -74,7 +72,7 @@ [SerializeField] [Range(0.0f, 10.0f)]
7472 [ SerializeField ] [ Range ( 0.0f , 3.0f ) ]
7573 private float mAdjustTimeZone = 1.5f ;
7674
77- // time to record down the real time to do one walk
75+ // time to record down the real time to do one walk
7876 // action after we calculate the real time.
7977 private float mRealTimeZone = 0 ;
8078
@@ -91,16 +89,15 @@ [SerializeField] [Range(0.0f, 3.0f)]
9189 [ SerializeField ]
9290 private bool mStartRandomWalkSpeed = false ;
9391
94- [ Tooltip ( @"Addition value to the walk speed. For
92+ [ Tooltip ( @"Addition value to the walk speed. For
9593instance value 5, will generate -5 ~ 5 and add it on to current walk speed." ) ]
9694 [ SerializeField ] [ Range ( 1 , 10 ) ]
9795 private float mRandomWalkSpeedRange = 5 ;
9896
9997
10098 [ Header ( "** Track Effect (JCS_2DWalkAction) **" ) ]
10199
102- [ Tooltip ( @"Check weather the this object get mad or not. If
103- the get mad will start tracking the object that make this object mad." ) ]
100+ [ Tooltip ( "If get mad will start tracking the object that make this object mad." ) ]
104101 [ SerializeField ]
105102 private bool mMadEffect = true ;
106103
@@ -111,7 +108,7 @@ [SerializeField] [Range(1, 10)]
111108
112109 [ Header ( "** Optional Settings (JCS_2DWalkAction) **" ) ]
113110
114- [ Tooltip ( "Plz fill this is there is animation going on to this game object ." ) ]
111+ [ Tooltip ( "Live object animation." ) ]
115112 [ SerializeField ]
116113 private JCS_2DLiveObjectAnimator mLiveObjectAnimator = null ;
117114
@@ -133,7 +130,7 @@ [SerializeField] [Range(1, 10)]
133130 public float RecordSpeedY { get { return this . mVelocityInfo . RecordSpeed . y ; } set { this . mVelocityInfo . RecordSpeedY = value ; } }
134131 public float RecordSpeedZ { get { return this . mVelocityInfo . RecordSpeed . z ; } set { this . mVelocityInfo . RecordSpeedZ = value ; } }
135132
136- // Track Effects
133+ // Track Effects
137134 public bool MadEffect { get { return this . mMadEffect ; } set { this . mMadEffect = value ; } }
138135
139136 //========================================
@@ -171,7 +168,7 @@ private void Update()
171168 // Public Functions
172169
173170 /// <summary>
174- /// Calculate the possiblity and see if do the walk action .
171+ /// Do the walk action depends on possibility .
175172 /// </summary>
176173 public void WalkByPossiblity ( )
177174 {
@@ -182,7 +179,7 @@ public void WalkByPossiblity()
182179 return ;
183180
184181 // start the algorithm to see if we
185- // find the direction to do,
182+ // find the direction to do,
186183 // if not it will just go randomly.
187184 WalkDirectionPossibility ( ) ;
188185 }
@@ -195,18 +192,18 @@ public void WalkDirectionPossibility()
195192 {
196193 // direction we are going to use next.
197194 Status direction = Status . IDLE ;
198-
195+
199196
200197 // if is already get attack do the mad effect.
201198 if ( mMadEffect && mAttackRecorder != null )
202199 {
203200 Transform lastAttacker = mAttackRecorder . LastAttacker ;
204201
205- // if the last attacker does not exist,
202+ // if the last attacker does not exist,
206203 // do nothing.
207204 if ( lastAttacker != null )
208205 {
209- // if does exist, start following
206+ // if does exist, start following
210207 // the attacker.
211208 if ( lastAttacker . position . x < this . transform . position . x )
212209 direction = Status . LEFT ;
@@ -239,7 +236,7 @@ public void WalkDirectionPossibility()
239236 direction = Status . LEFT ;
240237 ++ resultCounter ;
241238 }
242-
239+
243240 if ( rightPossiblity < mToRight )
244241 {
245242 // success to do right
@@ -259,21 +256,21 @@ public void WalkDirectionPossibility()
259256 /// <summary>
260257 /// Sometimes if the algorithm cannot find which direction to go.
261258 /// Just use the function instead of keep finding the direction.
262- ///
259+ ///
263260 /// For example, all three possiblity (Idle, Left, Right)
264- /// can be set to 100 percent. Than it will always have to
261+ /// can be set to 100 percent. Than it will always have to
265262 /// possiblity of direction to go, which mean the object could
266263 /// not decide which direction to go.
267264 /// </summary>
268265 public void WalkRandomly ( )
269266 {
270267 int result = JCS_Random . Range ( - 1 , 1 + 1 ) ;
271-
268+
272269 WalkByStatus ( result ) ;
273270 }
274271
275272 /// <summary>
276- ///
273+ /// Walk depends on the status.
277274 /// </summary>
278275 /// <param name="direction"></param>
279276 public void WalkByStatus ( int direction )
@@ -282,7 +279,7 @@ public void WalkByStatus(int direction)
282279 }
283280
284281 /// <summary>
285- ///
282+ /// Walk depends on the status.
286283 /// </summary>
287284 /// <param name="status"></param>
288285 public void WalkByStatus ( Status status )
@@ -364,7 +361,7 @@ private void DoWalk()
364361 }
365362
366363 /// <summary>
367- /// Algorithm to calculate the time to do
364+ /// Algorithm to calculate the time to do
368365 /// walk action include direction.
369366 /// </summary>
370367 private void ResetTimeZone ( )
0 commit comments