Ejemplo n.º 1
0
    //Run when the program is unloaded or closed
    public override void Exit()
    {
        //Set up the camera follow for hte player
        CameraEvent cei = new CameraEvent();

        //cei.target = (Node2D)player.GetParent().GetParent().GetParent();
        cei.target = GetNode <Node2D>("../../../Main");
        cei.FireEvent();
        //Call program event and pass along the movement data to the run state
        SendProgramEvent pei = new SendProgramEvent();

        pei.leftInputTimer  = leftInputTimer;
        pei.rightInputTimer = rightInputTimer;
        pei.upInputTimer    = upInputTimer;
        pei.downInputTimer  = downInputTimer;
        pei.lmbInputTimer   = lmbInputTimer;
        pei.rmbInputTimer   = rmbInputTimer;
        pei.mousePosTimer   = mousePosTimer;
        pei.FireEvent();
        //Hide the programing map
        displayMap.Visible = false;
        //Unregister the keyboard and mouse position input methods
        InputCallbackEvent.UnregisterListener(GrabInput);
        MouseInputCallbackEvent.UnregisterListener(GrabMouseInput);
    }
Ejemplo n.º 2
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();
    }
Ejemplo n.º 3
0
    private void StopGame()
    {
        map.QueueFree();
        //Change the shader for the end game screens
        SetShaderEvent ssei = new SetShaderEvent();

        ssei.showBlurAndWater = true;
        ssei.FireEvent();

        ((Node2D)camera).Position = new Vector2(640, 360);
        //Set the camera back to the main scene
        CameraEvent cei = new CameraEvent();

        //cei.target = (Node2D)redBlob.GetParent();
        cei.target = (Node2D)this;
        cei.dragMarginHorizontal = false;
        cei.dragMarginVertical   = false;
        cei.FireEvent();

        for (int i = 0; i < blueBlobsList.Count; i++)
        {
            blueBlobsList[i].QueueFree();
        }
        for (int i = 0; i < greenBlobList.Count; i++)
        {
            greenBlobList[i].QueueFree();
        }

        redBlob.QueueFree();
    }
Ejemplo n.º 4
0
    private void StartGame()
    {
        SetShaderEvent ssei = new SetShaderEvent();

        ssei.showBlur = true;
        ssei.FireEvent();
        //Instance the map and set it as a child of the main scene
        map = mapScene.Instance();
        //Set the map as the child of the main scene
        AddChild(map);
        //Instance thet reb blob scene
        redBlob = redBlobScene.Instance();
        //Set the blobs spawn position
        ((Node2D)redBlob).Position = new Vector2(300, 300);
        //Add the reb blob as a child of the main scene
        AddChild(redBlob);

        ((Node2D)camera).Position = new Vector2(0, 0);
        CameraEvent cei = new CameraEvent();

        cei.target = (Node2D)redBlob;
        cei.dragMarginHorizontal = true;
        cei.dragMarginVertical   = true;
        cei.FireEvent();

        SpawnGreenBlobs();
        SpawnBlueBlobs();
    }
Ejemplo n.º 5
0
    private void InstatiateScenes()
    {
        //Init needed background sytems
        //Instance the input manager and set it as a child of the main scene
        inputManager = inputManagerScene.Instance();
        //Set the input manager as the child of the main scene
        AddChild(inputManager);
        //Instance the map and set it as a child of the main scene
        camera = cameraScene.Instance();
        ((Node2D)camera).Position = new Vector2(640, 360);
        //Set the camera as the child of the main scene
        AddChild(camera);
        //Set the camera back to the main scene
        CameraEvent cei = new CameraEvent();

        //cei.target = (Node2D)redBlob.GetParent();
        cei.target = (Node2D)this;
        cei.FireEvent();
        //Instance the UI manager and set it as a child of the main scene
        uiManager = uiManagerScene.Instance();
        //Set the UI manager as the child of the main scene
        AddChild(uiManager);
        //Instance the sound manager and set it as a child of the main scene
        soundManager = soundManagerScene.Instance();
        //Set the sound manager as the child of the main scene
        AddChild(soundManager);
        //Create the background and set it as a child of the main scene
        background = backgroundScene.Instance();
        AddChild(background);


        //Instance the fullscreenshader and set it as a child of the main scene
        fullscreenShader = fullscreenShaderScene.Instance();
        //Set the map as the child of the main scene
        AddChild(fullscreenShader);
        SetShaderEvent ssei = new SetShaderEvent();

        ssei.showBlurAndWater = true;
        ssei.FireEvent();

        PlayAudioEvent paei = new PlayAudioEvent();

        paei.musicType = MusicType.MENU;
        paei.FireEvent();
    }
Ejemplo n.º 6
0
    //Run when the state starts up
    public override void Init()
    {
        //We use the event manager to grab the values, we do not call the fire event
        //becuase we dont want to store any new values just get the current ones
        GetProgramEvent gpei = new GetProgramEvent();

        gpei.FireEvent();
        leftInputTimer  = gpei.leftInputTimer;
        rightInputTimer = gpei.rightInputTimer;
        upInputTimer    = gpei.upInputTimer;
        downInputTimer  = gpei.downInputTimer;
        lmbInputTimer   = gpei.lmbInputTimer;
        rmbInputTimer   = gpei.rmbInputTimer;
        mousePosTimer   = gpei.mousePosTimer;

        //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/ProgramMap");

        RealMap.QueueFree();
        displayMap         = GetNode <TileMap>("Map/RealMap");
        displayMap.Visible = true;
        droidScene         = ResourceLoader.Load("res://Scenes/Droid.tscn") as PackedScene;
        gunTurretScene     = ResourceLoader.Load("res://Scenes/Enemies/GunTurret.tscn") as PackedScene;
        laserTurretScene   = ResourceLoader.Load("res://Scenes/Enemies/LaserTurret.tscn") as PackedScene;
        goalScene          = ResourceLoader.Load("res://Scenes/Goal.tscn") as PackedScene;


        //Instance player and gun towers
        BuildMap();
        //Set up the camera follow for hte player
        CameraEvent cei = new CameraEvent();

        cei.target = (Node2D)droid;
        cei.FireEvent();

        //enemyScene = ResourceLoader.Load("res://Scenes/Enemy.tscn") as PackedScene;

        //Grab the time the state started after all the initializations have completely run
        timerStarted = OS.GetTicksMsec();
    }