void Start() {
        CurveStateRenderer renderer = new CurveStateRenderer();
        AudioEngine auEngine = new AudioEngine(0, Settings.game_name, Settings.menu_sounds, Settings.game_sounds);

        List<WorldObject> environment = new List<WorldObject>();
        environment.Add(new CurveStaticObject("Prefabs/Curve/Camera_Default", new Vector3(0, 10, 0), false));
        environment.Add(new CurveStaticObject("Prefabs/Curve/Light_Default", new Vector3(0, 10, 0), false));
        environment.Add(new CanvasObject("Prefabs/Curve/OutroLogo", true, new Vector3(0, 0, 0), false));

        CurveRuleset rules = new CurveRuleset();
        rules.Add(new CurveRule("initialization", (CurveMenuState state, GameEvent eve, CurveMenuEngine engine) => {
            CurveSoundObject tso = new CurveSoundObject("Prefabs/Curve/AudioSource", auEngine.getSoundForMenu("outro"), Vector3.zero);
            state.environment.Add(tso);
            state.stoppableSounds.Add(tso);
            return false;
        }));

        rules.Add(new CurveRule("soundOver", (CurveMenuState state, GameEvent eve, CurveMenuEngine engine) => {
            Application.Quit();
            return false;
        }));

        gameObject.AddComponent<CurveMenuEngine>();
        gameObject.AddComponent<CurveMenuUserInterface>();
        gameObject.GetComponent<CurveMenuEngine>().initialize(rules, environment, renderer);
        gameObject.GetComponent<CurveMenuUserInterface>().initialize(gameObject.GetComponent<CurveMenuEngine>());
        gameObject.GetComponent<CurveMenuEngine>().postEvent(new GameEvent("", "initialization", "unity"));
    }
Пример #2
0
 public void initialize(CurveRuleset rules, List<WorldObject> environment, CurveStateRenderer renderer) {
     this.rules = rules;
     this.environment = environment;
     this.renderer = renderer;
     state = new CurveMenuState(environment);
     events = new Queue<GameEvent>();
     state.curPlayer = -1;
     initialized = true;
 }
