#region File Description
//-----------------------------------------------------------------------------
// InputComponentManager.cs
//
// Microsoft XNA Community Game Platform
// Copyright (C) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#endregion
#region Using Statements
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
#endregion
namespace RobotGameData.Input
{
///
/// It allows the creation of InputComponent up to 4, which is the maximum
/// allowed number, and waits for the user’s inputs.
///
public class InputComponentManager
{
#region Fields
protected InputComponent[] inputComponents;
#endregion
///
/// Constructor.
///
public InputComponentManager()
{
// create four input components
inputComponents = new InputComponent[]
{
new InputComponent( PlayerIndex.One),
new InputComponent( PlayerIndex.Two),
new InputComponent( PlayerIndex.Three),
new InputComponent( PlayerIndex.Four),
};
}
///
/// Initialize all input components
///
public void Initialize()
{
for( int i = 0; i < inputComponents.Length; i++)
inputComponents[i].Initialize();
}
///
/// Reset all input components
///
public void Reset()
{
for (int i = 0; i < inputComponents.Length; i++)
inputComponents[i].Reset();
}
///
/// Update all input components
///
public void Update(GameTime gameTime)
{
for (int i = 0; i < inputComponents.Length; i++)
inputComponents[i].Update(gameTime);
}
public InputComponent GetInputComponent(PlayerIndex idx)
{
return inputComponents[(Int32)idx];
}
///
/// This is the function which does the input process before updating.
///
public void PreUpdate()
{
for (int i = 0; i < inputComponents.Length; i++)
inputComponents[i].PreUpdate();
}
///
/// This is the function which does the input process after updating.
///
public void PostUpdate()
{
for (int i = 0; i < inputComponents.Length; i++)
inputComponents[i].PostUpdate();
}
}
}