Beispiel #1
0
 // --- Inherited Methods ---
 // Handles the control's input
 public override void handleInput(ref InputArgs args)
 {
     bounds=	new Rectangle(
         args.mouse.Position.X+xPad,
         args.mouse.Position.Y+yPad,
         size.X,
         size.Y
     );
 }
 private void input(InputArgs args)
 {
     if(args.isKeyDown(Buttons.A))
     {
         Console.WriteLine(GamePad.GetCapabilities(PlayerIndex.One).HasRightVibrationMotor);
     }
     if(args.isKeyDown(Keys.U))
         effect.Parameters["ambientIntensity"].SetValue(
             MathHelper.Clamp(effect.Parameters["ambientIntensity"].GetValueSingle()+0.01f, 0f, 1f)
         );
     if(args.isKeyDown(Keys.O))
         effect.Parameters["ambientIntensity"].SetValue(
             MathHelper.Clamp(effect.Parameters["ambientIntensity"].GetValueSingle()-0.01f, 0f, 1f)
         );
     if(args.isKeyDown(Keys.Space))
     {
         //camera.pos+=	Vector3.UnitY*4;
         camera.moveKeepLookAt(Vector3.UnitY*4);
     }
 }
Beispiel #3
0
 // Justs ticks away
 private void tickUp(Control ctrl, InputArgs args)
 {
     if(tick< 10)
         tick++;
 }
Beispiel #4
0
        // Gets the input arguments
        public InputArgs getInputArgs()
        {
            // Variables
            InputArgs	args=	new InputArgs();

            args.keyboard=	Keyboard.GetState();
            args.mouse=	Mouse.GetState();
            args.gamepads=	new GamePadState[4];
            args.gamepads[0]=	GamePad.GetState(PlayerIndex.One);
            args.gamepads[1]=	GamePad.GetState(PlayerIndex.Two);
            args.gamepads[2]=	GamePad.GetState(PlayerIndex.Three);
            args.gamepads[3]=	GamePad.GetState(PlayerIndex.Four);
            args.oldScrollData=	lastScrollData;
            lastScrollData=	args.mouse.ScrollWheelValue;
            args.lastMousePosition=	lastMousePosition;
            lastMousePosition=	args.mouse.Position;

            return args;
        }
