Esempio n. 1
0
    private void ChangeState(SendUIEvent suiei)
    {
        //Hide all the ui screens
        HideAllUI();
        //Set the current ui state
        currentState = suiei.uiState;
        //Depending on the state show the needed ui element
        switch (currentState)
        {
        case UIState.MENU:
            menu.Show();
            break;

        case UIState.WAIT_HUD:
            wait.Show();
            break;

        case UIState.PROGRAMMING_HUD:
            programming.Show();
            break;

        case UIState.RUN_HUD:
            run.Show();
            break;

        case UIState.WIN:
            win.Show();
            break;

        case UIState.LOSE:
            lose.Show();
            break;
        }
    }
Esempio n. 2
0
    private void Init()
    {
        //Instance the game state manager and add it as a child to the main scene
        GameStateManagerNode = GameStateManagerScene.Instance();
        AddChild(GameStateManagerNode);
        //Instance the camera for the main scene and add it to the main scene as a child
        camera = camerScene.Instance();
        AddChild(camera);

        //States for the games recording mechanic -------------------------------
        gameEmptyState   = GameEmptyStateScene.Instance();
        gameWaitState    = GameWaitStateScene.Instance();
        gameProgramState = GameProgramStateScene.Instance();
        gameRunState     = GameRunStateScene.Instance();

        gameStateManager = GetNode <GameStateManager>("GameStateManager");
        //Init the ui state manager to the menu state
        gameStateManager.Init(gameEmptyState);
        //The UI of the game
        ui = uiScene.Instance();
        AddChild(ui);
        //At the begining of hte program set the ui state to the menu ui elemenet
        SendUIEvent suiei = new SendUIEvent();

        suiei.uiState = UIState.MENU;
        suiei.FireEvent();
    }
Esempio n. 3
0
    //Run when the recording starts up
    public override void Init()
    {
        //Regestrations for the events needed for the scene ===========================================================
        InputCallbackEvent.RegisterListener(GrabInput);
        MouseInputCallbackEvent.RegisterListener(GrabMouseInput);
        //=============================================================================================================
        //Preload the scenes for the state to be used =================================================================
        //Load the map resource scene and instance it as a child of the GameProgramState node
        mapScene = ResourceLoader.Load("res://Scenes/Map.tscn") as PackedScene;
        map      = mapScene.Instance();
        AddChild(map);
        TileMap RealMap = GetNode <TileMap>("Map/RealMap");

        RealMap.QueueFree();
        displayMap         = GetNode <TileMap>("Map/ProgramMap");
        displayMap.Visible = true;
        playerScene        = ResourceLoader.Load("res://Scenes/Player.tscn") as PackedScene;
        //=============================================================================================================
        //Set the ui state to the programming hud =====================================================================
        SendUIEvent suiei = new SendUIEvent();

        suiei.uiState = UIState.PROGRAMMING_HUD;
        suiei.FireEvent();
        //=============================================================================================================
        //Grab the time the program started recording the time for hte user input
        timerStarted = OS.GetTicksMsec();

        BuildMap();

        //Set up the camera follow for hte player
        CameraEvent cei = new CameraEvent();

        cei.target = (Node2D)player;
        cei.FireEvent();
    }
Esempio n. 4
0
 private void StartGame(SendUIEvent suiei)
 {
     if (suiei.startGame)
     {
         SpawnScenes();
     }
 }
Esempio n. 5
0
    //Run when the state starts up
    public override void Init()
    {
        //Set the ui state to the wait hud state
        SendUIEvent suiei = new SendUIEvent();

        suiei.uiState = UIState.WAIT_HUD;
        suiei.FireEvent();
    }
Esempio n. 6
0
    private void WinGame(WinEvent wei)
    {
        gameStateManager.ChangeState(gameEmptyState);
        SendUIEvent suiei = new SendUIEvent();

        suiei.uiState = UIState.WIN;
        suiei.FireEvent();
    }
Esempio n. 7
0
    private void ShowWinScreen(WinEvent wei)
    {
        HideAll();
        winScreen.Show();
        SendUIEvent suiei = new SendUIEvent();

        suiei.showWinScreen = true;
        suiei.FireEvent();
    }
Esempio n. 8
0
    private void ShowMenu()
    {
        HideAll();
        menu.Show();
        SendUIEvent suiei = new SendUIEvent();

        suiei.showMenu = true;
        suiei.FireEvent();
    }
Esempio n. 9
0
 private void LoseGame(DeathEvent dei)
 {
     if (dei.target.IsInGroup("Player"))
     {
         gameStateManager.ChangeState(gameEmptyState);
         SendUIEvent suiei = new SendUIEvent();
         suiei.uiState = UIState.LOSE;
         suiei.FireEvent();
     }
 }
Esempio n. 10
0
    private void RunPressed(RunEvent rei)
    {
        gameStateManager.ChangeState(gameRunState);

        //At the begining of hte program set the ui state to the menu ui elemenet
        SendUIEvent suiei = new SendUIEvent();

        suiei.uiState = UIState.RUN_HUD;
        suiei.FireEvent();
    }
Esempio n. 11
0
    private void ShowUI()
    {
        HideAll();
        ui.Show();
        SendUIEvent suiei = new SendUIEvent();

        suiei.showUI    = true;
        suiei.startGame = true;
        suiei.FireEvent();
    }
Esempio n. 12
0
 private void ShowDeathScreen(DeathEvent dei)
 {
     if (dei.target.IsInGroup("Player"))
     {
         HideAll();
         DeathScreen.Show();
         SendUIEvent suiei = new SendUIEvent();
         suiei.showDeathScreen = true;
         suiei.FireEvent();
     }
 }
Esempio n. 13
0
    public override void _Ready()
    {
        //Referencing all the displays in the UI node for later use
        menu        = GetNode <VBoxContainer>("Menu");
        wait        = GetNode <VBoxContainer>("Wait");
        programming = GetNode <Node2D>("Programming");
        run         = GetNode <Node2D>("Run");
        win         = GetNode <Node2D>("Win");
        lose        = GetNode <Node2D>("Lose");

        SendUIEvent.RegisterListener(ChangeState);
        SendProgramEvent.RegisterListener(GetProgram);
    }
Esempio n. 14
0
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        //Pre load the scenes for the game
        playerScene   = ResourceLoader.Load("res://Scenes/Player.tscn") as PackedScene;
        mapScene      = ResourceLoader.Load("res://Scenes/Map.tscn") as PackedScene;
        enemyScene    = ResourceLoader.Load("res://Scenes/Enemy.tscn") as PackedScene;
        artifactScene = ResourceLoader.Load("res://Scenes/Artifact.tscn") as PackedScene;
        uiScene       = ResourceLoader.Load("res://Scenes/UI.tscn") as PackedScene;
        //The UI of the game
        ui = uiScene.Instance();
        AddChild(ui);

        SendUIEvent.RegisterListener(StartGame);
        DeathEvent.RegisterListener(LoseGame);
        WinEvent.RegisterListener(WinGame);
    }
Esempio n. 15
0
 public override void _ExitTree()
 {
     SendUIEvent.UnregisterListener(ChangeState);
     SendProgramEvent.UnregisterListener(GetProgram);
 }
Esempio n. 16
0
 public override void _ExitTree()
 {
     SendUIEvent.UnregisterListener(StartGame);
     DeathEvent.UnregisterListener(LoseGame);
     WinEvent.RegisterListener(WinGame);
 }