//---------------------------------------------------------------------------------------------------------------------------------------------------
//
// Copyright (C)2007 DarkWynter Studios. All rights reserved.
//
//---------------------------------------------------------------------------------------------------------------------------------------------------
// {Contact : darkwynter.com for licensing information
//---------------------------------------------------------------------------------------------------------------------------------------------------
namespace DWControllerDemo
{
#region Using Statements
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using DarkWynter.Engine.Controllers;
using DWGame.Globals;
using DWGame.Player;
#endregion
///
/// Game Controller for getting player inputs in-game
///
public class GameController : Controller
{
///
/// Constructor for PC and mouse controls
///
/// Player index for this controller
public GameController(int playerNumber)
: base(playerNumber)
{
Add(new KeyboardControl(Keys.Escape, Escape, 0));
Add(new MouseControl(ControlType.LeftButton, PickUpItem, 250));
Add(new MouseControl(ControlType.LeftButton, DropItem, 250, 0));
Add(new MouseControl(ControlType.Motion, Motion, 0));
//Add(new KeyboardControl(Keys.M, SwitchGameMode, 100));
Add(new KeyboardControl(Keys.Up, MoveForward, 10));
Add(new KeyboardControl(Keys.Left, MoveLeft, 10));
Add(new KeyboardControl(Keys.Right, MoveRight, 10));
Add(new KeyboardControl(Keys.Down, MoveBackward, 10));
Add(new KeyboardControl(Keys.LeftShift, PickUpItem, 10));
//Add(new KeyboardControl(Keys.Up, ChangeColorPos, 100));
//Add(new KeyboardControl(Keys.Down, ChangeColorNeg, 100));
}
///
/// Constructor for Xbox only controls
///
///
public GameController(PlayerIndex playerIndex)
: base(playerIndex)
{
// Add xbox controls
}
///
/// Constructor for Xbox and keyboard controls
///
/// Player index in ObjectLibrary
/// Player index for this controller
public GameController(int player, PlayerIndex playerIndex)
: base(player, playerIndex)
{
Add(new KeyboardControl(Keys.Escape, Escape, 0));
//Add(new KeyboardControl(Keys.M, SwitchGameMode, 100));
Add(new KeyboardControl(Keys.Up, MoveForward, 0));
Add(new KeyboardControl(Keys.Left, MoveLeft, 0));
Add(new KeyboardControl(Keys.Right, MoveRight, 0));
Add(new KeyboardControl(Keys.Down, MoveBackward, 0));
//Add(new KeyboardControl(Keys.Up, ChangeColorPos, 100));
//Add(new KeyboardControl(Keys.Down, ChangeColorNeg, 100));
}
private void Escape(ControllerBoolEventArgs args)
{
Statics._self.Exit();
}
private void PickUpItem(ControllerBoolEventArgs args)
{
Human.fire();
}
private void DropItem(ControllerBoolEventArgs args)
{
}
private void Motion(ControllerVec2EventArgs args)
{
}
private void MoveForward(ControllerBoolEventArgs arg)
{
if (Statics.playerState == Enums_Engine.PlayerState.ALIVE)
Human.moveUp();
}
private void MoveBackward(ControllerBoolEventArgs arg)
{
if (Statics.playerState == Enums_Engine.PlayerState.ALIVE)
Human.moveDown();
}
private void MoveLeft(ControllerBoolEventArgs arg)
{
if (Statics.playerState == Enums_Engine.PlayerState.ALIVE)
Human.moveLeft();
}
private void MoveRight(ControllerBoolEventArgs arg)
{
if (Statics.playerState == Enums_Engine.PlayerState.ALIVE)
Human.moveRight();
}
}
}