Beispiel #5
0
        // Handles the input of the game state
        public override void onHandleInput(InputArgs args)
        {
            bCenterOverride=	(stage== 1);

            if(!isUsingGamepad)
            {
                if(args.isAnyKeyDownForGamepad(0, true) || isKeysDown_menuMovement(ref args))
                {
                    isUsingGamepad=	true;
                }
            }
            else
            {
                if(args.isAnyKeyDownForMouse(true))
                {
                    isUsingGamepad=	false;
                    bCenterOverride=	true;
                }
            }

            if(!bCenterOverride)
                args.centerMouse(game);
            if(isUsingGamepad || stage!= 1)
                args.hideMouse(game);
            else
                args.showMouse(game);

            if(ticks[0]>= 8)
            {
                if(isKeysDown_moveUp(ref args))
                {
                    ticks[0]=	0;
                    moveCameraTo(camSel[0], camSel[1]+1);
                }

                if(isKeysDown_moveRight(ref args))
                {
                    ticks[0]=	0;
                    moveCameraTo(camSel[0]+1, camSel[1]);
                }

                if(isKeysDown_moveDown(ref args))
                {
                    ticks[0]=	0;
                    moveCameraTo(camSel[0], camSel[1]-1);
                }

                if(isKeysDown_moveLeft(ref args))
                {
                    ticks[0]=	0;
                    moveCameraTo(camSel[0]-1, camSel[1]);
                }
            }
            else
                ticks[0]++;

            if(
                (args.isKeyDown(MouseButtons.WheelDown) || args.isKeyDown(Keys.OemMinus) || args.isKeyDown(Buttons.LeftTrigger)) &&
                game.cameras.current.pos.Y< 757f
            ) // Scroll out
            {
                game.cameras.current.move(-0.1f*forward);
            }
            if(
                (args.isKeyDown(MouseButtons.WheelUp) || args.isKeyDown(Keys.OemPlus) || args.isKeyDown(Buttons.RightTrigger)) &&
                game.cameras.current.pos.Y> 320f
            ) // Scroll in
            {
                game.cameras.current.move(0.1f*forward);
            }

            if(map.currTeamID!= playerTeamID || !map.allowPlayerInput || map.hasAnyUncontrollableUnits(playerTeamID))
                return;

            game.gui.handleInput(args);

            // Selecting
            if(!holds[0] && isKeysDown_confirm(ref args) && (stage!= 1 || stage!= 4))
            {
                if(map.tiles.items[camSel[0], camSel[1]].item!= null)
                    interactWithTile(ref map.tiles.items[camSel[0], camSel[1]], ref args);

                holds[0]=	true;
            }
            else if(holds[0] && (args.isKeyUp(MouseButtons.Left) && args.isKeyUp(Buttons.A) && args.isKeyUp(Keys.Enter)))
                holds[0]=	false;

            if(!holds[4] && isKeysDown_confirm(ref args))
                holds[4]=	true;
            else if(holds[4] && (args.isKeyUp(Keys.Enter) && args.isKeyUp(Buttons.A) && args.isKeyUp(MouseButtons.Left)))
                holds[4]=	false;

            switch(stage)
            {
                case 0:	{
                    // Open Main Menu
                };break;
                case 1:	{
                    if(!holds[4])
                        holds[5]=	true;
                    if(args.isKeyUp(Keys.Escape) && args.isKeyUp(Buttons.B) && args.isKeyUp(MouseButtons.Right))
                    {
                        holds[3]=	false;
                        if(prevStage== 1)
                            prevStage=	0;
                        if(prevStage== 4)
                        {
                            prevStage=	0;
                            stage=	3;
                        }
                    }
                    else if(!holds[3] && isKeysDown_cancel(ref args))
                    {
                        if(prevStage== 1)
                            return;
                        holds[4]=	false;
                        stage=	0;
                        game.gui.close("player_unit_menu");
                        game.gui.close("enemy_unit_menu");
                    }

                }break;
                case 2:
                case 3:	{
                    if(!holds[3] && isKeysDown_cancel(ref args))
                    {
                        holds[3]=	true;
                        moveCameraTo(
                            map.teams.items[selUnit[0]].units.items[selUnit[1]].mapPos[0],
                            map.teams.items[selUnit[0]].units.items[selUnit[1]].mapPos[1]
                        );
                        map.destroyPaths();
                        if(isPlayer)
                            playerUnitGui.open();
                        else
                            enemyUnitGui.open();

                        if(stage== 3)
                            skillsGui.open(ref selUnit);
                        bCenterOverride=	true;
                        stage=	1;
                    }
                    else if(holds[3] && args.isKeyUp(Keys.Escape) && args.isKeyUp(Buttons.B) && args.isKeyUp(MouseButtons.Right))
                        holds[3]=	false;
                }break;
                case 4:	{
                    if(!holds[3] && isKeysDown_cancel(ref args))
                    {
                        holds[3]=	true;
                        prevStage=	4;
                        stage=	3;
                    }
                    else if(holds[3] && args.isKeyUp(Keys.Escape) && args.isKeyUp(Buttons.B) && args.isKeyUp(MouseButtons.Right))
                        holds[3]=	false;
                }break;
            }
        }
Beispiel #6
0
 // Keys for whenever you want something to move rightwards
 public bool isKeysDown_moveRight(ref InputArgs args)
 {
     return (args.isKeyDown(Keys.D) || args.isKeyDown(Buttons.LeftThumbstickRight));
 }
Beispiel #7
0
 // Keys for whenever you are moving around the menu using the keyboard
 public bool isKeysDown_menuMovement(ref InputArgs args)
 {
     return (args.isKeyDown(Keys.Up) || args.isKeyDown(Keys.Down));
 }
Beispiel #8
0
 // Keys for whenever you are confirming something
 public bool isKeysDown_confirm(ref InputArgs args)
 {
     return (args.isKeyDown(Keys.Enter) || args.isKeyDown(Buttons.A) || args.isKeyDown(MouseButtons.Left));
 }
Beispiel #9
0
 // Adds a stat variance to the unit
 private void addStat(Control ctrl, InputArgs args)
 {
     if(args.isKeyDown(MouseButtons.Left))
     {
         switch(ctrl.tag)
         {
             case "hp":	unit.statVariance.hp++;	break;
             case "mana":	unit.statVariance.mana++;	break;
             case "atk":	unit.statVariance.atk++;	break;
             case "def":	unit.statVariance.def++;	break;
             case "mag":	unit.statVariance.mag++;	break;
             case "res":	unit.statVariance.res++;	break;
             case "spd":	unit.statVariance.spd++;	break;
         }
         unit.initStats();
         close();
     }
 }
