3 import com
.adobe
.utils
.IntUtil
;
4 import flash
.display
.*;
6 import flash
.sampler
.NewObjectSample;
8 import spark
.components
.Application
;
9 import mx
.core
.UIComponent;
10 import org
.sevenchan
.dongs
.Creature
;
11 import org
.sevenchan
.dongs
.creature
.*;
12 import org
.sevenchan
.dongs
.enchantment
.events
.CombatStartEvent
;
13 import org
.sevenchan
.dongs
.Item
;
14 import org
.sevenchan
.dongs
.Screen;
15 import org
.sevenchan
.dongs
.Town
;
16 import org
.sevenchan
.dongs
.ui
.*;
17 import org
.sevenchan
.dongs
.screens
.*;
22 [Frame
(factoryClass
= "Preloader", backgroundColor
= 0x666666, frames
= 10)]
23 [SWF
(width
= 800, height
= 600, frameRate
= 60 , backgroundColor
= "#666666")]
24 public class AdventureController
extends Sprite
27 private const default_bg_color
:uint = 0x333333;
28 private var currentBGColor
:uint = default_bg_color
;
29 public var bodyPartsDialog
:org
.sevenchan
.dongs
.frmBodyPartsPool
= new org
.sevenchan
.dongs
.frmBodyPartsPool
;
30 private var bgshape
:Sprite;
32 private var currentScreen
:Screen;
33 private var combatScreen
:Screen;
34 private var btnNewGame
:SexButton
;
35 private var btnLoadSaveGame
:SexButton
;
36 private var btnExportGame
:SexButton
;
37 private var btnSelectPerk
:SexButton
;
38 private var btnDebugMenu
:SexButton
;
39 private var btnAppearance
:SexButton
;
40 private var btnAction
:Array;
42 private var pnlMain
:SexPanel
;
43 private var pnlStats
:SexPanel
;
45 private var statXP
:Statistic
;
46 private var statStrength
:Statistic
;
47 private var statSpeed
:Statistic
;
48 private var statIntellect
:Statistic
;
49 private var statSensitivity
:Statistic
;
50 private var statLust
:Statistic
;
52 private var statMana
:Statistic
;
53 public var statHP
:Statistic
;
54 private var statGold
:TextField;
56 public var player
:Player
;
58 public static var screenQueue
:Queue
= new Queue
();
60 public function AdventureController
(appl
:Main
):void
64 player
= new Player
(this);
66 else addEventListener
(Event.ADDED_TO_STAGE
, init
);
69 public static function init
(app
:Main
):void {
70 var ui
:UIComponent = new UIComponent();
71 ui
.addChild
(new AdventureController
(app
));
75 private function init
(e
:Event = null):void
79 removeEventListener
(Event.ADDED_TO_STAGE
, init
);
83 var toprow
:Number = 600 - 549;
86 //stage.opaqueBackground = 0x666666;
88 var txtHeader
:TextField = new TextField();
89 var tf
:TextFormat = new TextFormat();
92 txtHeader
.htmlText
= "ADVENTURE OF THE SEVEN LEAVES <b>TEST BUILD</b>";
93 txtHeader
.setTextFormat
(tf
);
94 txtHeader
.autoSize
= "left";
100 btnNewGame
= addButton
("New Game", 100, y
, toprow
); y
+= 129.2; btnNewGame
.addEventListener
(MouseEvent.CLICK
, onNewGame
);
101 btnLoadSaveGame
= addButton
("Load Game", 100, y
, toprow
); y
+= 129.2; btnLoadSaveGame
.addEventListener
(MouseEvent.CLICK
, onLoadOrSave
);
102 btnSelectPerk
= addButton
("Select Perk", 100, y
, toprow
); y
+= 129.2; //btnNewGame.addEventListener(MouseEvent.CLICK, onSelectPerk);
103 btnExportGame
= addButton
("Export Game", 100, y
, toprow
); y
+= 129.2; //btnNewGame.addEventListener(MouseEvent.CLICK, onExport);
104 btnDebugMenu
= addButton
("Debug Menu", 100, y
, toprow
); y
+= 129.2; btnDebugMenu
.addEventListener
(MouseEvent.CLICK
, onDebugMenu
);
105 btnAppearance
= addButton
("Appearance", 100, y
, toprow
); btnAppearance
.addEventListener
(MouseEvent.CLICK
, onAppearance
);
108 pnlMain
= addPanel
("", 464.5, 618.5, 167.75, 56.75);
110 pnlStats
= addPanel
("", 464.5, 144.9, 15.75, 56.75);
112 // Second row of buttons
113 btnAction
= new Array();
114 for (var i
:int = 0; i
< 12;i
++) {
115 var btn
:SexButton
= addButton
((i
+ 1).toString
(), 100, 16 + ((i
% 6) * 129.2), 561 + (Math.round
(i
/ 12) * 32));
117 btn
.addEventListener
(MouseEvent.CLICK
, onActionClick
);
120 setScreen
(new StartupScreen
());
123 public function onDebugMenu
(lolno
:MouseEvent):void {
124 setScreen
(new DebugScreen
());
127 public function showBodyPartSelector
(show
:Boolean):void {
128 app
.showBodyParts
(show
);
130 updateScreen
(currentScreen
);
133 public function setCheatMode
(val
:Boolean):void {
134 statHP
.showCheatButtons
(val
);
135 statXP
.showCheatButtons
(val
);
136 statIntellect
.showCheatButtons
(val
);
137 statLust
.showCheatButtons
(val
);
138 statMana
.showCheatButtons
(val
);
139 statSensitivity
.showCheatButtons
(val
);
140 statSpeed
.showCheatButtons
(val
);
141 statStrength
.showCheatButtons
(val
);
144 private function onAppearance
(e
:MouseEvent):void {
145 setScreen
(new AppearanceScreen
());
148 private function onNewGame
(e
:MouseEvent):void {
149 player
= new Player
(this);
150 player
.setMain
(this);
151 app
.bodyparts
.init
(player
);
152 setScreen
(new NewGameScreen
());
155 private function onLoadOrSave
(e
:MouseEvent):void {
156 if (!currentScreen
.loadOrSaveButton
) {
157 player
= new Player
(this);
158 player
.setMain
(this);
165 public function onPlayerLoaded
():void {
167 setScreen
(player
.currentTown
);
170 public function addToStatsPanel
(stat
:Statistic
):void {
171 pnlStats
.addToStack
(stat
);
172 pnlStats
.arrangeStack
();
175 public function remFromStatsPanel
(stat
:Statistic
):void {
176 pnlStats
.delFromStack
(stat
);
177 pnlStats
.arrangeStack
();
180 public function setupStatsPanel
():void {
181 pnlStats
.stackMode
(); // Remove textField.
182 pnlStats
.addToStack
(new StackHeader
("STATS"));
183 statXP
= new Statistic
("Experience", "How far you are from levelling up",true,setXP
);
184 pnlStats
.addToStack
(statXP
);
185 statStrength
= new Statistic
("Strength", "How much power your attacks will have.",false,setStrength
);
186 pnlStats
.addToStack
(statStrength
);
187 statSpeed
= new Statistic
("Speed", "How fast you are; Affects dodging and catching opponents.",false,null);
188 pnlStats
.addToStack
(statSpeed
);
189 statIntellect
= new Statistic
("Intellect", "Perceptiveness. Allows you to sense impending danger and figure out puzzles easier.", false, null);
190 pnlStats
.addToStack
(statIntellect
);
191 statSensitivity
= new Statistic
("Sensitivity", "The more sensitive you are, the faster your lust rises. However, lack of sensation means you cannot masturbate.",false,null);
192 pnlStats
.addToStack
(statSensitivity
);
193 statLust
= new Statistic
("Lust", "How horny you are right now.",false,null);
194 pnlStats
.addToStack
(statLust
);
196 pnlStats
.addToStack
(new StackHeader
("COMBAT"));
197 statHP
= new Statistic
("HP", "Health left.",false,null);
198 pnlStats
.addToStack
(statHP
);
199 statMana
= new Statistic
("Mana", "Magic stuff",false,null);
200 pnlStats
.addToStack
(statMana
);
202 pnlStats
.addToStack
(new StackHeader
("GOLD"));
203 statGold
= new TextField();
204 pnlStats
.addToStack
(statGold
);
205 var tf
:TextFormat = new TextFormat();
209 tf
.align
= TextFormatAlign.CENTER
;
210 statGold
.setTextFormat
(tf
);
211 statGold
.defaultTextFormat
= tf
;
213 pnlStats
.arrangeStack
();
218 private function setGold
(value
:int):void { player
.gold
= value
; }
219 private function setHP
(value
:int):void { player
.HP
= value
; }
220 private function setIntellect
(value
:int):void { player
.intellect
= value
; }
221 private function setLust
(value
:int):void { player
.lust
= value
; }
222 private function setMana
(value
:int):void { player
.mana
= value
; }
223 private function setSensitivity
(value
:int):void { player
.sensitivity
= value
; }
224 private function setSpeed
(value
:int):void { player
.speed
= value
; }
225 private function setStrength
(value
:int):void { player
.strength
= value
; }
226 private function setXP
(value
:int):void { player
.XP
= value
; }
228 private function setScreen
(screen
:Screen):void {
229 //trace("setscreen ",screen);
232 if (player
!= null) {
233 if(combatScreen
==null)
234 screen
= player
.currentTown
;
236 screen
= combatScreen
;
239 screen
= new StartupScreen
();
241 currentScreen
= screen
;
242 currentScreen
.setMain
(this);
243 currentScreen
.processButtonPress
( -1);
246 private function onActionClick
(e
:MouseEvent):void {
247 var clicked
:SexButton
= e
.target
as SexButton
;
248 for (var i
:int = 0; i
< 12; i
++) {
249 if (clicked
== btnAction
[i
]) {
250 var done
:Boolean = currentScreen
.processButtonPress
(i
);
251 //trace(currentScreen,done);
253 setScreen
(AdventureController
.screenQueue
.read
());
260 public function updateScreen
(screen
:Screen):void {
261 pnlMain
.visible
= visible
;
262 pnlStats
.visible
= visible
;
263 var btns
:Array = screen
.getButtons
();
264 for (var i
:int = 0; i
< 12; i
++) {
265 var btn
:SexButton
= (btnAction
[i
] as SexButton
);
266 btn
.visible
= (btns
[i
] != "") && visible
;
267 btn
.setText
(btns
[i
]);
269 this.btnAppearance
.visible
= screen
.appearanceButton
&& visible
;
270 this.btnDebugMenu
.visible
= screen
.debugMenuButton
&& visible
&& player
!=null;
271 this.btnExportGame
.visible
= screen
.exportGameButton
&& visible
;
272 this.btnLoadSaveGame
.setText
((screen
.loadOrSaveButton
)?"Save Game":"Load Game");
273 btnLoadSaveGame
.visible
= visible
;
274 this.btnNewGame
.visible
= screen
.newGameButton
&& visible
;
275 this.btnSelectPerk
.visible
= screen
.selectPerkButton
&& visible
;
277 this.pnlMain
.text
= screen
.getScreenText
();
280 public function refreshStats
():void {
281 if (player
.level
== 0) {
282 player
.levelUp
(true);
284 statXP
.setMaxAndValue
(player
.maxXP
, player
.XP
, false);
285 statStrength
.setMaxAndValue
(100, player
.strength
, false);
286 statSpeed
.setMaxAndValue
(100, player
.speed
, false);
287 statIntellect
.setMaxAndValue
(100, player
.intellect
, false);
288 statSensitivity
.setMaxAndValue
(100, player
.sensitivity
, false);
289 statLust
.setMaxAndValue
(100, player
.lust
, false);
291 statHP
.setMaxAndValue
(player
.maxHP
, player
.HP
, false);
292 statMana
.setMaxAndValue
(100, player
.mana
, false);
293 statGold
.text
= player
.gold
+"";
296 private function addButton
(label
:String, size
:Number, x
:Number, y
:Number):SexButton
{
297 var btn
:SexButton
= new SexButton
(size
, label
);
300 btn
.y
= y
- btn
.height
;
304 private function addPanel
(text
:String,h
:Number, w
:Number, x
:Number, y
:Number):SexPanel
{
305 var btn
:SexPanel
= new SexPanel
(text
);
313 private function initBG
():void
315 bgshape
= new Sprite();
316 bgshape
.graphics
.clear
();
317 bgshape
.graphics
.beginFill
(currentBGColor
);
318 bgshape
.graphics
.drawRect
(0,0,stage
.stageWidth
, stage
.stageHeight
);
319 addChildAt
(bgshape
, 0);
320 stage
.addEventListener
(Event.RESIZE
, resizeBGWithStage
);
322 private function resizeBGWithStage
(e
:Event):void
325 bgshape
.width
= stage
.stageWidth
;
326 bgshape
.height
= stage
.stageHeight
;
330 public function showInventory
(item
:Item
=null):void {
331 setScreen
(new InventoryScreen
(item
));
334 public function startCombat
(oldScreen
:Screen, combatant
:Creature
, playerInitiated
:Boolean = false):void {
336 combatant
.notifyEnchantments
(new CombatStartEvent
(player
));
337 player
.notifyEnchantments
(new CombatStartEvent
(combatant
));
338 combatScreen
= new CombatScreen
(oldScreen
, combatant
, playerInitiated
);
339 setScreen
(combatScreen
);
340 currentBGColor
= 0x330000;
344 public function endCombat
(oldScreen
:Screen):void {
347 //setScreen(AdventureController.screenQueue.read());
348 currentBGColor
= default_bg_color
;
352 public function setTown
(t
:Town
):void {
353 player
.currentTown
= t
;