-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodes.py
More file actions
65 lines (54 loc) · 1.68 KB
/
Copy pathmodes.py
File metadata and controls
65 lines (54 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from constants import *
class ModeController(object):
def __init__(self, entity):
self.timer = 0
self.time = 0
self.mainmode = MainMode()
self.current = self.mainmode.mode
self.entity = entity
def update(self, dt):
self.mainmode.update(dt)
if self.current is FREIGHT:
self.timer += dt
if self.timer >= self.time:
self.time = 0
self.entity.normalMode()
self.current = self.mainmode.mode
elif self.current in [SCATTER, CHASE]:
self.current = self.mainmode.mode
if self.current is SPAWN:
if self.entity.node == self.entity.spawnNode:
self.entity.normalMode()
self.current = self.mainmode.mode
def setSpawnMode(self):
if self.current is FREIGHT:
self.current = SPAWN
def setFreightMode(self):
if self.current in [SCATTER, CHASE]:
self.timer = 0
self.time = 7
self.current = FREIGHT
#print('Freight')
elif self.current is FREIGHT:
self.timer = 0
class MainMode(object):
def __init__(self):
self.timer = 0
self.scatter()
def update(self, dt):
self.timer += dt
if self.timer >= self.time:
if self.mode is SCATTER:
self.chase()
elif self.mode is CHASE:
self.scatter()
def scatter(self):
self.mode = SCATTER
self.time = 7
self.timer = 0
#print('Scatter')
def chase(self):
self.mode = CHASE
self.time = 20
self.timer = 0
#print('Chase')