3 import flash
.display
.*;
6 import mx
.core
.UIComponent;
7 import org
.sevenchan
.dongs
.Creature
;
8 import org
.sevenchan
.dongs
.creature
.*;
9 import org
.sevenchan
.dongs
.enchantment
.events
.CombatStartEvent
;
10 import org
.sevenchan
.dongs
.enchantment
.events
.ScreenChangedEvent
;
11 import org
.sevenchan
.dongs
.Item
;
12 import org
.sevenchan
.dongs
.Screen;
13 import org
.sevenchan
.dongs
.screens
.*;
14 import org
.sevenchan
.dongs
.Town
;
15 import org
.sevenchan
.dongs
.ui
.*;
20 [Frame
(factoryClass
="Preloader",backgroundColor
=0x666666,frames
=10)]
21 [SWF
(width
=800,height
=600,frameRate
=60,backgroundColor
="#666666")]
23 public class AdventureController
extends Sprite
26 private const default_bg_color
:uint = 0x333333;
27 private var currentBGColor
:uint = default_bg_color
;
28 public var bodyPartsDialog
:org
.sevenchan
.dongs
.frmBodyPartsPool
= new org
.sevenchan
.dongs
.frmBodyPartsPool
;
29 private var bgshape
:Sprite;
31 private var currentScreen
:Screen;
32 private var combatScreen
:Screen;
33 private var btnNewGame
:SexButton
;
34 private var btnLoadSaveGame
:SexButton
;
35 private var btnExportGame
:SexButton
;
36 private var btnImportGame
:SexButton
;
37 private var btnDebugMenu
:SexButton
;
38 private var btnAppearance
:SexButton
;
39 private var btnAction
:Array;
41 private var txtInput
:SexText
;
43 private var pnlMain
:SexPanel
;
44 private var pnlStats
:SexPanel
;
46 private var statXP
:Statistic
;
47 private var statStrength
:Statistic
;
48 private var statSpeed
:Statistic
;
49 private var statIntellect
:Statistic
;
50 private var statSensitivity
:Statistic
;
51 private var statLust
:Statistic
;
53 private var statMana
:Statistic
;
54 public var statHP
:Statistic
;
55 private var statGold
:TextField;
57 private var statsAreSetUp
:Boolean = false;
59 public var player
:Player
;
61 public static var screenQueue
:Queue
= new Queue
();
63 public var currentHeight
:Number = 600;
64 public var currentWidth
:Number = 800;
65 public var currentMeasuredHeight
:Number = 1; //idfk
66 public var currentMeasuredWidth
:Number = 1; // idfk
68 public function AdventureController
(appl
:Main
):void
72 player
= new Player
(this);
76 addEventListener
(Event.ADDED_TO_STAGE
, init
);
79 public static function init
(app
:Main
):void
81 var ui
:UIComponent = new UIComponent();
82 ui
.addChild
(new AdventureController
(app
));
86 private function init
(e
:Event = null):void
90 removeEventListener
(Event.ADDED_TO_STAGE
, init
);
94 var toprow
:Number = 600 - 549;
97 //stage.opaqueBackground = 0x666666;
99 var txtHeader
:TextField = new TextField();
100 var tf
:TextFormat = new TextFormat();
103 txtHeader
.htmlText
= "ADVENTURE OF THE SEVEN LEAVES <b>RELEASE 28</b>";
104 txtHeader
.setTextFormat
(tf
);
105 txtHeader
.autoSize
= "left";
110 // Top row of buttons
111 btnNewGame
= addButton
("New Game", 100, y
, toprow
);
113 btnNewGame
.addEventListener
(MouseEvent.CLICK
, onNewGame
);
114 btnLoadSaveGame
= addButton
("Load Game", 100, y
, toprow
);
116 btnLoadSaveGame
.addEventListener
(MouseEvent.CLICK
, onLoadOrSave
);
117 btnImportGame
= addButton
("Import Game", 100, y
, toprow
);
119 btnImportGame
.addEventListener
(MouseEvent.CLICK
, onImport
);
120 btnExportGame
= addButton
("Export Game", 100, y
, toprow
);
122 btnExportGame
.addEventListener
(MouseEvent.CLICK
, onExport
);
123 btnDebugMenu
= addButton
("Debug Menu", 100, y
, toprow
);
125 btnDebugMenu
.addEventListener
(MouseEvent.CLICK
, onDebugMenu
);
126 btnAppearance
= addButton
("Appearance", 100, y
, toprow
);
127 btnAppearance
.addEventListener
(MouseEvent.CLICK
, onAppearance
);
130 pnlMain
= addPanel
("", 464.5, 618.5, 167.75, 56.75);
131 pnlStats
= addPanel
("", 464.5, 144.9, 15.75, 56.75);
133 // Second row of buttons
134 btnAction
= new Array();
135 for (var i
:int = 0; i
< 12; i
++)
137 var btn
:SexButton
= addButton
((i
+ 1).toString
(), 100, 16 + ((i
% 6) * 129.2), 561 + (Math.round
(i
/ 12) * 32));
139 btn
.addEventListener
(MouseEvent.CLICK
, onActionClick
);
142 txtInput
= addTextBox
("", 100, 0, 0);
143 txtInput
.visible
= false;
145 setScreen
(new StartupScreen
());
148 public function onDebugMenu
(lolno
:MouseEvent):void
150 setScreen
(new DebugScreen
());
153 public function showBodyPartSelector
(show
:Boolean):void
155 app
.showBodyParts
(show
);
157 updateScreen
(currentScreen
);
160 public function showCreatureViewer
(show
:Boolean):void
162 app
.showCreatureViewer
(show
);
164 updateScreen
(currentScreen
);
166 public function showTextInput
(show
:Boolean, x
:Number, y
:Number):void {
167 txtInput
.setPosition
(this, x
, y
);
168 txtInput
.visible
= show
;
171 public function getTextBoxContents
():String {
172 return txtInput
.getText
();
175 public function setCheatMode
(val
:Boolean):void
177 statHP
.showCheatButtons
(val
);
178 statXP
.showCheatButtons
(val
);
179 statIntellect
.showCheatButtons
(val
);
180 statLust
.showCheatButtons
(val
);
181 statMana
.showCheatButtons
(val
);
182 statSensitivity
.showCheatButtons
(val
);
183 statSpeed
.showCheatButtons
(val
);
184 statStrength
.showCheatButtons
(val
);
187 private function onAppearance
(e
:MouseEvent):void
189 setScreen
(new AppearanceScreen
());
192 private function onNewGame
(e
:MouseEvent):void
194 player
= new Player
(this);
195 player
.setMain
(this);
196 app
.bodyparts
.init
(player
);
197 app
.creatures
.init
(player
);
198 setScreen
(new NewGameScreen
());
201 private function onImport
(e
:MouseEvent):void
203 player
= new Player
(this);
204 player
.setMain
(this);
208 private function onExport
(e
:MouseEvent):void
213 private function onLoadOrSave
(e
:MouseEvent):void
215 if (!currentScreen
.loadOrSaveButton
)
217 setScreen
(new LoadSaveScreen
(true));
221 setScreen
(new LoadSaveScreen
(false));
225 public function onPlayerLoaded
():void
228 setScreen
(player
.currentTown
);
231 public function addToStatsPanel
(stat
:Statistic
):void
233 pnlStats
.addToStack
(stat
);
234 pnlStats
.arrangeStack
();
237 public function remFromStatsPanel
(stat
:Statistic
):void
239 pnlStats
.delFromStack
(stat
);
240 pnlStats
.arrangeStack
();
243 public function setupStatsPanel
():void
245 pnlStats
.stackMode
(); // Remove textField.
246 pnlStats
.addToStack
(new StackHeader
("STATS"));
247 statXP
= new Statistic
("Experience", "How far you are from levelling up", true, setXP
);
248 pnlStats
.addToStack
(statXP
);
249 statStrength
= new Statistic
("Strength", "How much power your attacks will have.", false, setStrength
);
250 pnlStats
.addToStack
(statStrength
);
251 statSpeed
= new Statistic
("Speed", "How fast you are; Affects dodging and catching opponents.", false, null);
252 pnlStats
.addToStack
(statSpeed
);
253 statIntellect
= new Statistic
("Intellect", "Perceptiveness. Allows you to sense impending danger and figure out puzzles easier.", false, null);
254 pnlStats
.addToStack
(statIntellect
);
255 statSensitivity
= new Statistic
("Sensitivity", "The more sensitive you are, the faster your lust rises. However, lack of sensation means you cannot masturbate.", false, null);
256 pnlStats
.addToStack
(statSensitivity
);
257 statLust
= new Statistic
("Lust", "How horny you are right now.", false, null);
258 pnlStats
.addToStack
(statLust
);
260 pnlStats
.addToStack
(new StackHeader
("COMBAT"));
261 statHP
= new Statistic
("HP", "Health left.", false, null);
262 pnlStats
.addToStack
(statHP
);
263 statMana
= new Statistic
("Mana", "Magic stuff", false, null);
264 pnlStats
.addToStack
(statMana
);
266 pnlStats
.addToStack
(new StackHeader
("GOLD"));
267 statGold
= new TextField();
268 pnlStats
.addToStack
(statGold
);
269 var tf
:TextFormat = new TextFormat();
273 tf
.align
= TextFormatAlign.CENTER
;
274 statGold
.setTextFormat
(tf
);
275 statGold
.defaultTextFormat
= tf
;
277 pnlStats
.arrangeStack
();
278 statsAreSetUp
= true;
283 private function setGold
(value
:int):void
288 private function setHP
(value
:int):void
293 private function setIntellect
(value
:int):void
295 player
.intellect
= value
;
298 private function setLust
(value
:int):void
303 private function setMana
(value
:int):void
308 private function setSensitivity
(value
:int):void
310 player
.sensitivity
= value
;
313 private function setSpeed
(value
:int):void
315 player
.speed
= value
;
318 private function setStrength
(value
:int):void
320 player
.strength
= value
;
323 private function setXP
(value
:int):void
328 public function setScreen
(screen
:Screen):void
330 //trace("setscreen ",screen);
335 if (combatScreen
== null)
336 screen
= player
.currentTown
;
338 screen
= combatScreen
;
341 screen
= new StartupScreen
();
344 screen
= new StartupScreen
();
345 currentScreen
= screen
;
346 currentScreen
.setMain
(this);
347 currentScreen
.processButtonPress
(-1);
350 private function onActionClick
(e
:MouseEvent):void
352 var clicked
:SexButton
= e
.target
as SexButton
;
353 for (var i
:int = 0; i
< 12; i
++)
355 if (clicked
== btnAction
[i
])
357 var done
:Boolean = currentScreen
.processButtonPress
(i
);
358 //trace(currentScreen,done);
361 setScreen
(AdventureController
.screenQueue
.read
());
368 public function updateScreen
(screen
:Screen):void
370 pnlMain
.visible
= visible
;
371 pnlStats
.visible
= visible
;
372 var btns
:Array = screen
.getButtons
();
373 for (var i
:int = 0; i
< 12; i
++)
375 var btn
:SexButton
= (btnAction
[i
] as SexButton
);
376 btn
.visible
= (btns
[i
] != "") && visible
;
377 btn
.setText
(btns
[i
]);
379 this.btnAppearance
.visible
= screen
.appearanceButton
&& visible
;
380 this.btnDebugMenu
.visible
= screen
.debugMenuButton
&& visible
&& player
!= null;
381 this.btnExportGame
.visible
= screen
.exportGameButton
&& visible
;
382 this.btnLoadSaveGame
.setText
((screen
.loadOrSaveButton
) ? "Save Game" : "Load Game");
383 this.btnLoadSaveGame
.visible
= visible
&& screen
.showLoadOrSaveButton
;
384 this.btnNewGame
.visible
= screen
.newGameButton
&& visible
;
385 this.btnImportGame
.visible
= screen
.importGameButton
&& visible
;
387 this.pnlMain
.text
= screen
.getScreenText
();
390 player
.notifyEnchantments
(new ScreenChangedEvent
());
391 player
.addLust
(screen
.lustCost
);
395 public function refreshStats
():void
397 if (player
.level
== 0)
399 player
.levelUp
(true);
403 statXP
.setMaxAndValue
(player
.maxXP
, player
.XP
, false);
404 statStrength
.setMaxAndValue
(100, player
.strength
, false);
405 statSpeed
.setMaxAndValue
(100, player
.speed
, false);
406 statIntellect
.setMaxAndValue
(100, player
.intellect
, false);
407 statSensitivity
.setMaxAndValue
(100, player
.sensitivity
, false);
408 statLust
.setMaxAndValue
(100, player
.lust
, false);
410 statHP
.setMaxAndValue
(player
.maxHP
, player
.HP
, false);
411 statMana
.setMaxAndValue
(100, player
.mana
, false);
412 statGold
.text
= player
.gold
+ "";
415 private function addButton
(label
:String, size
:Number, x
:Number, y
:Number):SexButton
417 var btn
:SexButton
= new SexButton
(size
, label
);
420 btn
.y
= y
- btn
.height
;
424 private function setLocationOf
(sprite
:Sprite, x
:Number, y
:Number):void {
427 sprite
.y
= y
- sprite
.height
;
430 private function addTextBox
(text
:String, size
:Number, x
:Number, y
:Number):SexText
432 var txt
:SexText
= new SexText
(size
, text
);
435 txt
.y
= y
- txt
.height
;
439 private function addPanel
(text
:String, h
:Number, w
:Number, x
:Number, y
:Number):SexPanel
441 var btn
:SexPanel
= new SexPanel
(text
);
449 public function onResize
(h
:Number, w
:Number, measuredHeight
:Number, measuredWidth
:Number):void
453 currentMeasuredHeight
= measuredHeight
;
454 currentMeasuredWidth
= measuredWidth
;
456 var originalPanelHeightPCT
:Number = 464.5 / 600;
457 //pnlStats = addPanel("", 464.5, 144.9, 15.75, 56.75);
458 //pnlMain = addPanel("", 464.5, 618.5, 167.75, 56.75);
460 pnlStats
.height
= pnlMain
.height
= (464.5 / 600) * h
;
461 pnlStats
.width
= (144.9 / 800) * w
;
462 pnlStats
.x
= (15.75 / 800) * w
;
463 pnlStats
.y
= (56.75 / 600) * h
;
465 pnlMain
.width
= (618.5 / 800) * w
;
466 pnlMain
.x
= (167.75 / 800) * w
;
467 pnlMain
.y
= (56.75 / 600) * h
;
471 var xOffset
:Number = (16 / 800) * w
;
472 var yOffset
:Number = (531 / 600) * h
; //(561 / 600) * h;
473 var bHeightPadding
:Number = (32 / 600) * h
;
474 var bWidthPadding
:Number = (129.2 / 800) * w
;
475 var bHeight
:Number = (30 / 600) * h
;
476 var bWidth
:Number = (100 / 800) * w
;
477 for (var i
:int = 0; i
< 12; i
++)
479 //var btn:SexButton = addButton((i + 1).toString(), 100, 16 + ((i % 6) * 129.2), 561 + (Math.round(i / 12) * 32));
480 btnAction
[i
].height
= bHeight
;
481 btnAction
[i
].width
= bWidth
;
482 btnAction
[i
].x
= xOffset
+ ((i
% 6) * bWidthPadding
);
483 btnAction
[i
].y
= yOffset
+ (Math.round
(i
/ 12) * bHeightPadding
);
486 // Top row of buttons
487 xOffset
= (129.2 / 800) * w
;
488 var toprow
:Number = (21 / 600) * h
; // 51 - 21 = 30
489 var x
:Number = (16 / 800) * w
;
490 btnNewGame
.width
= bWidth
;
491 btnNewGame
.height
= bHeight
;
492 btnNewGame
.y
= toprow
;
496 btnLoadSaveGame
.width
= bWidth
;
497 btnLoadSaveGame
.height
= bHeight
;
498 btnLoadSaveGame
.y
= toprow
;
499 btnLoadSaveGame
.x
= x
;
502 btnImportGame
.width
= bWidth
;
503 btnImportGame
.height
= bHeight
;
504 btnImportGame
.y
= toprow
;
508 btnExportGame
.width
= bWidth
;
509 btnExportGame
.height
= bHeight
;
510 btnExportGame
.y
= toprow
;
514 btnDebugMenu
.width
= bWidth
;
515 btnDebugMenu
.height
= bHeight
;
516 btnDebugMenu
.y
= toprow
;
520 btnAppearance
.width
= bWidth
;
521 btnAppearance
.height
= bHeight
;
522 btnAppearance
.y
= toprow
;
525 // Text input (moves around)
526 txtInput
.dynamicResize
(this);
529 private function initBG
():void
531 bgshape
= new Sprite();
532 bgshape
.graphics
.clear
();
533 bgshape
.graphics
.beginFill
(currentBGColor
);
534 bgshape
.graphics
.drawRect
(0, 0, stage
.stageWidth
, stage
.stageHeight
);
535 addChildAt
(bgshape
, 0);
536 stage
.addEventListener
(Event.RESIZE
, resizeBGWithStage
);
539 private function redrawBG
():void
541 bgshape
.graphics
.beginFill
(currentBGColor
);
542 bgshape
.graphics
.drawRect
(0, 0, stage
.stageWidth
, stage
.stageHeight
);
545 private function resizeBGWithStage
(e
:Event):void
549 bgshape
.width
= stage
.stageWidth
;
550 bgshape
.height
= stage
.stageHeight
;
557 public function showInventory
(item
:Item
= null):void
559 setScreen
(new InventoryScreen
(item
));
562 public function startRape
(oldScreen
:Screen, combatant
:Creature
, playerInitiated
:Boolean = false):void
564 if (!(oldScreen
is CombatScreen
))
566 if (!combatant
.staticStats
)
568 combatant
._level
= Math.max
(1, player
.level
+ MathUtils
.rand
(-2, 2));
569 combatant
._strength
= Math.max
(1, player
.strength
+ MathUtils
.rand
(-2, 2));
571 combatant
.HP
= combatant
.maxHP
;
572 combatant
.mana
= combatant
.maxMana
;
574 combatant
.notifyEnchantments
(new CombatStartEvent
(player
));
575 player
.notifyEnchantments
(new CombatStartEvent
(combatant
));
577 if (combatant
.tryRape
(player
))
579 combatScreen
= new Rape
(combatant
);
580 setScreen
(combatScreen
);
581 currentBGColor
= 0x330000;
583 updateScreen
(combatScreen
);
587 if (!(oldScreen
is CombatScreen
))
589 startCombat
(oldScreen
, combatant
, false);
594 public function startCombat
(oldScreen
:Screen, combatant
:Creature
, playerInitiated
:Boolean = false):void
596 if (!combatant
.staticStats
)
598 if (player
.level
< 5)
600 combatant
._level
= Math.max
(1, player
.level
+ MathUtils
.rand
(-2, 0));
601 combatant
._strength
= Math.max
(1, player
.strength
+ MathUtils
.rand
(-2, 0));
605 combatant
._level
= Math.max
(1, player
.level
+ MathUtils
.rand
(-2, 2));
606 combatant
._strength
= Math.max
(1, player
.strength
+ MathUtils
.rand
(-2, 2));
609 combatant
.HP
= combatant
.maxHP
;
610 combatant
.mana
= combatant
.maxMana
;
612 combatant
.notifyEnchantments
(new CombatStartEvent
(player
));
613 player
.notifyEnchantments
(new CombatStartEvent
(combatant
));
614 combatScreen
= new CombatScreen
(oldScreen
, combatant
, playerInitiated
);
615 setScreen
(combatScreen
);
616 currentBGColor
= 0x330000;
620 public function endCombat
(oldScreen
:Screen):void
623 currentBGColor
= default_bg_color
;
627 public function setTown
(t
:Town
):void
629 player
.currentTown
= t
;