1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #include "tsage/blue_force/blueforce_scenes7.h"
24 #include "tsage/globals.h"
25 #include "tsage/scenes.h"
26 #include "tsage/tsage.h"
27 #include "tsage/staticres.h"
28 
29 namespace TsAGE {
30 
31 namespace BlueForce {
32 
33 /*--------------------------------------------------------------------------
34  * Scene 710 - Beach
35  *
36  *--------------------------------------------------------------------------*/
37 
signal()38 void Scene710::Timer1::signal() {
39 	PaletteRotation *rotation = BF_GLOBALS._scenePalette.addRotation(136, 138, -1);
40 	rotation->setDelay(20);
41 	rotation = BF_GLOBALS._scenePalette.addRotation(146, 148, -1);
42 	rotation->setDelay(30);
43 	rotation = BF_GLOBALS._scenePalette.addRotation(187, 191, -1);
44 	rotation->setDelay(35);
45 	rotation = BF_GLOBALS._scenePalette.addRotation(245, 246, -1);
46 	rotation->setDelay(20);
47 	remove();
48 }
49 
signal()50 void Scene710::Action1::signal() {
51 	Scene710 *scene = (Scene710 *)BF_GLOBALS._sceneManager._scene;
52 
53 	switch (_actionIndex++) {
54 	case 0:
55 		BF_GLOBALS._player.disableControl();
56 		_state = 7104;
57 		if (BF_INVENTORY.getObjectScene(INV_CRATE1) == 1)
58 			_state = 7105;
59 		setDelay(3);
60 		break;
61 	case 1: {
62 		ADD_MOVER(BF_GLOBALS._player, scene->_laura._position.x + 8, scene->_laura._position.y + 8);
63 		break;
64 		}
65 	case 2:
66 		BF_GLOBALS._player._strip = 2;
67 		scene->_stripManager.start(_state, this);
68 		break;
69 	case 3:
70 		if (_state != 7105)
71 			BF_GLOBALS._player.enableControl();
72 		else {
73 			BF_GLOBALS._player.disableControl();
74 			scene->_sceneMode = 7106;
75 			scene->setAction(&scene->_sequenceManager1, scene, 7106, &BF_GLOBALS._player, &scene->_laura, &scene->_kid, &scene->_dog, NULL);
76 		}
77 		if (_state < 7104) {
78 			_state++;
79 			if ((_state == 7104) && (BF_INVENTORY.getObjectScene(INV_CRATE1) == 1))
80 					_state = 7105;
81 		}
82 		remove();
83 		break;
84 	default:
85 		break;
86 	}
87 }
88 
89 // Laura
startAction(CursorType action,Event & event)90 bool Scene710::Object3::startAction(CursorType action, Event &event) {
91 	Scene710 *scene = (Scene710 *)BF_GLOBALS._sceneManager._scene;
92 
93 	if (action == CURSOR_TALK) {
94 		BF_GLOBALS._player.setAction(&scene->_action1);
95 		return true;
96 	} else
97 		return NamedObject::startAction(action, event);
98 }
99 
startAction(CursorType action,Event & event)100 bool Scene710::Object4::startAction(CursorType action, Event &event) {
101 	Scene710 *scene = (Scene710 *)BF_GLOBALS._sceneManager._scene;
102 
103 	if ((action == CURSOR_LOOK) && (scene->_kid._position.x < 0)) {
104 		SceneItem::display2(710, 13);
105 		return true;
106 	} else
107 		return NamedObject::startAction(action, event);
108 }
109 
110 //Stick
startAction(CursorType action,Event & event)111 bool Scene710::Object5::startAction(CursorType action, Event &event) {
112 	Scene710 *scene = (Scene710 *)BF_GLOBALS._sceneManager._scene;
113 
114 	switch (action) {
115 	case CURSOR_LOOK:
116 		if (scene->_stickThrowCount <= 2)
117 			return NamedObject::startAction(action, event);
118 		else {
119 			SceneItem::display2(710, 3);
120 			scene->_watchCrate = true;
121 			return true;
122 		}
123 	case CURSOR_USE:
124 		if ((scene->_kid._position.x < 0) && (scene->_dogLying)) {
125 			scene->_stickThrowCount++;
126 			if (!scene->_watchCrate) {
127 				BF_GLOBALS._player.disableControl();
128 				scene->_dogLying = false;
129 				scene->_sceneMode = 7105;
130 				scene->setAction(&scene->_sequenceManager1, scene, 7105, &BF_GLOBALS._player, &scene->_stick, &scene->_dog, NULL);
131 			} else {
132 				BF_GLOBALS._player.disableControl();
133 				scene->_sceneMode = 7101;
134 				scene->setAction(&scene->_sequenceManager1, scene, 7101, &BF_GLOBALS._player, &scene->_dog, &scene->_stick, NULL);
135 			}
136 			return true;
137 		}
138 		// fall through
139 	default:
140 		return NamedObject::startAction(action, event);
141 	}
142 }
143 
postInit(SceneObjectList * OwnerList)144 void Scene710::postInit(SceneObjectList *OwnerList) {
145 	SceneExt::postInit();
146 	loadScene(710);
147 	_sceneBounds.moveTo(320, 0);
148 
149 	BF_GLOBALS._sound1.fadeSound(14);
150 	_soundExt1.fadeSound(48);
151 
152 	BF_GLOBALS._player.postInit();
153 	BF_GLOBALS._player.hide();
154 	BF_GLOBALS._player._moveDiff = Common::Point(4, 2);
155 	BF_GLOBALS._player.disableControl();
156 	if (BF_GLOBALS._dayNumber == 0)
157 		BF_GLOBALS._dayNumber = 1;
158 	_stripManager.addSpeaker(&_jakeSpeaker);
159 	_stripManager.addSpeaker(&_skipSpeaker);
160 	_stripManager.addSpeaker(&_lauraSpeaker);
161 	_stripManager.addSpeaker(&_gameTextSpeaker);
162 
163 	_kid.postInit();
164 	_kid._moveDiff = Common::Point(4, 2);
165 	_laura.postInit();
166 	_laura._moveDiff = Common::Point(4, 2);
167 	_dog.postInit();
168 	_dog._moveDiff = Common::Point(4, 2);
169 	_stick.postInit();
170 	_stick.setVisage(710);
171 	_stick.setStrip(2);
172 	_stick.animate(ANIM_MODE_2, NULL);
173 	_stick.setPosition(Common::Point(650, 160));
174 	_stick._moveDiff.x = 16;
175 	_stick.setDetails(710, 4, -1, -1, 1, (SceneItem *)NULL);
176 	_laura.setDetails(710, 2, -1, -1, 1, (SceneItem *)NULL);
177 	_kid.setDetails(710, 6, -1, -1, 1, (SceneItem *)NULL);
178 	_dog.setDetails(710, 0, -1, -1, 1, (SceneItem *)NULL);
179 
180 	_item1.setDetails(Rect(555, 68, 583, 101), 710, 7,  23, -1, 1, NULL);
181 	_item2.setDetails(Rect(583, 46, 611,  78), 710, 7,  23, -1, 1, NULL);
182 	_item3.setDetails(Rect(611, 24, 639,  56), 710, 7,  23, -1, 1, NULL);
183 	_item6.setDetails(1, 710, 9,  1,  -1, 1);
184 	_item4.setDetails(2, 710, 8,  14, -1, 1);
185 	_item5.setDetails(3, 710, 10, 16, -1, 1);
186 	_item8.setDetails(Rect(222, 18, 249,  42), 710, 12, 18, -1, 1, NULL);
187 	_item7.setDetails(Rect(0,    0, 640,  52), 710, 11, 17, -1, 1, NULL);
188 	_item9.setDetails(Rect(0,    0, 640, 128), 710,  5, 15, -1, 1, NULL);
189 
190 	_stickThrowCount = 0;
191 	_dogLying = _watchCrate = _throwStick = false;
192 	_action1._state = 7100;
193 	_timer1.set(2, NULL);
194 	_sceneMode = 7100;
195 	setAction(&_sequenceManager1, this, 7100, &BF_GLOBALS._player, &_laura, &_kid, &_dog, NULL);
196 }
197 
signal()198 void Scene710::signal() {
199 	switch (_sceneMode) {
200 	case 0:
201 		BF_GLOBALS._player.enableControl();
202 		break;
203 	case 7100:
204 		BF_GLOBALS._player.enableControl();
205 		_sceneMode = 7102;
206 		setAction(&_sequenceManager1, this, 7102, &_dog, NULL);
207 		break;
208 	case 7101:
209 		// Pick up crate part
210 		BF_GLOBALS._player.enableControl();
211 		BF_INVENTORY.setObjectScene(INV_CRATE1, 1);
212 		_stick.remove();
213 		BF_GLOBALS._walkRegions.enableRegion(2);
214 		break;
215 	case 7102:
216 		_stick.setPosition(Common::Point(100, 122));
217 		_stick.animate(ANIM_MODE_NONE, NULL);
218 		_stick._strip = 2;
219 		if (_stickThrowCount <= 2)
220 			_stick._frame = 2;
221 		else {
222 			if (_stickThrowCount == 3) {
223 				BF_GLOBALS._player.disableControl();
224 				_sceneMode = 0;
225 				_stripManager.start(7108, this);
226 			}
227 			_stick._frame = 1;
228 		}
229 		_dogLying = true;
230 		BF_GLOBALS._walkRegions.disableRegion(2);
231 		if ((_throwStick) && (_sceneMode != 0))
232 			BF_GLOBALS._player.enableControl();
233 		break;
234 	case 7103:
235 		if (BF_GLOBALS._player._position.x > 179) {
236 			_sceneMode = 7102;
237 			setAction(&_sequenceManager1, this, 7102, &_dog, NULL);
238 		} else {
239 			_sceneMode = 7104;
240 			setAction(&_sequenceManager3, this, 7104, &_kid, NULL);
241 		}
242 		break;
243 	case 7105:
244 		_throwStick = true;
245 		// fall through
246 	case 7104:
247 		_sceneMode = 7102;
248 		setAction(&_sequenceManager1, this, 7102, &_dog, NULL);
249 		BF_GLOBALS._walkRegions.enableRegion(2);
250 		break;
251 	case 7106:
252 		BF_GLOBALS._sound1.fadeOut2(NULL);
253 		BF_GLOBALS._sceneManager.changeScene(270);
254 		break;
255 	default:
256 		break;
257 	}
258 }
259 
dispatch()260 void Scene710::dispatch() {
261 	if ((_kid._position.x > 0) && (_dogLying) && (_sceneMode != 7106)) {
262 		_dogLying = false;
263 		_sceneMode = 7103;
264 		setAction(&_sequenceManager1, this, 7103, &_kid, &_stick, &_dog, NULL);
265 	}
266 	SceneExt::dispatch();
267 }
268 
synchronize(Serializer & s)269 void Scene710::synchronize(Serializer &s) {
270 	SceneExt::synchronize(s);
271 	s.syncAsSint16LE(_dogLying);
272 	s.syncAsSint16LE(_stickThrowCount);
273 	s.syncAsSint16LE(_watchCrate);
274 	s.syncAsSint16LE(_throwStick);
275 }
276 
277 
278 } // End of namespace BlueForce
279 } // End of namespace TsAGE
280