Пример #3
0
 public void initialize(CurveRuleset rules, List<Actor> actors, List<WorldObject> environment, List<Player> players, CurveStateRenderer renderer) {
     this.rules = rules;
     this.actors = actors;
     this.environment = environment;
     this.players = players;
     this.renderer = renderer;
     state = new CurveGameState(actors, environment, players);
     events = new Queue<GameEvent>();
     state.curPlayer = new System.Random().Next(players.Count);
     initialized = true;
 }
	void Start () {
		CurveStateRenderer renderer = new CurveStateRenderer();
        AudioEngine auEngine = new AudioEngine(0, Settings.game_name, Settings.menu_sounds, Settings.game_sounds);

        List<Actor> actors = new List<Actor>();
        actors.Add(new CurveActor("pointer", "Prefabs/Curve/Ball", new Vector3(initial_x, initial_y, 90f), false, null));

        List<WorldObject> environment = new List<WorldObject>();
        environment.Add(new CurveStaticObject("Prefabs/Curve/Ball", Vector3.zero, false));
        environment.Add(new CurveStaticObject("Prefabs/Curve/MainCamera", Vector3.zero, false));
        environment.Add(new CurveStaticObject("Prefabs/Curve/Light", Vector3.zero, false));
        environment.Add(new CanvasObject("Prefabs/Curve/LeapLogo", true, Vector3.zero, false));
        environment.Add(new CurveStaticObject("Prefabs/Curve/Divider", new Vector3(0, 0, 100f), false));
		
		List<Player> players = new List<Player>();
		players.Add(new Player("player0", "player0"));

        CurveRuleset rules = new CurveRuleset();
		rules.Add(new CurveRule("initialization", (CurveGameState state, GameEvent eve, CurveGameEngine engine) => {
			AudioClip auClip = auEngine.getSoundForMenu("tutorial_1");
			CurveSoundObject tso = new CurveSoundObject("Prefabs/Curve/AudioSource", auClip);
			state.environment.Add(tso);
			state.blockingSound = tso;
            state.timestamp = 11;
            for (int j = 0; j < 14; j++) {
                state.expectedValues[j] = 6;
            }
			return false;
		}));

        rules.Add(new CurveRule("frame", (CurveGameState state, GameEvent eve, CurveGameEngine engine) => {
            if (state.replaying || state.repeating) {
                if (state.delay <= 0) {
                    state.delay = 0.6f;
                    if (state.replaying) {
                        float x = initial_rx + state.index * offset_x;
                        float y = initial_y + state.expectedValues[state.index] * offset_y;
                        engine.state.environment.Add(new CurveSoundObject("Prefabs/Curve/VisibleGameAudio", auEngine.getSoundForPlayer("note", new Vector3(state.index, state.expectedValues[state.index], 0)), new Vector3(x, y, 90)));
                    } else {
                        if (state.values[state.index] != -1) {
                            float x = initial_x + state.index * offset_x;
                            float y = initial_y + state.values[state.index] * offset_y;
                            engine.state.environment.Add(new CurveSoundObject("Prefabs/Curve/VisibleGameAudio", auEngine.getSoundForPlayer("note", new Vector3(state.index, state.values[state.index], 0)), new Vector3(x, y, 90)));
                        } else {
                            engine.state.environment.Add(new CurveSoundObject("Prefabs/Curve/VisibleGameAudio", auEngine.getSoundForPlayer("air")));
                        }
                    }
                    state.index++;
                    if (state.index == max) {
                        if ((state.timestamp == 17 && state.replaying)
                            || (state.timestamp == 19 && state.replaying)
                            || (state.timestamp == 20 && state.repeating)
                            || (state.timestamp == 22 && state.replaying)
                            || (state.timestamp == 23 && state.replaying)) {
                            state.timestamp += 41;
                            if (state.timestamp == 60) {
                                state.values[0] = 12;
                            }
                        }
                        state.index = 0;
                        state.repeating = false;
                        state.replaying = false;
                        state.delay = 0;
                    }
                } else {
                    state.delay -= Time.deltaTime;
                }
            }
            return false;
        }));

        rules.Add(new CurveRule("action", (CurveGameState state, GameEvent eve, CurveGameEngine engine) => {
            if (eve.payload.Equals("escape")) {
                Application.LoadLevel(Settings.previousMenu);
                return false;
            }
            return true;
        }));

        rules.Add(new CurveRule("soundOver", (CurveGameState state, GameEvent eve, CurveGameEngine engine) => {
            int id = int.Parse(eve.payload);
            if (state.blockingSound != null && id == state.blockingSound.clip.GetInstanceID()) {
                state.environment.Remove(state.blockingSound);
                state.blockingSound = null;
                CurveSoundObject tso;
                switch (state.timestamp) {
                    case 11:
                        tso = new CurveSoundObject("Prefabs/Curve/GameAudio", auEngine.getSoundForPlayer("note", new Vector3(7, 0, 0)));
                        state.blockingSound = tso;
                        state.environment.Add(tso);
                        state.timestamp = 52;
                        return false;
                    case 12:
                        tso = new CurveSoundObject("Prefabs/Curve/GameAudio", auEngine.getSoundForPlayer("note", new Vector3(7, 1, 0)));
                        state.blockingSound = tso;
                        state.environment.Add(tso);
                        state.timestamp = 53;
                        return false;
                    case 13:
                        tso = new CurveSoundObject("Prefabs/Curve/GameAudio", auEngine.getSoundForPlayer("note", new Vector3(7, 13, 0)));
                        state.blockingSound = tso;
                        state.environment.Add(tso);
                        state.timestamp = 54;
                        return false;
                    case 14:
                        state.replaying = true;
                        state.timestamp = 55;
                        return false;
                    case 115:
                        tso = new CurveSoundObject("Prefabs/Curve/GameAudio", auEngine.getSoundForMenu("tutorial_5b"));
                        state.blockingSound = tso;
                        state.environment.Add(tso);
                        state.timestamp = 15;
                        return false;
                    case 116:
                        tso = new CurveSoundObject("Prefabs/Curve/GameAudio", auEngine.getSoundForMenu("tutorial_6"));
                        state.blockingSound = tso;
                        state.environment.Add(tso);
                        state.timestamp = 57;
                        max = 3;
                        return false;
                    case 118:
                        tso = new CurveSoundObject("Prefabs/Curve/GameAudio", auEngine.getSoundForMenu("tutorial_8b"));
                        state.blockingSound = tso;
                        state.environment.Add(tso);
                        state.timestamp = 18;
                        return false;
                    case 22:
                        max = 14;
                        for (int i = 0; i < 14; i++) {
                            state.expectedValues[i] = i / 3;
                        }
                        state.replaying = true;
                        return false;
                    case 23:
                        state.replaying = true;
                        for (int i = 0; i < 14; i++) {
                            state.expectedValues[i] = 13 - i;
                        }
                        return false;
                    case 24:
                        state.timestamp = 10;
                        return false;
                    default:
                        if (state.timestamp > 50) {
                            state.timestamp = state.timestamp - 50;
                            tso = new CurveSoundObject("Prefabs/Curve/GameAudio", auEngine.getSoundForMenu("tutorial_" + state.timestamp));
                            state.blockingSound = tso;
                            state.environment.Add(tso);
                            state.timestamp += 10;
                        }
                        return false;
                }
            } else {
                WorldObject toRemove = null;
                foreach (WorldObject go in state.environment) {
                    if (go is CurveSoundObject && (go as CurveSoundObject).clip.GetInstanceID() == id) {
                        toRemove = go;
                        break;
                    }
                }
                if (toRemove != null) {
                    state.environment.Remove(toRemove);
                }
                if (state.timestamp == 55
                    || state.timestamp == 58
                    || state.timestamp == 60
                    || state.timestamp == 61
                    || state.timestamp == 63
                    || state.timestamp == 64
                    || state.timestamp == 65) {
                    state.timestamp -= 50;
                    CurveSoundObject tso = new CurveSoundObject("Prefabs/Curve/GameAudio", auEngine.getSoundForMenu("tutorial_" + state.timestamp));
                    state.blockingSound = tso;
                    state.environment.Add(tso);
                    state.timestamp += 10;
                }
            }
            return false;
        }));

        rules.Add(new CurveRule("ALL", (CurveGameState state, GameEvent eve, CurveGameEngine engine) => {
            return !eve.initiator.StartsWith("player") || (eve.initiator.Equals("player" + state.curPlayer) && state.blockingSound == null);
        }));

        rules.Add(new CurveRule("action", (CurveGameState state, GameEvent eve, CurveGameEngine engine) => {
            if (state.repeating || state.replaying || state.blockingSound != null) {
                return true;
            }
            switch (eve.payload) {
                case "any":
                    if (state.timestamp == 10) {
                        (state.result as CurveGameResult).status = CurveGameResult.GameStatus.Over;
                        return false;
                    }
                    return true;
                case "replay":
                    state.replaying = true;
                    state.index = 0;
                    return false;
                case "repeat":
                    state.repeating = true;
                    state.index = 0;
                    return false;
                case "enter":
                    foreach (Actor actor in state.actors) {
                        Vector3 position = actor.position - new Vector3(initial_x, initial_y, 0f);
                        int x = (int)(position.x / offset_x);
                        int y = (int)(position.y / offset_y);
                        if (state.values[x] == state.expectedValues[x]) {
                            if (state.timestamp == 18) {
                                CurveSoundObject tso = new CurveSoundObject("Prefabs/Curve/GameAudio", auEngine.getSoundForPlayer("boundary", new Vector3(0, 1, 0)));
                                state.environment.Add(tso);
                                state.blockingSound = tso;
                                state.timestamp = 118;
                            } else {
                                engine.state.environment.Add(new CurveSoundObject("Prefabs/Curve/GameAudio", auEngine.getSoundForPlayer("boundary", new Vector3(0, 1, 0)), Vector3.zero));
                            }
                        } else {
                            if (state.timestamp == 15) {
                                CurveSoundObject tso;
                                state.values[x] = y;
                                if (state.values[x] == state.expectedValues[x]) {
                                    tso = new CurveSoundObject("Prefabs/Curve/GameAudio", auEngine.getSoundForPlayer("correct"));
                                    state.environment.Add(tso);
                                    state.blockingSound = tso;
                                    state.timestamp = 116;
                                } else {
                                    tso = new CurveSoundObject("Prefabs/Curve/GameAudio", auEngine.getSoundForPlayer("note", new Vector3(x, y, 0)));
                                    state.environment.Add(tso);
                                    state.blockingSound = tso;
                                    state.timestamp = 115;
                                }
                            } else {
                                state.values[x] = y;
                                if (state.values[x] == state.expectedValues[x]) {
                                    if (state.timestamp == 18 && state.values[1] == state.expectedValues[1] && state.values[2] == state.expectedValues[2]) {
                                        CurveSoundObject tso = new CurveSoundObject("Prefabs/Curve/GameAudio", auEngine.getSoundForPlayer("correct"));
                                        state.environment.Add(tso);
                                        state.blockingSound = tso;
                                        state.timestamp = 59;
                                    } else if (state.timestamp == 21 && state.values[0] == state.expectedValues[0]) {
                                        CurveSoundObject tso = new CurveSoundObject("Prefabs/Curve/GameAudio", auEngine.getSoundForPlayer("correct"));
                                        state.environment.Add(tso);
                                        state.blockingSound = tso;
                                        state.timestamp = 62;
                                    } else {
                                        engine.state.environment.Add(new CurveSoundObject("Prefabs/Curve/GameAudio", auEngine.getSoundForPlayer("correct")));
                                    }
                                } else {
                                    engine.state.environment.Add(new CurveSoundObject("Prefabs/Curve/GameAudio", auEngine.getSoundForPlayer("note", new Vector3(x, y, 0)), Vector3.zero));
                                }
                            }
                        }
                    }
                    return false;
            }
            return true;
        }));

        rules.Add(new CurveRule("move", (CurveGameState state, GameEvent eve, CurveGameEngine engine) => {
            if (state.repeating || state.replaying) {
                return false;
            }
            int dx = 0;
            int dy = 0;
            switch (eve.payload) {
                case "left":
                    dx = -1;
                    break;
                case "right":
                    dx = 1;
                    break;
                case "up":
                    dy = 1;
                    break;
                case "down":
                    dy = -1;
                    break;
                default:
                    return false;
            }
            foreach (Actor actor in state.actors) {
                Vector3 position = actor.position - new Vector3(initial_x, initial_y, 0f);
                int x = (int)(position.x / offset_x) + dx;
                int y = (int)(position.y / offset_y) + dy;
                if (x <= -1 || x >= max || y <= -1 || y >= 14) {
                    return false;
                }
                actor.position = new Vector3(offset_x * x + initial_x, offset_y * y + initial_y, actor.position.z);
                engine.state.environment.Add(new CurveSoundObject("Prefabs/Curve/GameAudio", auEngine.getSoundForPlayer("note", new Vector3(x, y, 0))));
            }
            return false;
        }));
		
		gameObject.AddComponent<CurveGameEngine>();
		gameObject.AddComponent<CurveUserInterface>();
		gameObject.GetComponent<CurveGameEngine>().initialize(rules, actors, environment, players, renderer);
		gameObject.GetComponent<CurveUserInterface>().initialize(gameObject.GetComponent<CurveGameEngine>());
		gameObject.GetComponent<CurveGameEngine>().postEvent(new GameEvent("", "initialization", "unity"));
	}
	void Start () {
        CurveStateRenderer renderer = new CurveStateRenderer();
        AudioEngine auEngine = new AudioEngine(0, Settings.game_name, Settings.menu_sounds, Settings.game_sounds);

        List<Actor> actors = new List<Actor>();
        actors.Add(new CurveActor("pointer", "Prefabs/Curve/Ball", new Vector3(initial_x, initial_y, 90f), false, null));

        List<WorldObject> environment = new List<WorldObject>();
        environment.Add(new CurveStaticObject("Prefabs/Curve/Ball", Vector3.zero, false));
        environment.Add(new CurveStaticObject("Prefabs/Curve/MainCamera",    Vector3.zero, false));
        environment.Add(new CurveStaticObject("Prefabs/Curve/Light", Vector3.zero, false));
        environment.Add(new CanvasObject("Prefabs/Curve/LeapLogo", true, Vector3.zero, false));
        environment.Add(new CurveStaticObject("Prefabs/Curve/Divider", new Vector3(0, 0, 100f), false));
        TextCanvasObject gui = new TextCanvasObject("Prefabs/Curve/GUI_Element", true, "Time Left: " + Settings.time * 60, new Vector3(0, 0, 0), false);
        environment.Add(gui);

        List<Player> players = new List<Player>();
        players.Add(new Player("player0", "player0"));

        CurveRuleset rules = new CurveRuleset();
        rules.Add(new CurveRule("initialization", (CurveGameState state, GameEvent eve, CurveGameEngine engine) => {
            AudioClip auClip = auEngine.getSoundForMenu("new_game_intro");
            CurveSoundObject tso = new CurveSoundObject("Prefabs/Curve/AudioSource", auClip);
            state.environment.Add(tso);
            state.blockingSound = tso;
            state.timestamp = 0;
            state.level = Settings.level;
            state.time_left = Settings.time * 60;
            for (int j = 0; j < 14; j++) {
                switch (state.level) {
                    case 0:
                        state.expectedValues[j] = 6;
                        break;
                    case 1:
                        state.expectedValues[j] = j;
                        break;
                    case 2:
                        state.expectedValues[j] = (int)(13f - j);
                        break;
                    case 3:
                        state.expectedValues[j] = (int)(j * j / 13f);
                        break;
                    case 4:
                        state.expectedValues[j] = (int)(Mathf.Sqrt(14.5f * j));
                        break;
                    case 5:
                        state.expectedValues[j] = (int) Mathf.Round((Mathf.Sin(j * 3.14159f / 4f) + 1f) * 6f);
                        break;
                    case 6:
                        state.expectedValues[j] = (int)(13f / (j + 1));
                        break;
                }
                state.values[j] = -1;
            }
            return false;
        }));

        rules.Add(new CurveRule("frame", (CurveGameState state, GameEvent eve, CurveGameEngine engine) => {
            if (state.timestamp == 2 && !state.repeating && !state.replaying) {
                state.time_left -= Time.deltaTime;
                gui.text = "Time Left: " + (int)state.time_left;
                if (state.time_left <= 0) {
                    state.timestamp = 9;
                    AudioClip auClip = auEngine.getSoundForMenu("new_game_loss");
                    CurveSoundObject tso = new CurveSoundObject("Prefabs/Curve/AudioSource", auClip);
                    state.environment.Add(tso);
                    state.blockingSound = tso;
                }
            } else if (state.timestamp == 2) {
                if (state.delay <= 0) {
                    state.delay = 0.6f;
                    if (state.replaying) {
                        float x = initial_rx + state.index * offset_x;
                        float y = initial_y + state.expectedValues[state.index] * offset_y;
                        engine.state.environment.Add(new CurveSoundObject("Prefabs/Curve/VisibleGameAudio", auEngine.getSoundForPlayer("note", new Vector3(state.index, state.expectedValues[state.index], 0)), new Vector3(x, y, 90)));
                    } else {
                        if (state.values[state.index] != -1) {
                            float x = initial_x + state.index * offset_x;
                            float y = initial_y + state.values[state.index] * offset_y;
                            engine.state.environment.Add(new CurveSoundObject("Prefabs/Curve/VisibleGameAudio", auEngine.getSoundForPlayer("note", new Vector3(state.index, state.values[state.index], 0)), new Vector3(x, y, 90)));
                        } else {
                            engine.state.environment.Add(new CurveSoundObject("Prefabs/Curve/VisibleGameAudio", auEngine.getSoundForPlayer("air")));
                        }
                    }
                    state.index++;
                    if (state.index == 14) {
                        state.index = 0;
                        state.repeating = false;
                        state.replaying = false;
                        state.delay = 0;
                    }
                } else {
                    state.delay -= Time.deltaTime;
                }
            }
            return false;
        }));

        rules.Add(new CurveRule("action", (CurveGameState state, GameEvent eve, CurveGameEngine engine) => {
            if (eve.payload.Equals("escape")) {
                Application.LoadLevel(Settings.previousMenu);
                return false;
            }
            return true;
        }));

        rules.Add(new CurveRule("soundOver", (CurveGameState state, GameEvent eve, CurveGameEngine engine) => {
            int id = int.Parse(eve.payload);
            if (state.blockingSound != null && id == state.blockingSound.clip.GetInstanceID()) {
                state.environment.Remove(state.blockingSound);
                state.blockingSound = null;
                if (state.timestamp == 0) {
                    state.timestamp = 2;
                    state.replaying = true;
                }
                if (state.timestamp == 9) {
                    state.timestamp = 10;
                }
            } else {
                WorldObject toRemove = null;
                foreach (WorldObject go in state.environment) {
                    if (go is CurveSoundObject && (go as CurveSoundObject).clip.GetInstanceID() == id) {
                        toRemove = go;
                        break;
                    }
                }
                if (toRemove != null) {
                    state.environment.Remove(toRemove);
                }
            }
            return false;
        }));

        rules.Add(new CurveRule("ALL", (CurveGameState state, GameEvent eve, CurveGameEngine engine) => {
            return !eve.initiator.StartsWith("player") || (eve.initiator.Equals("player" + state.curPlayer) && state.blockingSound == null);
        }));

        rules.Add(new CurveRule("action", (CurveGameState state, GameEvent eve, CurveGameEngine engine) => {
            if (state.repeating || state.replaying || state.blockingSound != null) {
                return true;
            }
            switch (eve.payload) {
                case "any":
                    if (state.timestamp == 10) {
                        (state.result as CurveGameResult).status = CurveGameResult.GameStatus.Over;
                        return false;
                    }
                    return true;
                case "replay":
                    state.replaying = true;
                    state.index = 0;
                    return false;
                case "repeat":
                    state.repeating = true;
                    state.index = 0;
                    return false;
                case "enter":
                    if (state.timestamp == 1 || state.timestamp >= 9) {
                        return false;
                    }
                    foreach (Actor actor in state.actors) {
                        Vector3 position = actor.position - new Vector3(initial_x, initial_y, 0f);
                        int x = (int)(position.x / offset_x);
                        int y = (int)(position.y / offset_y);
                        if (state.values[x] == state.expectedValues[x]) {
                            engine.state.environment.Add(new CurveSoundObject("Prefabs/Curve/GameAudio", auEngine.getSoundForPlayer("boundary", new Vector3(0, 1, 0)), Vector3.zero));
                        } else {
                            state.values[x] = y;
                            if (state.values[x] == state.expectedValues[x]) {
                                engine.state.environment.Add(new CurveSoundObject("Prefabs/Curve/GameAudio", auEngine.getSoundForPlayer("correct"), Vector3.zero));
                            } else {
                                engine.state.environment.Add(new CurveSoundObject("Prefabs/Curve/GameAudio", auEngine.getSoundForPlayer("note", new Vector3(x, y, 0)), Vector3.zero));
                            }
                        }
                    }
                    int i;
                    for (i = 0; i < 14; i++) {
                        if (state.values[i] != state.expectedValues[i]) {
                            break;
                        }
                    }
                    if (i == 14) {
                        state.timestamp = 9;
                        engine.state.environment.Add(new CurveSoundObject("Prefabs/Curve/GameAudio", auEngine.getSoundForPlayer("claps_1"), Vector3.zero));
                        AudioClip auClip = auEngine.getSoundForMenu("new_game_win");
                        CurveSoundObject tso = new CurveSoundObject("Prefabs/Curve/AudioSource", auClip);
                        state.environment.Add(tso);
                        state.blockingSound = tso;
                    }
                    return false;
            }
            return true;
        }));

        rules.Add(new CurveRule("move", (CurveGameState state, GameEvent eve, CurveGameEngine engine) => {
            if (state.repeating || state.replaying) {
                return false;
            }
            int dx = 0;
            int dy = 0;
            switch (eve.payload) {
                case "left":
                    dx = -1;
                    break;
                case "right":
                    dx = 1;
                    break;
                case "up":
                    dy = 1;
                    break;
                case "down":
                    dy = -1;
                    break;
                default:
                    return false;
            }
            foreach (Actor actor in state.actors) {
                Vector3 position = actor.position - new Vector3(initial_x, initial_y, 0f);
                int x = (int)(position.x / offset_x) + dx;
                int y = (int)(position.y / offset_y) + dy;
                if (x <= -1 || x >= 14 || y <= -1 || y >= 14) {
                    return false;
                }
                actor.position = new Vector3(offset_x * x + initial_x, offset_y * y + initial_y, actor.position.z);
                engine.state.environment.Add(new CurveSoundObject("Prefabs/Curve/GameAudio", auEngine.getSoundForPlayer("note", new Vector3(x, y, 0))));
            }
            return false;
        }));

        gameObject.AddComponent<CurveGameEngine>();
        gameObject.AddComponent<CurveUserInterface>();
        gameObject.GetComponent<CurveGameEngine>().initialize(rules, actors, environment, players, renderer);
        gameObject.GetComponent<CurveUserInterface>().initialize(gameObject.GetComponent<CurveGameEngine>());
        gameObject.GetComponent<CurveGameEngine>().postEvent(new GameEvent("", "initialization", "unity"));
	}
    void Start() {
        CurveStateRenderer renderer = new CurveStateRenderer();
        AudioEngine auEngine = new AudioEngine(0, Settings.game_name, Settings.menu_sounds, Settings.game_sounds);

        List<WorldObject> environment = new List<WorldObject>();
        environment.Add(movingCamera);
        environment.Add(new CurveStaticObject("Prefabs/Curve/Light_Default", new Vector3(0, 10, 0), false));
        environment.Add(new CanvasObject("Prefabs/Curve/Logos", true, new Vector3(10000, 0, 0), false));
        environment.Add(new CurveMenuItem("Prefabs/Curve/ButtonSelected", "5 λεπτά", "newGame", "5", auEngine.getSoundForMenu("new_game_remaining_time_5"), new Vector3(0, 0, -offset_y), false, true));
        environment.Add(new CurveMenuItem("Prefabs/Curve/ButtonDefault", "4 λεπτά", "newGame", "4", auEngine.getSoundForMenu("new_game_remaining_time_4"), new Vector3(0, 0, 0), false, false));
        environment.Add(new CurveMenuItem("Prefabs/Curve/ButtonDefault", "3 λεπτά", "newGame", "3", auEngine.getSoundForMenu("new_game_remaining_time_3"), new Vector3(0, 0, offset_y), false));
        environment.Add(new CurveMenuItem("Prefabs/Curve/ButtonDefault", "2 λεπτά", "newGame", "2", auEngine.getSoundForMenu("new_game_remaining_time_2"), new Vector3(0, 0, 2 * offset_y), false));
        environment.Add(new CurveMenuItem("Prefabs/Curve/ButtonDefault", "1 λεπτό", "newGame", "1", auEngine.getSoundForMenu("new_game_remaining_time_1"), new Vector3(0, 0, 3 * offset_y), false));
        environment.Add(new CurveMenuItem("Prefabs/Curve/ButtonDefault", "Πίσω", "curveSelectionMenu", "back", auEngine.getSoundForMenu("back"), new Vector3(0, 0, 4 * offset_y), false));

        CurveRuleset rules = new CurveRuleset();
        rules.Add(new CurveRule("initialization", (CurveMenuState state, GameEvent eve, CurveMenuEngine engine) => {
            AudioClip audioClip;
            state.timestamp = 0;
            audioClip = auEngine.getSoundForMenu("new_game_select");
            CurveSoundObject tso = new CurveSoundObject("Prefabs/Curve/AudioSource", audioClip, Vector3.zero);
            state.environment.Add(tso);
            state.stoppableSounds.Add(tso);
            Settings.previousMenu = "curveSelectionMenu";
            return false;
        }));

        rules.Add(new CurveRule("soundOver", (CurveMenuState state, GameEvent eve, CurveMenuEngine engine) => {
            if (state.timestamp == 0) {
                AudioClip audioClip = auEngine.getSoundForMenu("new_game_remaining_time_5");
                CurveSoundObject tso = new CurveSoundObject("Prefabs/Curve/AudioSource", audioClip, Vector3.zero);
                state.environment.Add(tso);
                state.stoppableSounds.Add(tso);
                state.timestamp = 1;
            }
            return false;
        }));

        rules.Add(new CurveRule("action", (CurveMenuState state, GameEvent eve, CurveMenuEngine engine) => {
            if (eve.payload.Equals("escape")) {
                Application.LoadLevel("curveSelectionMenu");
                return false;
            }
            return true;
        }));

        rules.Add(new CurveRule("action", (CurveMenuState state, GameEvent eve, CurveMenuEngine engine) => {
            if (eve.payload.Equals("enter")) {
                foreach (WorldObject obj in state.environment) {
                    if (obj is CurveMenuItem) {
                        if ((obj as CurveMenuItem).selected) {
                            int mins;
                            if (Int32.TryParse((obj as CurveMenuItem).audioMessageCode, out mins)) {
                                Settings.time = mins;
                            }
                            Application.LoadLevel((obj as CurveMenuItem).target);
                            return false;
                        }
                    }
                }
            }
            return true;
        }));

        rules.Add(new CurveRule("move", (CurveMenuState state, GameEvent eve, CurveMenuEngine engine) => {
            state.timestamp++;
            foreach (CurveSoundObject Curveso in state.stoppableSounds) {
                state.environment.Remove(Curveso);
            }
            state.stoppableSounds.Clear();
            CurveMenuItem previous = null;
            bool change = false;
            AudioClip audioClip;
            CurveSoundObject tso;
            foreach (WorldObject obj in state.environment) {
                if (obj is CurveMenuItem) {
                    CurveMenuItem temp = obj as CurveMenuItem;
                    if (temp.selected) {
                        if (eve.payload == "_up" || eve.payload == "left") {
                            if (previous == null) {
                                audioClip = auEngine.getSoundForPlayer("boundary", Vector3.up);
                                tso = new CurveSoundObject("Prefabs/Curve/AudioSource", audioClip, Vector3.zero);
                                state.environment.Add(tso);
                                state.stoppableSounds.Add(tso);
                                break;
                            }
                            temp.selected = false;
                            temp.prefab = temp.prefab.Replace("Selected", "Default");
                            previous.selected = true;
                            previous.prefab = previous.prefab.Replace("Default", "Selected");
                            tso = new CurveSoundObject("Prefabs/Curve/AudioSource", previous.audioMessage, Vector3.zero);
                            state.environment.Add(tso);
                            state.stoppableSounds.Add(tso);
                            break;
                        } else {
                            change = true;
                        }
                    } else if (change) {
                        temp.selected = true;
                        temp.prefab = temp.prefab.Replace("Default", "Selected");
                        previous.prefab = previous.prefab.Replace("Selected", "Default");
                        previous.selected = false;
                        change = false;
                        tso = new CurveSoundObject("Prefabs/Curve/AudioSource", temp.audioMessage, Vector3.zero);
                        state.environment.Add(tso);
                        state.stoppableSounds.Add(tso);
                        break;
                    }
                    previous = temp;
                }
            }
            if (change) {
                audioClip = auEngine.getSoundForPlayer("boundary", Vector3.down);
                tso = new CurveSoundObject("Prefabs/Curve/AudioSource", audioClip, Vector3.zero);
                state.environment.Add(tso);
                state.stoppableSounds.Add(tso);
            }
            foreach (WorldObject obj in state.environment) {
                if (obj is CurveMenuItem) {
                    CurveMenuItem temp = obj as CurveMenuItem;
                    if (temp.selected) {
                        movingCamera.position = new Vector3(0, 10, Mathf.Clamp(temp.position.z, 6 * offset_y, 0));
                        break;
                    }
                }
            }
            return true;
        }));

        gameObject.AddComponent<CurveMenuEngine>();
        gameObject.AddComponent<CurveMenuUserInterface>();
        gameObject.GetComponent<CurveMenuEngine>().initialize(rules, environment, renderer);
        gameObject.GetComponent<CurveMenuUserInterface>().initialize(gameObject.GetComponent<CurveMenuEngine>());
        gameObject.GetComponent<CurveMenuEngine>().postEvent(new GameEvent("", "initialization", "unity"));
    }
    void Start() {
        CurveStateRenderer renderer = new CurveStateRenderer();
        AudioEngine auEngine = new AudioEngine(0, Settings.game_name, Settings.menu_sounds, Settings.game_sounds);

        List<WorldObject> environment = new List<WorldObject>();
        environment.Add(new CurveStaticObject("Prefabs/Curve/Camera_Default", new Vector3(0, 10, 0), false));
        environment.Add(new CurveStaticObject("Prefabs/Curve/Light_Default", new Vector3(0, 10, 0), false));
        environment.Add(new CanvasObject("Prefabs/Curve/Logos", true, new Vector3(10000, 0, 0), false));
        environment.Add(new CurveMenuItem("Prefabs/Curve/ButtonSelected", "Οδηγίες", "tutorial", "tutorials", auEngine.getSoundForMenu("tutorials"), new Vector3(0, 0, -offset_y), false, true));
        environment.Add(new CurveMenuItem("Prefabs/Curve/ButtonDefault", "Νέο Παιχνίδι", "curveSelectionMenu", "new_game", auEngine.getSoundForMenu("new_game"), new Vector3(0, 0, 0), false));        
        environment.Add(new CurveMenuItem("Prefabs/Curve/ButtonDefault", "Έξοδος", "exitScene", "exit", auEngine.getSoundForMenu("exit"), new Vector3(0, 0, offset_y), false));

        CurveRuleset rules = new CurveRuleset();
        rules.Add(new CurveRule("initialization", (CurveMenuState state, GameEvent eve, CurveMenuEngine engine) => {
            AudioClip audioClip;
            if (Settings.just_started) {
                Settings.just_started = false;
                audioClip = auEngine.getSoundForMenu("game_intro");
                state.timestamp = 0;
            } else {
                audioClip = auEngine.getSoundForMenu("tutorials");
                state.timestamp = 1;
            }
            CurveSoundObject tso = new CurveSoundObject("Prefabs/Curve/AudioSource", audioClip, Vector3.zero);
            state.environment.Add(tso);
            state.stoppableSounds.Add(tso);
            Settings.previousMenu = "mainMenu";
            return false;
        }));

        rules.Add(new CurveRule("soundSettings", (CurveMenuState state, GameEvent eve, CurveMenuEngine engine) => {
            Settings.menu_sounds = eve.payload;
            auEngine = new AudioEngine(0, "curve", Settings.menu_sounds, Settings.game_sounds);
            foreach (WorldObject wo in state.environment) {
                if (wo is CurveMenuItem) {
                    (wo as CurveMenuItem).audioMessage = auEngine.getSoundForMenu((wo as CurveMenuItem).audioMessageCode);
                }
            }
            return false;
        }));

        rules.Add(new CurveRule("soundOver", (CurveMenuState state, GameEvent eve, CurveMenuEngine engine) => {
            if (state.timestamp == 0) {
                AudioClip audioClip = auEngine.getSoundForMenu("tutorials");
                CurveSoundObject tso = new CurveSoundObject("Prefabs/Curve/AudioSource", audioClip, Vector3.zero);
                state.environment.Add(tso);
                state.stoppableSounds.Add(tso);
                state.timestamp = 1;
            }
            return false;
        }));

        rules.Add(new CurveRule("action", (CurveMenuState state, GameEvent eve, CurveMenuEngine engine) => {
            if (eve.payload.Equals("escape")) {
                Application.LoadLevel("mainMenu");
                return false;
            }
            return true;
        }));

        rules.Add(new CurveRule("action", (CurveMenuState state, GameEvent eve, CurveMenuEngine engine) => {
            if (eve.payload.Equals("enter")) {
                foreach (WorldObject obj in state.environment) {
                    if (obj is CurveMenuItem) {
                        if ((obj as CurveMenuItem).selected) {
                            Application.LoadLevel((obj as CurveMenuItem).target);
                            return false;
                        }
                    }
                }
            }
            return true;
        }));

        rules.Add(new CurveRule("move", (CurveMenuState state, GameEvent eve, CurveMenuEngine engine) => {
            state.timestamp++;
            foreach (CurveSoundObject Curveso in state.stoppableSounds) {
                state.environment.Remove(Curveso);
            }
            state.stoppableSounds.Clear();
            CurveMenuItem previous = null;
            bool change = false;
            AudioClip audioClip;
            CurveSoundObject tso;
            foreach (WorldObject obj in state.environment) {
                if (obj is CurveMenuItem) {
                    CurveMenuItem temp = obj as CurveMenuItem;
                    if (temp.selected) {
                        if (eve.payload == "_up" || eve.payload == "left") {
                            if (previous == null) {
                                audioClip = auEngine.getSoundForPlayer("boundary", Vector3.up);
                                tso = new CurveSoundObject("Prefabs/Curve/AudioSource", audioClip, Vector3.zero);
                                state.environment.Add(tso);
                                state.stoppableSounds.Add(tso);
                                break;
                            }
                            temp.selected = false;
                            temp.prefab = temp.prefab.Replace("Selected", "Default");
                            previous.selected = true;
                            previous.prefab = previous.prefab.Replace("Default", "Selected");
                            tso = new CurveSoundObject("Prefabs/Curve/AudioSource", previous.audioMessage, Vector3.zero);
                            state.environment.Add(tso);
                            state.stoppableSounds.Add(tso);
                            break;
                        } else {
                            change = true;
                        }
                    } else if (change) {
                        temp.selected = true;
                        temp.prefab = temp.prefab.Replace("Default", "Selected");
                        previous.prefab = previous.prefab.Replace("Selected", "Default");
                        previous.selected = false;
                        change = false;
                        tso = new CurveSoundObject("Prefabs/Curve/AudioSource", temp.audioMessage, Vector3.zero);
                        state.environment.Add(tso);
                        state.stoppableSounds.Add(tso);
                        break;
                    }
                    previous = temp;
                }
            }
            if (change) {
                audioClip = auEngine.getSoundForPlayer("boundary", Vector3.down);
                tso = new CurveSoundObject("Prefabs/Curve/AudioSource", audioClip, Vector3.zero);
                state.environment.Add(tso);
                state.stoppableSounds.Add(tso);
            }
            return true;
        }));

        gameObject.AddComponent<CurveMenuEngine>();
        gameObject.AddComponent<CurveMenuUserInterface>();
        gameObject.GetComponent<CurveMenuEngine>().initialize(rules, environment, renderer);
        gameObject.GetComponent<CurveMenuUserInterface>().initialize(gameObject.GetComponent<CurveMenuEngine>());
        gameObject.GetComponent<CurveMenuEngine>().postEvent(new GameEvent("", "initialization", "unity"));
    }