shuvit 4 years ago
parent
commit
d3f5d16463
4 changed files with 12 additions and 84 deletions
  1. 3
    0
      assets/roads_bak.blend
  2. 3
    0
      characters/annie_actions.blend
  3. 3
    0
      characters/annie_actions1.blend
  4. 3
    84
      scripts/StatesCar.py

+ 3
- 0
assets/roads_bak.blend View File

1
+version https://git-lfs.github.com/spec/v1
2
+oid sha256:784809674b518a6435240657168d882fc30d0dace8f4fdd643ecc4dc0189b4e4
3
+size 83642732

+ 3
- 0
characters/annie_actions.blend View File

1
+version https://git-lfs.github.com/spec/v1
2
+oid sha256:79b18251c91fea0da8010ccbc3999a6038753731fcd1707eedc026af6fdce1a8
3
+size 12021164

+ 3
- 0
characters/annie_actions1.blend View File

1
+version https://git-lfs.github.com/spec/v1
2
+oid sha256:04b45c642e23d76d6526d7f4da8fb61ee1c2b6a48ae95cf4228647cf0bd122f8
3
+size 12504512

+ 3
- 84
scripts/StatesCar.py View File

7
 
7
 
8
 def mark_path(path, y):
8
 def mark_path(path, y):
9
     iter_ = 0
9
     iter_ = 0
10
-
11
     for x in path:
10
     for x in path:
12
         pm = bge.logic.getCurrentScene().addObject('path_marker', y.obj, 0)
11
         pm = bge.logic.getCurrentScene().addObject('path_marker', y.obj, 0)
13
         pm.worldPosition = path[iter_]    
12
         pm.worldPosition = path[iter_]    
21
         y.path_display.append(pm)
20
         y.path_display.append(pm)
22
 
21
 
23
 def clear_markers(self):
22
 def clear_markers(self):
24
-    # for x in bge.logic.getCurrentScene().objects:
25
-    #     if 'path_marker' in x.name:
26
-    #         x.endObject()
27
     for x in self.FSM.owner.path_display:
23
     for x in self.FSM.owner.path_display:
28
         try:
24
         try:
29
             x.endObject()
25
             x.endObject()
81
         self.FSM.FSM.ToTransition('toEnterParallelPark')
77
         self.FSM.FSM.ToTransition('toEnterParallelPark')
82
 
78
 
83
 def get_lane_point(self):
79
 def get_lane_point(self):
84
-
85
-
86
     self.point = self.path[self.path_index]
80
     self.point = self.path[self.path_index]
87
-    #print(self.path_index, 'path index')
88
     if self.point != self.last_lane_point:
81
     if self.point != self.last_lane_point:
89
         v = Vector([self.last_lane_point.x - self.point.x, self.last_lane_point.y - self.point.y, 0])
82
         v = Vector([self.last_lane_point.x - self.point.x, self.last_lane_point.y - self.point.y, 0])
90
         tv = v.normalized()
83
         tv = v.normalized()
92
         self.last_lane_point = self.lane_point
85
         self.last_lane_point = self.lane_point
93
         self.lane_point = self.point + self.manager.lane_position * nv
86
         self.lane_point = self.point + self.manager.lane_position * nv
94
 
87
 
95
-
96
-
97
 def update_point(self):
88
 def update_point(self):
98
     
89
     
99
     if self.path_index >= (len(self.path) ):
90
     if self.path_index >= (len(self.path) ):
100
         self.FSM.FSM.ToTransition('toEnterParallelPark')
91
         self.FSM.FSM.ToTransition('toEnterParallelPark')
101
     else:
92
     else:
102
         dist = self.obj.getDistanceTo(self.lane_point)
93
         dist = self.obj.getDistanceTo(self.lane_point)
103
-        #print(dist, self.path_index)
104
         self.point = self.path[self.path_index]
94
         self.point = self.path[self.path_index]
105
         if dist < 2.5:
95
         if dist < 2.5:
106
             get_lane_point(self)   
96
             get_lane_point(self)   
107
             if self.path_index > (len(self.path)):
97
             if self.path_index > (len(self.path)):
108
                 pass
98
                 pass
109
             else:
99
             else:
110
-                
111
                 self.path_index += 1
100
                 self.path_index += 1
112
-            
113
-
114
          
101
          
115
 def align_to_point(self):
102
 def align_to_point(self):
116
     v = self.obj.getVectTo(self.lane_point)[1]
103
     v = self.obj.getVectTo(self.lane_point)[1]
119
 
106
 
120
 def delta_to_vect(self):
107
 def delta_to_vect(self):
121
     v = self.obj.getVectTo(self.lane_point)[1]
108
     v = self.obj.getVectTo(self.lane_point)[1]