Beispiel #10
0
        // Called when the keyboard has been pressed
        private void pressedNoFocus(Control ctrl, InputArgs args)
        {
            if(ctrl.isEnabled)
                return;
            if(!ctrl.bounds.Contains(args.mouse.Position))
                return;

            if(tick< 10)
            {
                tick++;
                return;
            }

            if(gstate.isKeysDown_menuMoveUp(ref args))
            {
                tick=	0;
                moveButtonUpwards(set.children.getIndexOf(ctrl));
            }

            if(gstate.isKeysDown_menuMoveDown(ref args))
            {
                tick=	0;
                moveButtonDownwards(set.children.getIndexOf(ctrl));
            }
        }
Beispiel #11
0
        // Called when the keyboard has been pressed
        private void pressed(Control ctrl, InputArgs args)
        {
            if(gstate.holds[4])
                return;

            if(tick< 10)
                return;

            if(gstate.isKeysDown_confirm(ref args))
            {
                tick=	0;
                game.gui.close("player_unit_menu");
                game.gui.close("skills_menu");
                gstate.playerUnitGui.isEnabled=	true;
                map.destroyPaths();
                map.showSkillRange(selUnit, ctrl.tag);
                gstate.selSkill=	ctrl.tag;
                gstate.stage=	3;
            }

            if(gstate.isKeysDown_menuMoveUp(ref args))
            {
                tick=	0;
                moveButtonUpwards(set.children.getIndexOf(ctrl));
            }

            if(gstate.isKeysDown_menuMoveDown(ref args))
            {
                tick=	0;
                moveButtonDownwards(set.children.getIndexOf(ctrl));
            }
        }
Beispiel #12
0
 // Called when the button has been clicked
 private void clicked(Control ctrl, InputArgs args)
 {
     if(args.isKeyDown(MouseButtons.Left))
     {
         game.gui.close("player_unit_menu");
         game.gui.close("skills_menu");
         gstate.playerUnitGui.isEnabled=	true;
         map.destroyPaths();
         map.showSkillRange(selUnit, ctrl.tag);
         gstate.selSkill=	ctrl.tag;
         gstate.stage=	3;
     }
 }
Beispiel #13
0
 // Opens up the ui the first time, sets the mouse there for easability
 public void openFirst(InputArgs args)
 {
     args.setMousePosition(game, new Point(228, 64));
     open();
 }
Beispiel #14
0
        // Called when the keyboard has been pressed
        private void pressed(Control ctrl, InputArgs args)
        {
            if(gstate.holds[4])
                return;

            if(gstate.isKeysDown_confirm(ref args))
                gstate.stopGui(ctrl.tag);

            if(tick< 10)
                return;

            // Up movement
            if(gstate.isKeysDown_menuMoveUp(ref args))
            {
                tick=	0;
                switch(ctrl.tag)
                {
                    case "enemy_stats":	skills.focus();	break;
                    case "enemy_exit":	stats.focus();	break;
                }
            }

            // Down movement
            if(gstate.isKeysDown_menuMoveDown(ref args))
            {
                tick=	0;
                switch(ctrl.tag)
                {
                    case "enemy_skills":	stats.focus();	break;
                    case "enemy_stats":	exit.focus();	break;
                }
            }
        }
Beispiel #15
0
 // Called when the state is handling the input
 public virtual void onHandleInput(InputArgs args)
 {
 }
Beispiel #16
0
 // Keys for whenever you are canceling something
 public bool isKeysDown_cancel(ref InputArgs args)
 {
     return (args.isKeyDown(Keys.Escape) || args.isKeyDown(Buttons.B) || args.isKeyDown(MouseButtons.Right));
 }
        // Called when the cancel button is pressed, or when escape / B has been pressed
        private void canceled(Control ctrl, InputArgs args)
        {
            if(gstate.holds[4])
                return;

            if(args.isKeyDown(Keys.Escape) || args.isKeyDown(Buttons.B))
            {
                game.gui.close("attack_decision");
                gstate.stage=	4;
                gstate.selSkill=	info.skillID;
                map.destroyPaths();
                map.showSkillRange(info.attackerID, info.skillID);
            }
            if(args.isKeyDown(MouseButtons.Left))
            {
                game.gui.close("attack_decision");
                gstate.stage=	3;
                gstate.selSkill=	info.skillID;
                map.destroyPaths();
                map.showSkillRange(info.attackerID, info.skillID);
            }
        }
