-
Notifications
You must be signed in to change notification settings - Fork 0
/
TileDecorator.py
92 lines (66 loc) · 2.37 KB
/
TileDecorator.py
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
from Tile import *
class TileDecorator(Tile):
def __init__(self, x, y, component, state_string, state_dic):
super(TileDecorator, self).__init__(x, y)
self.component = component
self.state_dic = state_dic
self.state = state_dic[state_string]
def interact(self, character):
self.state.interact(self, character)
class HoleDecorator(TileDecorator):
def __init__(self, x, y, component, state_string, state_dic, maze_1, maze_2):
super(HoleDecorator, self).__init__(x, y, component, state_string, state_dic)
self.maze_1 = maze_1
self.maze_2 = maze_2
def paint(self, maze):
self.component.paint(maze)
image = self.state.getImage()
maze.paintTileDecorator(image, self.cel_x, self.cel_y)
def open(self):
self.state = self.state_dic['opened']
def enter(self):
self.maze_1.goTo(self.maze_2)
def isHoleTile(self):
return True
def isOpened(self):
return self.state.isOpened()
def isClosed(self):
return self.state.isClosed()
class KeyDecorator(TileDecorator):
def paint(self, maze):
self.component.paint(maze)
image = self.state.getImage()
maze.paintKeyDecorator(image, self.cel_x, self.cel_y)
def obtain(self):
self.state = self.state_dic['key_obtained']
def isKeyTile(self):
return True
class HeartDecorator(TileDecorator):
def paint(self, maze):
self.component.paint(maze)
image = self.state.getImage()
maze.paintHeartDecorator(image, self.cel_x, self.cel_y)
def obtain(self):
self.state = self.state_dic['heart_obtained']
def isHeartTile(self):
return True
class MedalDecorator(TileDecorator):
def paint(self, maze):
self.component.paint(maze)
image = self.state.getImage()
maze.paintMedalDecorator(image, self.cel_x, self.cel_y)
class RedMedalDecorator(MedalDecorator):
def obtain(self):
self.state = self.state_dic['obtained']
def isRedMedalTile(self):
return True
class BlueMedalDecorator(MedalDecorator):
def obtain(self):
self.state = self.state_dic['obtained']
def isBlueMedalTile(self):
return True
class GoldMedalDecorator(MedalDecorator):
def obtain(self):
self.state = self.state_dic['obtained']
def isGoldMedalTile(self):
return True