122
-    #vt = Vector([self.last_lane_point.x - self.lane_point.x, self.last_lane_point.y - self.lane_point.y, 0])
123
-
124
     delta = self.last_lane_point - self.lane_point
109
     delta = self.last_lane_point - self.lane_point
125
     delta = delta.cross(v)
110
     delta = delta.cross(v)
126
     delta_mult = -.1
111
     delta_mult = -.1
127
     mult = 1.0
112
     mult = 1.0
128
     deltamove = delta[2] * delta_mult
113
     deltamove = delta[2] * delta_mult
129
-    #self.obj.applyMovement([0, deltamove, 0], True)
130
     f = deltamove * 5000
114
     f = deltamove * 5000
131
     self.obj.applyForce([0, f, 0], True)
115
     self.obj.applyForce([0, f, 0], True)
132
             
116
             
167
     def Execute(self):
151
     def Execute(self):
168
         self.FSM.stateLife += 1
152
         self.FSM.stateLife += 1
169
         print('doing example')
153
         print('doing example')
170
-        #o = self.FSM.owner
171
-        #g = o.me['game']
172
-        #self.FSM.ToTransition('toActivate')
173
-        #print(self.FSM.owner)
174
-        #self.FSM.owner.applyRotation([0,0,.01], True)
175
-        #self.FSM.owner.worldPosition.z = 0
176
-        #self.FSM.owner.worldPosition.z += 0.1
177
-        #self.FSM.owner.worldPosition.x += 1.1
178
-        #print(self.FSM.owner.children)
179
-
154
+        
180
     def Exit(self):
155
     def Exit(self):
181
         pass
156
         pass
182
 
157
 
195
         self.FSM.owner.target.status = 'targetted'
170
         self.FSM.owner.target.status = 'targetted'
196
         self.FSM.owner.start_empty.status = 'available'
171
         self.FSM.owner.start_empty.status = 'available'
197
         
172
         
198
-        #print('target is', self.FSM.owner.target)
199
         print('physics resumed')
173
         print('physics resumed')
200
         super(ExitParallelPark, self).Enter()        
174
         super(ExitParallelPark, self).Enter()        
201
         
175
         
202
     def Execute(self):
176
     def Execute(self):
203
         self.FSM.stateLife += 1
177
         self.FSM.stateLife += 1
204
-        #print('doing ExitParallelPark')
205
         v = self.FSM.owner.obj.getVectTo(self.FSM.owner.path[0])
178
         v = self.FSM.owner.obj.getVectTo(self.FSM.owner.path[0])
206
-        #v.z = 0
207
         self.FSM.owner.obj.alignAxisToVect(v[1], 0, .01)
179
         self.FSM.owner.obj.alignAxisToVect(v[1], 0, .01)
208
         self.FSM.owner.obj.alignAxisToVect([0,0,1], 2, 1)
180
         self.FSM.owner.obj.alignAxisToVect([0,0,1], 2, 1)
209
         if self.FSM.stateLife > 220:
181
         if self.FSM.stateLife > 220:
210
             self.FSM.ToTransition('toNavigateToTarget')
182
             self.FSM.ToTransition('toNavigateToTarget')
211
-        #self.FSM.owner.obj.applyForce([6, 0, 0], True)
212
 
183
 
213
     def Exit(self):
184
     def Exit(self):
214
         pass        
185
         pass        
216
 #====================================  
187
 #====================================  
217
             
188
             
218
 class EnterParallelPark(State):
189
 class EnterParallelPark(State):
219
-    def __init__(self,FSM):
220
-        
190
+    def __init__(self,FSM):        
221
         super(EnterParallelPark, self).__init__(FSM)    
191
         super(EnterParallelPark, self).__init__(FSM)    
222
         
192
         
223
     def Enter(self):
193
     def Enter(self):
244
         self.FSM.stateLife += 1
214
         self.FSM.stateLife += 1
245
         if self.FSM.stateLife == 2:
215
         if self.FSM.stateLife == 2:
246
             self.FSM.owner.manager.cars_active.remove(self.FSM.owner)
216
             self.FSM.owner.manager.cars_active.remove(self.FSM.owner)
247
-        #self.FSM.ToTransition('toActivate')
248
-        
249
 
217
 
250
     def Exit(self):
218
     def Exit(self):
251
         pass
219
         pass
270
         set_height(self.FSM.owner)
238
         set_height(self.FSM.owner)
271
         delta_to_vect(self.FSM.owner)
239
         delta_to_vect(self.FSM.owner)
272
         apply_gas(self.FSM.owner)
240
         apply_gas(self.FSM.owner)
273
-        #print('target', self.FSM.owner.target.obj.worldPosition)
274
 
241
 