Beispiel #18
0
 // Keys for whenever you are moving down the menu
 public bool isKeysDown_menuMoveDown(ref InputArgs args)
 {
     return (args.isKeyDown(Keys.Down) || args.isKeyDown(Buttons.DPadDown));
 }
        // Called when the commit button is pressed or when enter / A has been pressed
        private void commited(Control ctrl, InputArgs args)
        {
            if(gstate.holds[4] || gstate.stage== 6)
                return;

            if(args.isKeyDown(MouseButtons.Left) || args.isKeyDown(Keys.Enter) || args.isKeyDown(Buttons.A))
            {
                gstate.holds[4]=	true;
                game.gui.close("attack_decision");
                gstate.stage=	6;
                gstate.selSkill=	info.skillID;
                gstate.moveCameraTo(map.getUnitX(info.attackerID), map.getUnitY(info.attackerID));
                if(!info.isTrap)
                {
                    if(map.makeUnitAttack(info.attackerID, map.getUnitX(info.defenderID), map.getUnitY(info.defenderID), ref info))
                    {
                        map.destroyPaths();
                        // Animate attack!
                        // map.animateAttack(ref info);

                        // Still more options to go, reopen the unit's menu
                        if(gstate.unitLevelUpGui.isOpened)
                        {
                            gstate.unitLevelUpGui.open(ref map.teams.items[info.attackerID[0]].units.items[info.attackerID[1]]);
                        }
                        else if(!map.teams.items[info.attackerID[0]].units.items[info.attackerID[1]].isWalkingDone)
                        {
                            gstate.stage=	1;
                            map.endUnitAttacking(info.attackerID);
                            gstate.playerUnitGui.open();
                        }
                        else
                        {
                            game.gui.close("player_unit_menu");
                            gstate.stage=	0;
                            map.endUnitAttacking(info.attackerID);
                        }
                    }
                    if(gstate.unitLevelUpGui.isOpened)
                    {
                        gstate.unitLevelUpGui.open(ref map.teams.items[info.attackerID[0]].units.items[info.attackerID[1]]);
                    }
                }
                else
                {
                    map.setTrap(info.attackerID, map.getUnitX(info.attackerID), map.getUnitY(info.attackerID), info.trapRadius, info.trap);
                    // Animate trap!
                    // map.animateAttack(ref info);

                    // Still more options to go, reopen the unit's menu
                    if(gstate.unitLevelUpGui.isOpened)
                    {
                        gstate.unitLevelUpGui.open(ref map.teams.items[info.attackerID[0]].units.items[info.attackerID[1]]);
                    }
                    else if(!map.teams.items[info.attackerID[0]].units.items[info.attackerID[1]].isWalkingDone)
                    {
                        gstate.stage=	1;
                        map.endUnitAttacking(info.attackerID);
                        gstate.playerUnitGui.open();
                    }
                    else
                    {
                        game.gui.close("player_unit_menu");
                        gstate.stage=	0;
                        map.endUnitAttacking(info.attackerID);
                    }
                }
            }
        }
Beispiel #20
0
 // Keys for whenever you are moving up the menu
 public bool isKeysDown_menuMoveUp(ref InputArgs args)
 {
     return (args.isKeyDown(Keys.Up) || args.isKeyDown(Buttons.DPadUp));
 }
Beispiel #21
0
        // Called when the keyboard has been pressed
        private void pressed(Control ctrl, InputArgs args)
        {
            if(gstate.holds[4])
                return;

            if(gstate.isKeysDown_confirm(ref args))
                gstate.stopGui(ctrl.tag);

            if(tick< 10)
                return;

            // Up movement
            if(gstate.isKeysDown_menuMoveUp(ref args))
            {
                tick=	0;
                switch(ctrl.tag)
                {
                    case "player_skills":
                        if(move.isEnabled)
                            args.setMousePosition(game, new Point(move.bounds.X+move.bounds.Width/2, move.bounds.Y+move.bounds.Height/2));
                        break;
                    case "player_stats":
                        if(skills.isEnabled)
                            args.setMousePosition(game, new Point(skills.bounds.X+skills.bounds.Width/2, skills.bounds.Y+skills.bounds.Height/2));
                        else
                        {
                            if(move.isEnabled)
                                args.setMousePosition(game, new Point(move.bounds.X+move.bounds.Width/2, move.bounds.Y+move.bounds.Height/2));
                        }
                        break;
                    case "player_end":
                        args.setMousePosition(game, new Point(stats.bounds.X+stats.bounds.Width/2, stats.bounds.Y+stats.bounds.Height/2));
                        break;
                    case "player_exit":
                        if(end.isEnabled)
                            args.setMousePosition(game, new Point(end.bounds.X+end.bounds.Width/2, end.bounds.Y+end.bounds.Height/2));
                        else
                            args.setMousePosition(game, new Point(stats.bounds.X+stats.bounds.Width/2, stats.bounds.Y+stats.bounds.Height/2));
                        break;
                }
            }

            // Down movement
            if(gstate.isKeysDown_menuMoveDown(ref args))
            {
                tick=	0;
                switch(ctrl.tag)
                {
                    case "player_move":
                        if(skills.isEnabled)
                            args.setMousePosition(game, new Point(skills.bounds.X+skills.bounds.Width/2, skills.bounds.Y+skills.bounds.Height/2));
                        else
                            args.setMousePosition(game, new Point(stats.bounds.X+stats.bounds.Width/2, stats.bounds.Y+stats.bounds.Height/2));
                        break;
                    case "player_skills":
                        args.setMousePosition(game, new Point(stats.bounds.X+stats.bounds.Width/2, stats.bounds.Y+stats.bounds.Height/2));
                        break;
                    case "player_stats":
                        if(end.isEnabled)
                            args.setMousePosition(game, new Point(end.bounds.X+end.bounds.Width/2, end.bounds.Y+end.bounds.Height/2));
                        else
                            args.setMousePosition(game, new Point(exit.bounds.X+exit.bounds.Width/2, exit.bounds.Y+exit.bounds.Height/2));
                        break;
                    case "player_end":
                        args.setMousePosition(game, new Point(exit.bounds.X+exit.bounds.Width/2, exit.bounds.Y+exit.bounds.Height/2));
                        break;
                }
            }
        }
