Пример #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);
    }
Пример #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();
    }
Пример #3
0
    private void GrabMouseInput(MouseInputCallbackEvent micei)
    {
        //The timestamp is worked out by getting the current tick and subtracting the start of the session tick amount
        ulong timeStamp = OS.GetTicksMsec() - timerStarted;

        //Due to the timestamp being the key for the dictionary we have to make sure there are no duplicate keys or we will get and error
        //so we check if 10 seconds have passed and if they have only then do we add a new entry into the dictionary then we reset
        //the lastMousePosTimeEntry to the latest time of entry
        mousePosTimer.Add(timeStamp, micei.mousePos);
    }
Пример #4
0
 private void mouseUpdate()
 {
     micei = new MouseInputCallbackEvent();
     //If 10 mirco econds have not passed yet then return out of the mouseUpdate method
     //if(OS.GetTicksMsec() - lastMousePosTimeEntry <= 10) return;
     if (OS.GetTicksMsec() - lastMousePosTimeEntry <= 20)
     {
         return;
     }
     micei.mousePos = GetGlobalMousePosition();
     micei.FireEvent();
     lastMousePosTimeEntry = OS.GetTicksMsec();
 }
Пример #5
0
 private void GetMousePos(MouseInputCallbackEvent micei)
 {
     globalMousePos = micei.mousePos;
 }
Пример #6
0
 // Called when the node enters the scene tree for the first time.
 public override void _Ready()
 {
     InputCallbackEvent.RegisterListener(GetInput);
     MouseInputCallbackEvent.RegisterListener(GetMousePos);
 }
Пример #7
0
 public override void _ExitTree()
 {
     InputCallbackEvent.UnregisterListener(GetInput);
     MouseInputCallbackEvent.UnregisterListener(GetMousePos);
 }