275
         #emergency exit
242
         #emergency exit
276
         if self.FSM.stateLife > 30 * 60:
243
         if self.FSM.stateLife > 30 * 60:
277
             self.FSM.ToTransition('toEnterParallelPark')
244
             self.FSM.ToTransition('toEnterParallelPark')
278
 
245
 
279
-        #print('doing NavigateToTarget')
280
-
281
-        #self.FSM.owner.obj.applyForce([6, 0, 0], True)
282
-
283
     def Exit(self):
246
     def Exit(self):
284
         pass        
247
         pass        
285
 
248
 
291
         
254
         
292
     def Enter(self):
255
     def Enter(self):
293
         self.FSM.stateLife = 1
256
         self.FSM.stateLife = 1
294
-        # self.FSM.owner.restorePhysics()
295
-        # self.FSM.owner.restoreDynamics()
296
-        # self.FSM.owner.worldPosition.z = 2
297
-        # self.FSM.curTarget = None
298
-        # self.FSM.last_target = None
299
-        # #self.FSM.path = None
300
-        # self.point = None
301
-        # self.last_point = self.FSM.owner.worldPosition.copy()
302
-        # self.last_pos = self.FSM.owner.worldPosition.copy()
303
-        # self.backup = 0
304
-        # self.lane_point = None
305
-        # self.last_lane_point = self.last_pos
306
-        # self.lane_position = 1.75
307
-        # self.pos_his = []
308
-        # self.max_speed = 5.0
309
-        # self.FSM.path = None
310
-        # print('physics resumed')
311
         super(Activate, self).Enter()        
257
         super(Activate, self).Enter()        
312
         
258
         
313
     def find_target(self):
259
     def find_target(self):
314
         pass
260
         pass
315
-        # if self.FSM.curTarget == None:
316
-        #     choices = self.FSM.owner['manager'].targets
317
-        #     if self.FSM.last_target in choices:
318
-        #         choices.remove(self.FSM.last_target)
319
-        #     if choices:    
320
-        #         self.FSM.curTarget = random.choice(choices)
321
-        #         self.FSM.path = self.FSM.owner['manager'].navmesh.findPath(self.FSM.owner.worldPosition, self.FSM.curTarget.worldPosition)
322
-        #         self.FSM.path.remove(self.FSM.path[0])
323
-        #         self.point = self.FSM.path[0]
324
-        #         vt = Vector([self.last_point.x - self.point.x, self.last_point.y - self.point.y, 0])
325
-        #         tv = vt.normalized()
326
-        #         #rotate 90 degrees
327
-        #         nv = Vector([-tv.y, tv.x, 0])
328
-        #         distance = 3.5
329
-        #         self.lane_point = self.point + self.lane_position * nv
330
-        #     else:
331
-        #         print('no fucking choices')
332
-        #     return False
333
-        # else:
334
-        #     return True  
335
 
261
 
336
     def drive_to_point(self):
262
     def drive_to_point(self):
337
         if self.FSM.path:
263
         if self.FSM.path:
414
             self.pos_his.append(self.FSM.owner.worldPosition.copy())
340
             self.pos_his.append(self.FSM.owner.worldPosition.copy())
415
             pos_his_len = len(self.pos_his)
341
             pos_his_len = len(self.pos_his)
416
             if pos_his_len > 200:
342
             if pos_his_len > 200:
417
-                #sum_ = abs(self.FSM.owner.worldPosition.x) + abs(self.pos_his[-1][0]) + abs(self.FSM.owner.worldPosition.y) + abs(self.pos_his[-1][1]) 
343
+                
418
                 sum_ = abs(self.FSM.owner.worldPosition.x - self.pos_his[0][0]) + abs(self.FSM.owner.worldPosition.y - self.pos_his[0][1])
344
                 sum_ = abs(self.FSM.owner.worldPosition.x - self.pos_his[0][0]) + abs(self.FSM.owner.worldPosition.y - self.pos_his[0][1])
419
                 #print(sum_, 'sum')
345
                 #print(sum_, 'sum')
420
                 if sum_ < .05:
346
                 if sum_ < .05:
426
     def Execute(self):
352
     def Execute(self):
427
         self.FSM.stateLife += 1
353
         self.FSM.stateLife += 1
428
 
354
 
429
-        #if self.find_target():
430
-            #self.drive_to_point()
431
-
432
-        #self.FSM.owner.linearVelocity.y = 0
433
-        #self.last_pos = self.FSM.owner.worldPosition.copy()
434
-        #self.FSM.owner['manager'].target_loc.worldPosition = self.lane_point
435
-
436
     def Exit(self):
355
     def Exit(self):
437
         pass
356
         pass
438
 
357
 

Loading…
Cancel
Save