1 from game_layers import MessageInstruction
2 from cocos.sprite import *
3 from cocos import euclid
4 from constants import CELL_SIZE
5 from models import Ping, Installer, AlgorithmFactory, DOS
6 import os
7
8
10
12 super(Tutorial, self).__init__()
13 self.curPrompt = 0
14 self.lvlNum = lvlNum
15
16 if lvlNum == 1:
17 self.t = L1Tutorial()
18 if lvlNum == 2:
19 self.t = L2Tutorial()
20
21 self.prompt_stats = self.t.prompt_stats
22 self.prompts = self.t.prompts
23 self.prompt_visual_aids = self.t.prompt_visual_aids
24 self.prompt_visual_aid_stats = self.t.prompt_visual_aid_stats
25 self.game_states = self.t.game_states
26 self.controller = controller
27 self.message = None
28 self.visual_aids = None
29 self.cur_vertex_highlight = None
30
54
61
64
66
67 visual_aids = []
68 i = 0
69 for image in self.prompt_visual_aids[self.curPrompt]:
70 visual_aids.append(
71 TutorialVisualAid(self.controller, image, self.prompt_visual_aid_stats[
72 self.curPrompt][i][0], self.prompt_visual_aid_stats[self.curPrompt][i][1])
73 )
74 i += 1
75
76 return visual_aids
77
83
85
86
87 curState = self.get_cur_state()
88 if troop_type == curState[1] and curState[0] == "click_on_move":
89 if (curState[2] == -1) or (int(curState[2]) == int(destID)):
90 self.next_prompt()
91
98
99
104
105
106
108 if self.curPrompt < len(self.game_states):
109 return self.game_states[self.curPrompt]
110 return [None]
111
115
118
120 - def __init__(self, layer, image, x, y):
126
129
131 - def __init__(self, vertex_id, controller, is_active=True):
142
145
146
148
150
151 self.prompts = [
152 '''To get started, first build Ping troops. Ping lets you to locate the enemy. You can't see them now but they're there!\n1. Click the server \n2. Click Ping'''
153 , '''Servers can create troops called Installers that create buildings.\n1. Click the server \n2. Click the Installer'''
154 , '''Build the building by moving the Installer to a new location.\n1. Left click your Installer \n2. Right click the location you want to build on.'''
155 , '''Let's build an algorithm factory, it will allow you to build attack.\n1. Click the Installer\n2. Click the Algorithm Factory'''
156 , '''Now you need troops that allows you to attack an enemy once you see it. Build 2 DOS troops.\n1. Click the Algorithm Factory\n2. Click the DOS troop'''
157 , '''Now you need troops that allows you to attack an enemy once you see it. Build 2 DOS troops.\n1. Click the Algorithm Factory\n2. Click the DOS troop'''
158 , '''Remember Ping, now we will use it to find the enemy. Move a ping unit to the highlighted vertex.\n1. Left click Ping \n2. Right click the highlighted location'''
159 , '''Let's actually use the Ping troop to see the enemy. \n1. Click Ping \n2. Click the attack button.'''
160 , '''Now move your DOS troop to the location of the enemy and prepare for attack'''
161 , '''You can see the enemy now, lets attack em!\n1. Click DOS and then the attack button\n2.Click on an enemy troop'''
162
163 ]
164
165 self.prompt_visual_aids = [
166 [os.path.join("images", "tutorial", "instruction1.png")],
167 [os.path.join("images", "tutorial", "instruction2.png")],
168 [os.path.join("images", "tutorial", "instruction3.png")],
169 [os.path.join("images", "tutorial", "instruction4.png")],
170 [os.path.join("images", "tutorial", "instruction5.png")],
171 [os.path.join("images", "tutorial", "instruction6.png")],
172 [os.path.join("images", "tutorial", "instruction7.png")],
173 [os.path.join("images", "tutorial", "instruction8.png")]
174 ]
175
176 self.game_states = [["on_enter", None],
177 ["player_add_unit", "Installer"],
178 ["click_on_move", "Installer", -1],
179 ["player_add_unit", "AlgorithmFactory"],
180 ["player_add_unit", "DOS"],
181 ["click_on_move", "Ping", 4],
182 ["click_on_action", "Ping"],
183 ["click_on_move", "DOS", 5],
184 ["player_unit_attack", "DOS"]]
185
186 self.prompt_stats = [(400, 450, 700, 300, 22),
187 (350, 450, 600, 300, 22),
188 (350, 450, 600, 300, 22),
189 (400, 450, 700, 300, 22),
190 (350, 450, 600, 300, 22),
191 (350, 450, 600, 300, 22),
192 (300, 450, 500, 300, 22),
193 (300, 450, 500, 300, 22),
194 (300, 450, 500, 300, 22),
195 (300, 450, 500, 300, 22),
196 (300, 450, 500, 300, 22),
197 (300, 450, 500, 300, 22)]
198
199 self.prompt_visual_aid_stats = [[(180, 570)],
200 [(180, 140)],
201 [(700, 560)],
202 [(180, 570)],
203 [(180, 570)],
204 [(180, 570)],
205 [(180, 140)],
206 [(600, 560)],
207 [(180, 600)]]
208
213