//---------------------------------------------------------------------------------------------------------------------------------------------------
//
// Copyright (C)2007 DarkWynter Studios. All rights reserved.
//
//---------------------------------------------------------------------------------------------------------------------------------------------------
// {Contact : darkwynter.com for licensing information
//---------------------------------------------------------------------------------------------------------------------------------------------------
namespace DWControllerDemo
{
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using DarkWynter.Engine;
using DarkWynter.Engine.Controllers;
using DWControllerDemo;
///
/// Menu Controller for getting player inputs for the menu system
///
public class MenuController : Controller
{
///
/// Constructor
///
/// Player index for this controller
public MenuController(int playerNumber)
: base(playerNumber)
{
Add(new KeyboardControl(Keys.Escape, Escape, 100));
Add(new KeyboardControl(Keys.G, SwitchGameMode, 100));
Add(new KeyboardControl(Keys.Up, MenuUp, 200));
Add(new KeyboardControl(Keys.Down, MenuDown, 200));
Add(new KeyboardControl(Keys.Left, MenuLeft, 200));
Add(new KeyboardControl(Keys.Right, MenuRight, 200));
}
///
/// Constructor for Xbox only controls
///
/// Controller index
public MenuController(PlayerIndex playerIndex)
: base(playerIndex)
{
// Add Xbox controls
}
///
/// Constructor for Xbox and keyboard controls
///
/// Player index in ObjectLibrary
/// Player index for this controller
public MenuController(int player, PlayerIndex playerIndex)
: base(player, playerIndex)
{
Add(new KeyboardControl(Keys.Escape, Escape, 100));
Add(new KeyboardControl(Keys.M, SwitchGameMode, 100));
Add(new KeyboardControl(Keys.Up, MenuUp, 200));
Add(new KeyboardControl(Keys.Down, MenuDown, 200));
Add(new KeyboardControl(Keys.Left, MenuLeft, 200));
Add(new KeyboardControl(Keys.Right, MenuRight, 200));
// Add xbox controls
}
private void Escape(ControllerBoolEventArgs args)
{
ControllerDemo._self.Exit();
}
private void SwitchGameMode(ControllerBoolEventArgs args)
{
ControllerDemo._self.gameMode = ControllerDemo.GameMode.Game;
}
private void MenuUp(ControllerBoolEventArgs args)
{
Vector4 color = ControllerDemo._self.backColor.ToVector4();
color.X = 1.0f; // R
color.Y = 1.0f; // G
color.Z = 1.0f; // B
ControllerDemo._self.backColor = new Microsoft.Xna.Framework.Graphics.Color(color);
}
private void MenuDown(ControllerBoolEventArgs args)
{
Vector4 color = ControllerDemo._self.backColor.ToVector4();
color.X = 0.0f; // R
color.Y = 0.0f; // G
color.Z = 0.0f; // B
ControllerDemo._self.backColor = new Microsoft.Xna.Framework.Graphics.Color(color);
}
private void MenuLeft(ControllerBoolEventArgs args)
{
}
private void MenuRight(ControllerBoolEventArgs args)
{
}
}
}