This file was deleted.

This file was deleted.

@@ -10,13 +10,12 @@ import flixel.input.keyboard.FlxKeyList;
import neko.vm.Ui;
import ui.Gadget;
import ui.MainMenu;
import ui.MenuClass;

/**
* @author Sjoer van der Ploeg
*/

class MainMenuState extends FlxState
class MenuState extends FlxState
{
private var mainMenu:MainMenu;

@@ -40,7 +39,7 @@ class MainMenuState extends FlxState
{
switch (_level)
{
case "game": FlxG.switchState(new Presentation());
case "game": FlxG.switchState(new PlayState());
case "help": FlxG.switchState(null);
case "about": FlxG.switchState(null);
case "exit": Sys.exit(0);
@@ -1,21 +1,111 @@
package states;

import flixel.FlxG;
import flixel.FlxState;
import game.ConversationLoader;
import game.StoryContainer;
import ui.MapDisplay;
import ui.ActionBar;
import ui.ConversationUI;
import ui.Gadget;

/**
* @author Sjoer van der Ploeg
*
* Default playstate
* PlayState for the presentation
*/

class PlayState extends FlxState
{
private var map:MapDisplay;
private var gadget:Gadget;
private var actionBar:ActionBar;
private var conversation:ConversationUI;

private var stories:StoryContainer;

/**
* Create this state.
*/
override public function create()
{
super.create();

map = new MapDisplay();
actionBar = new ActionBar(actions);
gadget = new Gadget();

stories = new StoryContainer(storyCallback);
conversation = new ConversationUI(conversationCallback);

add(map);
add(actionBar);
add(gadget);

// hacks
conversation.set(stories.nextText("bully", 1), "bully");
}

public function storyCallback(_options:Array<String>)
{
//trace(_options);
}

public function conversationCallback(_options:Array<String>)
{
//trace(stories.currentText(_options[1])[0][1]);
//if (stories.currentText(_options[1])[0][1] == "player" || stories.currentText(_options[1])[0][1] == "npc")
switch (_options[0])
{
case "0":
FUCKMYLIFE();
conversation.set(stories.nextText(_options[1], 1), _options[1]);

default:
conversation.set(stories.nextText(_options[1], Std.parseInt(_options[0])), _options[1]);
evaluate(stories.currentText(_options[1]), _options);
}
}

private function evaluate(_command:Array<Array<String>>, _options:Array<String>)
{
trace(_command + " " + _options);

switch (_command[0][1].toLowerCase())
{
default: trace(_command);

case "conversation":
FUCKMYLIFE();
trace(_command[0][2]);
stories.nextPart(_options[1], _command[0][2]);
evaluate(stories.nextText(_options[1], 1), [null, _options[1]]);

case "gadget":
trace(_command + " " + _options);
gadget.addNotification(_command[0][2], conversationCallback, [_command[0][0], _options[1]]);
}
}

private function FUCKMYLIFE()
{
remove(conversation);
conversation.destroy();
conversation = new ConversationUI(conversationCallback);
}

private function actions(_action:String)
{
switch(_action)
{
case "A":
add(conversation);

case "B": trace("B");
case "C": trace("C");
case "D": trace("D");
case "E": trace("E");
}
}

/**
@@ -24,6 +114,11 @@ class PlayState extends FlxState
override public function update()
{
super.update();

if (gadget.gadgetOpen && members.indexOf(actionBar) != -1) remove(actionBar);
else if (!gadget.gadgetOpen && members.indexOf(actionBar) == -1) add(actionBar);

if (FlxG.keys.justPressed.ESCAPE) FlxG.switchState(new MenuState());
}

/**

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -20,13 +20,13 @@ class ConversationUI extends FlxSpriteGroup
private var nameText:FlxText;
private var options:Array<FlxButtonPlus> = new Array<FlxButtonPlus>();

private var optionCallback:Dynamic->Void;
private var callback:Dynamic->Void;

public function new(_callback:Dynamic->Void)
{
super();

optionCallback = _callback;
callback = _callback;

add(scene);
add_character();
@@ -67,41 +67,23 @@ class ConversationUI extends FlxSpriteGroup

options[_index].textHighlight = new FlxText(bgText.x + 32, bgText.y + 16 + (_index * 56), bgText.width - 64, null, 20, true);
options[_index].textHighlight.color = 0xFFFFFF;

add(options[_index]);
}
}

public function set(_options:Array<Array<String>>, _story:Int, ?_lastBtn:Int = null)
public function set(_text:Array<Array<String>>, _story:String)
{
nameText.text = _options[0].pop();
nameText.text = _text[0][3];
for (_option in options)
remove(_option);

for (_index in 0 ... 3)
{
if (_index < _options.length)
if (_index < _text.length)
{
options[_index].text = _options[_index][2];
options[_index].onClickCallback = optionCallback.bind([Std.parseInt(_options[_index][0]), _story, _index]);
options[_index].visible = true;
options[_index].text = _text[_index][2];
options[_index].onClickCallback = callback.bind([_text[_index][0], _story]);
add(options[_index]);
}

else
{
options[_index].text = null;
options[_index].visible = false;
}

options[_index].textHighlight.visible = (_index == _lastBtn) ? true : false;
options[_index].textNormal.visible = !options[_index].textHighlight.visible;
}
}

public function FUCKMYLIFE() // I HATE FUCKING HIGHLIGHTS, they need to be visible before being able to change ... FIX: drive into the problem with a semitruck on another day!
{
for (_ffs in options)
{
_ffs.textHighlight.visible = false;
_ffs.textNormal.visible = true;
}
}

@@ -116,7 +98,8 @@ class ConversationUI extends FlxSpriteGroup
character = null;
bgText = null;
bgNameText = null;
nameText = null;
options = null;
optionCallback = null;
callback = null;
}
}

This file was deleted.

@@ -25,7 +25,7 @@ class Gadget extends FlxSpriteGroup

private var text:FlxText = new FlxText();

private var defaultText:String = "There are no messages to be shown right now!";
private var defaultText:String = "Er zijn op het moment geen berichten om te tonen!";

private var timer:Timer = new Timer(1000, 1);
private var blinker:Timer = new Timer(250, 0);
@@ -35,7 +35,7 @@ class Gadget extends FlxSpriteGroup
private var notification:Bool = false;

private var callback:Dynamic->Void;
private var callbackOptions:Array<Int>;
private var callbackOptions:Array<String>;

public function new(_x:Float = 0, _y:Float = 0)
{
@@ -44,49 +44,52 @@ class Gadget extends FlxSpriteGroup
width = FlxG.width;
height = FlxG.height;

bg.makeGraphic(FlxG.width, FlxG.height, FlxColor.BLACK);
bg.visible = false;
add(bg);
bg.x = FlxG.width * 0.5 - (screen.width * 0.5);
bg.y = FlxG.height * 0.5 - (screen.height * 0.5);
bg.makeGraphic(screen.frameWidth, screen.frameHeight, FlxColor.BLACK);
//bg.makeGraphic(FlxG.width, FlxG.height, FlxColor.BLACK);
//bg.visible = false;
//add(bg);

edge.x = FlxG.width * 0.5 - (edge.width * 0.5);
edge.y = FlxG.height * 0.5 - (edge.height * 0.5);
edge.visible = false;
add(edge);
//edge.visible = false;
//add(edge);

background.x = FlxG.width * 0.5 - (background.width * 0.5);
background.y = FlxG.height * 0.5 - (background.height * 0.5);
background.alpha = 0.5;
background.visible = false;
add(background);
//background.visible = false;
//add(background);

logo.x = FlxG.width * 0.5 - (logo.width * 0.5);
logo.y = FlxG.height * 0.5 - (logo.height * 0.5);
logo.visible = false;
add(logo);
//logo.visible = false;
//add(logo);

screen.x = FlxG.width * 0.5 - (screen.width * 0.5);
screen.y = FlxG.height * 0.5 - (screen.height * 0.5);
screen.alpha = 0.5;
screen.visible = false;
add(screen);
//screen.visible = false;
//add(screen);

text.x = screen.x + 32;
text.y = screen.y + 32;
text.fieldWidth = screen.width - 64;
text.wordWrap = true;
text.size = 32;
text.visible = false;
add(text);
//text.visible = false;
//add(text);

backside.x = FlxG.width - backside.width - 64;
backside.y = FlxG.height - backside.height - 64;
backside.visible = true;
//backside.visible = true;
add(backside);

notificationSprite.x = FlxG.width - notificationSprite.width - 64;
notificationSprite.y = FlxG.height - notificationSprite.height - 64;
notificationSprite.visible = false;
add(notificationSprite);
//notificationSprite.visible = false;
//add(notificationSprite);

FlxG.plugins.add(new MouseEventManager());

@@ -99,8 +102,39 @@ class Gadget extends FlxSpriteGroup

private function flip(_sprite:FlxSprite)
{
if (backside.visible) timer.start();
else text.visible = false;
if (_sprite == backside)
{
remove(backside);
remove(notificationSprite);

add(bg);
add(edge);
add(background);
add(logo);
add(screen);
add(text);

logo.visible = true;
text.visible = false;

timer.start();

gadgetOpen = true;
}

else
{
add(backside);

remove(bg);
remove(edge);
remove(background);
remove(logo);
remove(screen);
remove(text);

gadgetOpen = false;
}

if (textRead)
{
@@ -110,11 +144,6 @@ class Gadget extends FlxSpriteGroup
}

else if (text.text == defaultText) text.text = "";

gadgetOpen = bg.visible = edge.visible = background.visible = logo.visible = screen.visible = (_sprite == backside);
backside.visible = !_sprite.visible;

if (notification && !backside.visible) notificationSprite.visible = false;
}

private function onTimer(_event:TimerEvent)
@@ -142,27 +171,30 @@ class Gadget extends FlxSpriteGroup
if (!notification)
{
blinker.reset();
notificationSprite.visible = false;
remove(notificationSprite);
}

else if (notification && backside.visible)
else if (notification && !gadgetOpen)
{
notificationSprite.visible = !notificationSprite.visible;
}

//else if (!backside.visible) notificationSprite.visible = false;
}

public function addNotification(_text:String, _callback:Dynamic->Void, _options:Array<Int>)
public function addNotification(_text:String, _callback:Dynamic->Void, _options:Array<String>)
{
text.text = _text;
trace(_options);

text.text = _text;
callback = _callback;
callbackOptions = _options;

//ugly hack, needs an array and some routine to switch notifications etc etc etc
//if (callbackOptions[0] == null) callbackOptions[0] = "1";
//else callbackOptions[0] = Std.string(Std.parseInt(callbackOptions[0]) + 1);

add(notificationSprite);

notification = true;

blinker.start();
}

@@ -26,7 +26,7 @@ class MapDisplay extends FlxSpriteGroup
private var directions:Array<Array<Int>> = [
[], [2, 4], [1],
[], [1, 7], [],
[10], [4, 10], [10],
[10], [10], [10],
[10], [6, 7, 8, 9, 11, 13], [10],
[13], [10, 12, 14, 15, 16, 17], [13],
[13], [13], [13]
@@ -35,9 +35,9 @@ class MapDisplay extends FlxSpriteGroup
private var direction:Array<Array<String>> = [
[], ["E", "S"], ["W"],
[], ["N", "S"], [],
["SE"], ["N", "S"], ["SW"],
["SE"], ["S"], ["SW"],
["E"], ["NW", "N", "NE", "W", "E", "S"], ["W"],
["E"], ["N", "W", "E", "SW", "S", "SE"], ["W"],
["E"], ["N", "W", "E", "SW", "S", "SE"], ["W"],
["NE"], ["N"], ["NW"]
];

This file was deleted.