Exemplo n.º 1
0
        //LoadXboxPlayerInputs()
        #if XBOX
        private IPlayerInput[] LoadXboxPlayerInputs()
        {
            IPlayerInput[] playerInputs   = new IPlayerInput[4];
            XmlDocument    configDocument = new XmlDocument();

            configDocument.Load(".//Config//XBOXconfig.xml");
            XmlNodeList inputNodes = configDocument.SelectNodes("/config/input");

            try
            {
                for (int i = 0; i < playerInputs.Length; i++)
                {
                    XmlNode inputNode   = inputNodes[i];
                    float   scrollSpeed = float.Parse(inputNode.Attributes["scrollSpeed"].Value);
                    playerInputs[i] = new GamepadInput(UtilityMethods.NumToEnum <PlayerIndex>(i), scrollSpeed);
                }
                return(playerInputs);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemplo n.º 2
0
        private IPlayerInput[] LoadPCPlayerInputs()
        {
            IPlayerInput[] playerInputs   = new IPlayerInput[4];
            XmlDocument    configDocument = new XmlDocument();

            configDocument.Load(".//Config//PCconfig.xml");
            XmlNodeList inputNodes = configDocument.SelectNodes("/config/input");

            try
            {
                for (int i = 0; i < playerInputs.Length; i++)
                {
                    XmlNode inputNode            = inputNodes[i];
                    string  activeInputAttribute = inputNode.Attributes["activeInput"].Value;
                    float   scrollSpeed;

                    if (String.Compare(activeInputAttribute, "Keyboard", true) == 0)
                    {
                        scrollSpeed     = float.Parse(inputNode.Attributes["scrollSpeed"].Value);
                        playerInputs[i] = new KeyboardInput(scrollSpeed);
                    }
                    else if (String.Compare(activeInputAttribute, "Wiimote", true) == 0)
                    {
                        //if we have Wiimote, Mouse, Wiimote,
                        //the last Wiimote is player 3 but Wiimote index 1.
                        int numWiimotePlayers = 0;
                        foreach (IPlayerInput input in playerInputs)
                        {
                            if (input is WiiInput)
                            {
                                numWiimotePlayers += 1;
                            }
                        }
                        playerInputs[i] = new WiiInput(numWiimotePlayers);
                    }
                    else if (String.Compare(activeInputAttribute, "Mouse", true) == 0)
                    {
                        playerInputs[i] = new MouseInput();
                    }
                    else
                    {
                        //if we have Gamepad, Mouse, Gamepad
                        //the last Gamepad is player 3 but Gamepad PlayerIndex.Two.
                        int numGamepadPlayers = 0;
                        foreach (IPlayerInput input in playerInputs)
                        {
                            if (input is GamepadInput)
                            {
                                numGamepadPlayers += 1;
                            }
                        }
                        scrollSpeed     = float.Parse(inputNode.Attributes["scrollSpeed"].Value);
                        playerInputs[i] = new GamepadInput(UtilityMethods.NumToEnum <PlayerIndex>(numGamepadPlayers), scrollSpeed);
                    }
                }
                return(playerInputs);
            }
            catch (Exception ex)
            {
                throw;
            }
        }