Beispiel #22
0
 // Keys for whenever you want something to move upwards
 public bool isKeysDown_moveUp(ref InputArgs args)
 {
     return (args.isKeyDown(Keys.W) || args.isKeyDown(Buttons.LeftThumbstickUp));
 }
Beispiel #23
0
        // Called when the player is trying to regain focus to te menu
        private void pressedNoFocus(Control ctrl, InputArgs args)
        {
            if(hasAnyFocus() || refd)
                return;

            if(gstate.isKeysDown_menuMoveUp(ref args) || gstate.isKeysDown_menuMoveDown(ref args))
            {
                if(move.isEnabled)
                    args.setMousePosition(game, new Point(move.bounds.X+move.bounds.Width/2, move.bounds.Y+move.bounds.Height/2));
                else if(skills.isEnabled)
                    args.setMousePosition(game, new Point(skills.bounds.X+skills.bounds.Width/2, skills.bounds.Y+skills.bounds.Height/2));
                else
                    args.setMousePosition(game, new Point(stats.bounds.X+stats.bounds.Width/2, stats.bounds.Y+stats.bounds.Height/2));
            }
        }
Beispiel #24
0
        // Does things with the tile
        public void interactWithTile(ref GridNode<Tile> node, ref InputArgs args)
        {
            if(holds[5])
            {
                holds[5]=	false;

                return;
            }
            switch(stage)
            {
                case 0:	{
                    if(node.item.unitID[0]== -1)
                        return;
                    stage=	1;
                    selUnit=	node.item.unitID;
                    if(node.item.unitID[0]!= playerTeamID)
                    {
                        isPlayer=	false;
                        enemyUnitGui.openFirst(args);

                        return;
                    }

                    isPlayer=	true;
                    playerUnitGui.open();
                };break;
                case 2:	{
                    if(node.path== -1)
                        return;
                    if(node.item.unitID!= selUnit && node.item.hasUnit)
                        return;

                    map.moveUnit(selUnit, camSel[0], camSel[1]);
                    map.destroyPaths();
                    if(!map.teams.items[selUnit[0]].units.items[selUnit[1]].isAttackingDone)
                    {
                        stage=	1;
                        map.endUnitWalking(selUnit);
                        playerUnitGui.open();
                    }
                    else
                    {
                        game.gui.close("player_unit_menu");
                        stage=	0;
                        map.endUnitWalking(selUnit);
                    }
                };break;
                case 3:	{
                    if(node.path== -1)
                        return;
                    if(!node.item.hasUnit)
                        return;

                    map.destroyPaths();
                    currAttackInfo=	map.showAttackDecision(selUnit, camSel[0], camSel[1], selSkill);
                    //moveCameraTo(camSel[0], camSel[1]-3);
                    openAttackDecisionGui();
                    stage= 1;
                };break;
            }
        }
Beispiel #25
0
 // Stop the gui
 private void stopGui(Control ctrl, InputArgs args)
 {
     if(args.isKeyDown(MouseButtons.Left))
         gstate.stopGui(ctrl.tag);
 }
Beispiel #26
0
        // --- Inherited Methods ---
        // Updates the game
        protected override void Update(GameTime time)
        {
            inputArgs=	getInputArgs();

            inputEvent(inputArgs);
            updateEvent(time);

            base.Update(time);
        }
Beispiel #27
0
 // Handles the game's input
 public override void onHandleInput(InputArgs args)
 {
     game.gui.handleInput(args);
 }