Beispiel #1
0
        public InputContext(IDataReader state, IInputManager inputManager, Core core)
            : base(state)
        {
            m_lastKeybaord = state.ReadBoolean();
            m_lastMouse = state.ReadBoolean();
            m_lastTouch = state.ReadBoolean();
            m_lastGamepad = state.ReadBoolean();

            Enum.TryParse(state.ReadString(), out m_playerIndex);
            // keyboard
            int numInputMappings = state.ReadInt32();
            for (int i = 0; i < numInputMappings; ++i)
            {
                String key = state.ReadString();
                Keys k;
                if (Enum.TryParse(key, true, out k))
                {
                    m_keyMappings.Add(k, new InputMapping(state, core));
                }
                else
                {
                    new InputMapping(state,core);
                }
            }

            //gamepad
            int numGamepadBindings = state.ReadInt32();
            for (int i = 0; i < numGamepadBindings; ++i)
            {
                String button = state.ReadString();
                Buttons b;
                if (Enum.TryParse(button,true,out b))
                {
                    m_gamepadMappings.Add(b, new InputMapping(state, core));
                }
                else
                {
                    new InputMapping(state, core);
                }
            }

            m_inputManager = inputManager;
        }
Beispiel #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="objectBuilder"></param>
        public static void registerElement(IObjectBuilder objectBuilder, IInputManager inputManager, Core core)
        {
            ParameterSequenceBuilder sequenceBuilder = new ParameterSequenceBuilder();
            sequenceBuilder.createSequence();

            sequenceBuilder.addParameter(new BoolParameter("lastKey","false"));
            sequenceBuilder.addParameter(new BoolParameter("lastMouse", "false"));
            sequenceBuilder.addParameter(new BoolParameter("lastTouch", "false"));
            sequenceBuilder.addParameter(new BoolParameter("lastGamepad", "false"));
            sequenceBuilder.addParameter(new StringParameter("playerIndex","One"));

            CompoundParameter keymapping = new CompoundParameter("keymapping");
            keymapping.addParameter(new StringParameter("key",""));
            keymapping.addParameter(new BoolParameter("pressed", "false"));
            keymapping.addParameter(new IdParameter("downMsgId", ""));
            keymapping.addParameter(new IdParameter("upMsgId", ""));
            keymapping.addParameter(new IdParameter("target",""));
            keymapping.addParameter(new StringParameter("message", ""));
            SequenceParameter keymappings = new SequenceParameter("keymappings", keymapping);

            CompoundParameter keyboardMappings = new CompoundParameter("keyboard");
            keyboardMappings.addParameter(keymappings);
            sequenceBuilder.addParameter(keyboardMappings);

            CompoundParameter gamepadmapping = new CompoundParameter("gamepadmapping");
            gamepadmapping.addParameter(new StringParameter("key", "Start"));
            gamepadmapping.addParameter(new BoolParameter("pressed", "false"));
            gamepadmapping.addParameter(new IdParameter("downMsgId", ""));
            gamepadmapping.addParameter(new IdParameter("upMsgId", ""));
            gamepadmapping.addParameter(new IdParameter("target", ""));
            gamepadmapping.addParameter(new StringParameter("message", ""));
            SequenceParameter gamepadmappings = new SequenceParameter("gamepadmappings", gamepadmapping);

            //CompoundParameter gamepadLeftStickMapping = new CompoundParameter("leftStickMapping");
            //gamepadLeftStickMapping.addParameter(new IdParameter("movedMsgId",""));
            //gamepadLeftStickMapping.addParameter(new IdParameter("target", ""));

            //CompoundParameter gamepadRightStickMapping = new CompoundParameter("rightStickMapping");
            //gamepadRightStickMapping.addParameter(new IdParameter("movedMsgId", ""));
            //gamepadRightStickMapping.addParameter(new IdParameter("target", ""));

            CompoundParameter gamepadMappings = new CompoundParameter("gamepad");
            gamepadMappings.addParameter(gamepadmappings);
            //gamepadMappings.addParameter(gamepadLeftStickMapping);
            //gamepadMappings.addParameter(gamepadRightStickMapping);
            sequenceBuilder.addParameter(gamepadMappings);

            objectBuilder.registerElement(new Constructor(inputManager, core), sequenceBuilder.CurrentSequence, typeof(InputContext), "InputContext", null);
        }
Beispiel #3
0
 public Constructor(IInputManager inputManager, Core core)
 {
     m_inputManager = inputManager;
     m_core = core;
 }
Beispiel #4
0
 public InputMapping(IDataReader state, Core core)
 {
     m_core = core;
     m_bIsPressed = state.ReadBoolean();
     m_downMsg = new XnaScrapId(state);
     m_upMsg = new XnaScrapId(state);
     m_targetId = new XnaScrapId(state);
     m_message = state.ReadString();
 }
Beispiel #5
0
        public TestGame(int processId = 0, string window = "")
        {
            //graphics = new GraphicsDeviceManager(this);
            //graphics.PreferredDepthStencilFormat = DepthFormat.Depth24;
            //graphics.ApplyChanges();
            Content.RootDirectory = "Content";

            // Frame rate is 30 fps by default for Windows Phone.
            TargetElapsedTime = TimeSpan.FromTicks(333333);

            m_core = new Core(this);
            m_scriptExecutor = XmlScriptExecutor.GetInstance(this);
            m_scriptCompiler = new XmlScriptCompilerService(this);
            m_collisionManager = new CollisionManager(this);
            m_sceneManager = new SceneManager(this);
            m_inputManager = new InputManager(this);
            m_animationService = new AnimationService(this);
            // graphics should be inserted last, as they should be updated at the end of a frame
            //RenderManager.TargetWindow target = new RenderManager.TargetWindow();
            //target.ProcessId = processId;
            //target.ChildWndCaption = window;
            //m_renderManager = new RenderManager(this, graphics, target);
            m_renderManager = new RenderManager(this, graphics);
            #if WINDOWS
            m_netCtrl = new NetCtrlService(this);
            #endif
        }