//---------------------------------------------------------------------------------------------------------------------------------------------------
//
// Copyright (C)2007 DarkWynter Studios. All rights reserved.
//
//---------------------------------------------------------------------------------------------------------------------------------------------------
// {Contact : darkwynter.com for licensing information
//---------------------------------------------------------------------------------------------------------------------------------------------------
///
/// Controller code for the game, includes GameController and MenuController
///
namespace DWControllerDemo
{
#region Using Statements
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using DarkWynter.Engine.Controllers;
using DW.Globals;
#endregion
///
/// Game Controller for getting player inputs in-game
///
public class GameController : Controller
{
#region CTORs
///
/// Constructor for PC and mouse controls
///
/// Player index for this controller
public GameController(int playerNumber): base(playerNumber)
{
Init();
}
///
/// Constructor for Xbox only controls
///
public GameController(PlayerIndex playerIndex)
: base(playerIndex)
{
Init();
}
///
/// Constructor for Xbox and keyboard controls
///
/// Player index in ObjectLibrary
/// Player index for this controller
public GameController(int player, PlayerIndex playerIndex)
: base(player, playerIndex)
{
Init();
}
#endregion
// NOTES:
// We need different controller constructors for differentiating xbox vs. pc vs. xboxpc controller types
// We only want two key setups most of the time tho, so we defer to Init which switches pc and xbox configs concisely based on type.
private void Init()
{
if (playerControllerType == ControllerType.PC_ONLY || playerControllerType == ControllerType.PC_AND_XBOX)
{
Add(new KeyboardControl(Keys.Back, SwitchGameMode, 200));
Add(new KeyboardControl(Keys.Escape, Escape, 0));
Add(new KeyboardControl(Keys.M, SwitchGameMode, 100));
Add(new KeyboardControl(Keys.W, MoveForward, 10));
Add(new KeyboardControl(Keys.A, MoveLeft, 10));
Add(new KeyboardControl(Keys.D, ChangeColorNeg, 10));
Add(new KeyboardControl(Keys.S, MoveBackward, 10));
Add(new KeyboardControl(Keys.Down, ChangeColorNeg, 100));
Add(new KeyboardControl(Keys.Up, ChangeColorPos, 100));
Add(new MouseControl(ControlType.LeftButton, ChangeColorPos, 100));
Add(new MouseControl(ControlType.LeftButton, ChangeColorNeg, 100, 0));
Add(new MouseControl(ControlType.Motion, Motion, 0));
}
if (playerControllerType == ControllerType.XBOX_ONLY || playerControllerType == ControllerType.PC_AND_XBOX)
{
// Add xbox control bindings here !!!
Add(new XboxDigitalControl(Buttons.Back, Escape, 100));
}
}
// NOTES:
// the args list coming into each Input Delegate contain a "value" and a List