Exemple #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);
    }
Exemple #2
0
    public override void _Input(Godot.InputEvent @event)
    {
        if (@event is InputEventMouseButton || @event is InputEventKey)
        {
            InputCallbackEvent icei = new InputCallbackEvent();
            if (@event.IsActionPressed("LeftMouseButton"))
            {
                icei.lmbClickPressed = true;
            }
            if (@event.IsActionReleased("LeftMouseButton"))
            {
                icei.lmbClickRelease = true;
            }
            if (@event.IsActionPressed("RightMouseButton"))
            {
                icei.rmbClickPressed = true;
            }

            /*
             * if (@event.IsActionReleased("RightMouseButton")) icei.rmbClickRelease = true;
             * if (@event.IsActionPressed("MoveUp")) icei.upPressed = true;
             * if (@event.IsActionReleased("MoveUp")) icei.upRelease = true;
             * if (@event.IsActionPressed("MoveDown")) icei.downPressed = true;
             * if (@event.IsActionReleased("MoveDown")) icei.downRelease = true;
             * if (@event.IsActionPressed("MoveLeft")) icei.leftPressed = true;
             * if (@event.IsActionReleased("MoveLeft")) icei.leftRelease = true;
             * if (@event.IsActionPressed("MoveRight")) icei.rightPressed = true;
             * if (@event.IsActionReleased("MoveRight")) icei.rightRelease = true;
             */
            icei.FireEvent();
        }
    }
Exemple #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();
    }
Exemple #4
0
 private void GetMouseButtonInput(InputCallbackEvent icei)
 {
     if (icei.lmbClickPressed)
     {
         //Instance bullet, set the rotation and start position
         bullet = bulletScene.Instance();
         this.GetParent().AddChild(bullet);
     }
 }
Exemple #5
0
 private void GetInput(InputCallbackEvent icei)
 {
     if (icei.lmbClickPressed)
     {
         //Call the mouse click event for the player
         MouseClickEvent mcei = new MouseClickEvent();
         mcei.clickPos = GetGlobalMousePosition();
         mcei.FireEvent();
     }
 }
Exemple #6
0
    private void GrabInput(InputCallbackEvent icei)
    {
        //The timestamp is worked out by getting the current tick and subtracting the start of the session tick amount
        ulong timeStamp = OS.GetTicksMsec() - timerStarted;

        if (icei.leftPressed)
        {
            leftInputTimer.Add(timeStamp, InputActions.LEFT_PRESSED);
        }
        if (icei.leftRelease)
        {
            leftInputTimer.Add(timeStamp, InputActions.LEFT_RELEASED);
        }
        if (icei.rightPressed)
        {
            rightInputTimer.Add(timeStamp, InputActions.RIGHT_PRESSED);
        }
        if (icei.rightRelease)
        {
            rightInputTimer.Add(timeStamp, InputActions.RIGHT_RELEASED);
        }
        if (icei.upPressed)
        {
            upInputTimer.Add(timeStamp, InputActions.UP_PRESSED);
        }
        if (icei.upRelease)
        {
            upInputTimer.Add(timeStamp, InputActions.UP_RELEASED);
        }
        if (icei.downPressed)
        {
            downInputTimer.Add(timeStamp, InputActions.DOWN_PRESSED);
        }
        if (icei.downRelease)
        {
            downInputTimer.Add(timeStamp, InputActions.DOWN_RELEASED);
        }
        if (icei.lmbClickPressed)
        {
            lmbInputTimer.Add(timeStamp, InputActions.LEFT_CLICK_PRESSED);
        }
        if (icei.lmbClickRelease)
        {
            lmbInputTimer.Add(timeStamp, InputActions.LEFT_CLICK_RELEASED);
        }
        if (icei.rmbClickPressed)
        {
            rmbInputTimer.Add(timeStamp, InputActions.RIGHT_CLICK_PRESSED);
        }
        if (icei.rmbClickRelease)
        {
            rmbInputTimer.Add(timeStamp, InputActions.RIGHT_CLICK_RELEASED);
        }
    }
