3
3
* $Date: $
4
4
* $Revision: $
5
5
* $Creator: Jen-Chieh Shen $
6
- * $Notice: See LICENSE.txt for modification and distribution information
6
+ * $Notice: See LICENSE.txt for modification and distribution information
7
7
* Copyright (c) 2016 by Shen, Jen-Chieh $
8
8
*/
9
9
using UnityEngine ;
13
13
namespace JCSUnity
14
14
{
15
15
/// <summary>
16
- /// Simulate the walk action by the character itself .
16
+ /// Action does the AI walk action in 2D .
17
17
/// </summary>
18
18
[ RequireComponent ( typeof ( JCS_CharacterControllerInfo ) ) ]
19
19
[ RequireComponent ( typeof ( JCS_VelocityInfo ) ) ]
@@ -38,14 +38,12 @@ public enum Status
38
38
39
39
private JCS_VelocityInfo mVelocityInfo = null ;
40
40
41
+
41
42
[ Header ( "** Runtime Varaibles (JCS_2DWalkAction) **" ) ]
42
43
43
- [ Tooltip ( "Speed of the action. (walk action) " ) ]
44
+ [ Tooltip ( "Speed of the action." ) ]
44
45
[ SerializeField ]
45
- private float mWalkSpeed = 10 ;
46
-
47
-
48
- [ Header ( "** Activate Variables **" ) ]
46
+ private float mWalkSpeed = 10.0f ;
49
47
50
48
[ Tooltip ( "Possibility to walk LEFT way." ) ]
51
49
[ SerializeField ] [ Range ( 0.0f , 100.0f ) ]
@@ -64,7 +62,7 @@ [SerializeField] [Range(0.0f, 100.0f)]
64
62
private float mPossibility = 80.0f ;
65
63
66
64
67
- [ Header ( "** Time Settings **" ) ]
65
+ [ Header ( "** Time Settings (JCS_2DWalkAction) **" ) ]
68
66
69
67
[ Tooltip ( "Time to do one walk." ) ]
70
68
[ SerializeField ] [ Range ( 0.0f , 10.0f ) ]
@@ -74,7 +72,7 @@ [SerializeField] [Range(0.0f, 10.0f)]
74
72
[ SerializeField ] [ Range ( 0.0f , 3.0f ) ]
75
73
private float mAdjustTimeZone = 1.5f ;
76
74
77
- // time to record down the real time to do one walk
75
+ // time to record down the real time to do one walk
78
76
// action after we calculate the real time.
79
77
private float mRealTimeZone = 0 ;
80
78
@@ -91,16 +89,15 @@ [SerializeField] [Range(0.0f, 3.0f)]
91
89
[ SerializeField ]
92
90
private bool mStartRandomWalkSpeed = false ;
93
91
94
- [ Tooltip ( @"Addition value to the walk speed. For
92
+ [ Tooltip ( @"Addition value to the walk speed. For
95
93
instance value 5, will generate -5 ~ 5 and add it on to current walk speed." ) ]
96
94
[ SerializeField ] [ Range ( 1 , 10 ) ]
97
95
private float mRandomWalkSpeedRange = 5 ;
98
96
99
97
100
98
[ Header ( "** Track Effect (JCS_2DWalkAction) **" ) ]
101
99
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." ) ]
104
101
[ SerializeField ]
105
102
private bool mMadEffect = true ;
106
103
@@ -111,7 +108,7 @@ [SerializeField] [Range(1, 10)]
111
108
112
109
[ Header ( "** Optional Settings (JCS_2DWalkAction) **" ) ]
113
110
114
- [ Tooltip ( "Plz fill this is there is animation going on to this game object ." ) ]
111
+ [ Tooltip ( "Live object animation." ) ]
115
112
[ SerializeField ]
116
113
private JCS_2DLiveObjectAnimator mLiveObjectAnimator = null ;
117
114
@@ -133,7 +130,7 @@ [SerializeField] [Range(1, 10)]
133
130
public float RecordSpeedY { get { return this . mVelocityInfo . RecordSpeed . y ; } set { this . mVelocityInfo . RecordSpeedY = value ; } }
134
131
public float RecordSpeedZ { get { return this . mVelocityInfo . RecordSpeed . z ; } set { this . mVelocityInfo . RecordSpeedZ = value ; } }
135
132
136
- // Track Effects
133
+ // Track Effects
137
134
public bool MadEffect { get { return this . mMadEffect ; } set { this . mMadEffect = value ; } }
138
135
139
136
//========================================
@@ -171,7 +168,7 @@ private void Update()
171
168
// Public Functions
172
169
173
170
/// <summary>
174
- /// Calculate the possiblity and see if do the walk action .
171
+ /// Do the walk action depends on possibility .
175
172
/// </summary>
176
173
public void WalkByPossiblity ( )
177
174
{
@@ -182,7 +179,7 @@ public void WalkByPossiblity()
182
179
return ;
183
180
184
181
// start the algorithm to see if we
185
- // find the direction to do,
182
+ // find the direction to do,
186
183
// if not it will just go randomly.
187
184
WalkDirectionPossibility ( ) ;
188
185
}
@@ -195,18 +192,18 @@ public void WalkDirectionPossibility()
195
192
{
196
193
// direction we are going to use next.
197
194
Status direction = Status . IDLE ;
198
-
195
+
199
196
200
197
// if is already get attack do the mad effect.
201
198
if ( mMadEffect && mAttackRecorder != null )
202
199
{
203
200
Transform lastAttacker = mAttackRecorder . LastAttacker ;
204
201
205
- // if the last attacker does not exist,
202
+ // if the last attacker does not exist,
206
203
// do nothing.
207
204
if ( lastAttacker != null )
208
205
{
209
- // if does exist, start following
206
+ // if does exist, start following
210
207
// the attacker.
211
208
if ( lastAttacker . position . x < this . transform . position . x )
212
209
direction = Status . LEFT ;
@@ -239,7 +236,7 @@ public void WalkDirectionPossibility()
239
236
direction = Status . LEFT ;
240
237
++ resultCounter ;
241
238
}
242
-
239
+
243
240
if ( rightPossiblity < mToRight )
244
241
{
245
242
// success to do right
@@ -259,21 +256,21 @@ public void WalkDirectionPossibility()
259
256
/// <summary>
260
257
/// Sometimes if the algorithm cannot find which direction to go.
261
258
/// Just use the function instead of keep finding the direction.
262
- ///
259
+ ///
263
260
/// 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
265
262
/// possiblity of direction to go, which mean the object could
266
263
/// not decide which direction to go.
267
264
/// </summary>
268
265
public void WalkRandomly ( )
269
266
{
270
267
int result = JCS_Random . Range ( - 1 , 1 + 1 ) ;
271
-
268
+
272
269
WalkByStatus ( result ) ;
273
270
}
274
271
275
272
/// <summary>
276
- ///
273
+ /// Walk depends on the status.
277
274
/// </summary>
278
275
/// <param name="direction"></param>
279
276
public void WalkByStatus ( int direction )
@@ -282,7 +279,7 @@ public void WalkByStatus(int direction)
282
279
}
283
280
284
281
/// <summary>
285
- ///
282
+ /// Walk depends on the status.
286
283
/// </summary>
287
284
/// <param name="status"></param>
288
285
public void WalkByStatus ( Status status )
@@ -364,7 +361,7 @@ private void DoWalk()
364
361
}
365
362
366
363
/// <summary>
367
- /// Algorithm to calculate the time to do
364
+ /// Algorithm to calculate the time to do
368
365
/// walk action include direction.
369
366
/// </summary>
370
367
private void ResetTimeZone ( )
0 commit comments