Exemple #7
0
 private void GrabInput(InputCallbackEvent icei)
 {
     if (icei.lmbClickPressed)
     {
         dragging     = true;
         dragComplete = false;
     }
     if (icei.lmbClickRelease && dragging)
     {
         dragComplete = true;
         dragEndPos   = GetGlobalMousePosition();
     }
     if (icei.rmbClickPressed && dragging)
     {
         dragCanceled = true;
         dragStartPos = Vector2.Zero;
         dragEndPos   = Vector2.Zero;
         dragging     = false;
         dragComplete = false;
     }
 }
Exemple #8
0
    private void GetInput(InputCallbackEvent icei)
    {
        if (icei.upPressed)
        {
            up = true;
        }
        else if (icei.upRelease)
        {
            up = false;
        }

        if (icei.downPressed)
        {
            down = true;
        }
        else if (icei.downRelease)
        {
            down = false;
        }

        if (icei.leftPressed)
        {
            left = true;
        }
        else if (icei.leftRelease)
        {
            left = false;
        }

        if (icei.rightPressed)
        {
            right = true;
        }
        else if (icei.rightRelease)
        {
            right = false;
        }
    }
Exemple #9
0
 public override void _ExitTree()
 {
     InputCallbackEvent.UnregisterListener(GrabInput);
 }
Exemple #10
0
 // Called when the node enters the scene tree for the first time.
 public override void _Ready()
 {
     //Register with the input event system to listen to event messages
     InputCallbackEvent.RegisterListener(GrabInput);
 }
Exemple #11
0
 // Called when the node enters the scene tree for the first time.
 public override void _Ready()
 {
     InputCallbackEvent.RegisterListener(GetInput);
     MouseInputCallbackEvent.RegisterListener(GetMousePos);
 }
Exemple #12
0
 public override void _ExitTree()
 {
     InputCallbackEvent.UnregisterListener(GetInput);
     MouseInputCallbackEvent.UnregisterListener(GetMousePos);
 }
Exemple #13
0
    public override void _Input(Godot.InputEvent @event)
    {
        if (@event is InputEventMouseButton || @event is InputEventKey)
        {
            icei = new InputCallbackEvent();
            if (@event.IsActionPressed("LeftClick"))
            {
                icei.lmbClickPressed = true;
            }
            if (@event.IsActionReleased("LeftClick"))
            {
                icei.lmbClickRelease = true;
            }
            if (@event.IsActionPressed("RightClick"))
            {
                icei.rmbClickPressed = true;
            }
            if (@event.IsActionReleased("RightClick"))
            {
                icei.rmbClickRelease = true;
            }
            if (@event.IsActionPressed("MoveUp"))
            {
                icei.upPressed = true;
            }
            if (@event.IsActionReleased("MoveUp"))
            {
                icei.upRelease = true;
            }
            if (@event.IsActionPressed("MoveDown"))
            {
                icei.downPressed = true;
            }
            if (@event.IsActionReleased("MoveDown"))
            {
                icei.downRelease = true;
            }
            if (@event.IsActionPressed("MoveLeft"))
            {
                icei.leftPressed = true;
            }
            if (@event.IsActionReleased("MoveLeft"))
            {
                icei.leftRelease = true;
            }
            if (@event.IsActionPressed("MoveRight"))
            {
                icei.rightPressed = true;
            }
            if (@event.IsActionReleased("MoveRight"))
            {
                icei.rightRelease = true;
            }
            icei.FireEvent();

            if (!mouseUpdateCalled)
            {
                mouseUpdateCalled = true;
                mouseUpdate();
                mouseUpdateCalled = false;
            }
        }
        if (@event is InputEventMouseMotion)
        {
            //Update the mouse position only if the mouse update function is not running yet
            if (!mouseUpdateCalled)
            {
                mouseUpdateCalled = true;
                mouseUpdate();
                mouseUpdateCalled = false;
            }
        }
    }
Exemple #14
0
 // Called when the node enters the scene tree for the first time.
 public override void _Ready()
 {
     InputCallbackEvent.RegisterListener(GetMouseButtonInput);
     bulletScene = ResourceLoader.Load("res://Scenes/BulletProgram.tscn") as PackedScene;
 }