Inheritance: MonoBehaviour
 public void StartGame()
 {
     //this.simpleSound.Stop();
     KeyboardController keyboardController = new KeyboardController();
     GameEngine game = new GameEngine(keyboardController);
     game.Run();
 }
	// Use this for initialization
	void Start () {

        // todo - move controller creation to a controller factory?
        // initialize controller
        keyboardController = new KeyboardController(playerGO);

    }
        protected override void OnStart()
        {
			var scene = new ReactiveScene();
			var layer = new ReactiveLayer2D();

            var controller = new KeyboardController<int>();
            controller.BindKey(Keys.Down, 0);
            controller.BindKey(Keys.Up, 1);
            controller.BindKey(Keys.Z, 2);
            controller.BindKey(Keys.X, 3);

            var layout = new LinearPanel()
            {
                ItemSpan = new Vector2DF(0, 36),
                Position = new Vector2DF(20, 20),
            };
            layout.SetEasingBehaviorUp(EasingStart.StartRapidly2, EasingEnd.EndSlowly3, 10);
            selector = new Selector<int, int>(controller, layout)
            {
                Loop = true,
                CursorOffset = new Vector2DF(-5, -3),
            };
			selector.Cursor.Texture = Engine.Graphics.CreateTexture2D("ListCursor.png");
			selector.BindKey(0, 1, 2, 3);
            selector.SetEasingBehaviorUp(EasingStart.StartRapidly2, EasingEnd.EndSlowly3, 10);

            font = Engine.Graphics.CreateDynamicFont("", 20, new Color(255, 255, 255, 255), 0, new Color(0, 0, 0, 255));
            for(int i = 0; i < 8; i++)
            {
                var obj = new ListItem()
                {
                    Text = $"選択肢{i}",
                    Font = font,
                };
                Engine.AddObject2D(obj);
                selector.AddChoice(i, obj);
            }

            var moveSound = Engine.Sound.CreateSoundSource("kachi38.wav", true);
            var decideSound = Engine.Sound.CreateSoundSource("pi78.wav", true);
            var cancelSound = Engine.Sound.CreateSoundSource("pi11.wav", true);

            selector.OnSelectionChanged.Subscribe(i => Engine.Sound.Play(moveSound));
            selector.OnDecide.Subscribe(i =>
            {
                Engine.Sound.Play(decideSound);
            });
            selector.OnCancel.Subscribe(i =>
            {
                Engine.Sound.Play(cancelSound);
            });

			Engine.ChangeScene(scene);
			scene.AddLayer(layer);
			layer.AddObject(selector);
		}
Beispiel #4
0
        public State DuringState(DaleStateHandler daleStateHandler)
        {
            KeyboardController keyboardController = daleStateHandler.keyboardController;

            if (keyboardController.isJumpKeyPressed)
            {
                return(daleStateHandler.jumpingState);
            }
            return(this);
        }
 public void Keyman7_DeActivateKeyboard_RevertsToDefault()
 {
     RequiresKeyman7();
     KeyboardController.KeyboardDescriptor d = KeyboardController.GetAvailableKeyboards(KeyboardController.Engines.Keyman7)[0];
     Keyboard.Controller.SetKeyboard(d.ShortName);
     Application.DoEvents();            //required
     KeyboardController.DeactivateKeyboard();
     Application.DoEvents();            //required
     Assert.AreNotEqual(d.ShortName, KeyboardController.GetActiveKeyboard());
 }
Beispiel #6
0
        public override void BeforeTest(TestDetails testDetails)
        {
            if (Keyboard.Controller != null)
            {
                Keyboard.Controller.Dispose();
            }

            KeyboardController.Initialize();
            base.BeforeTest(testDetails);
        }
    public bool GetButton(KeyboardController.eSimulatedAxis simulatedAxisId)
    {
        string keyCode = GetKeyCode(simulatedAxisId);
        if (!string.IsNullOrEmpty(keyCode))
        {
            return Input.GetKey(keyCode);
        }

        return false;
    }
        public void WhenReceiveCommandOnKeyPressedPressed_CallToGuessLetter()
        {
            var keyboardViewModel  = new InGameViewModel();
            var guessLetter        = Substitute.For <IGuessLetter>();
            var keyboardController = new KeyboardController(keyboardViewModel, guessLetter);

            keyboardViewModel.OnKeyPressedPressed.Execute("A");

            guessLetter.Received().Guess('A');
        }
        public void SetUp()
        {
            textBoxForm = new TextBoxTestForm();
            textBoxForm.Show();

            textBoxTester = new ControlTester("myTextBox");
            Assert.AreEqual("default", textBoxTester.Text);

            keyboardController = new KeyboardController(textBoxTester);
        }
Beispiel #10
0
    public KeyboardController()
    {
        Instance             = this;
        keySequenceDetectors = new List <KeySequenceDetector>();

        directionKeys[Direction.Up]    = new[] { KeyCode.W, KeyCode.UpArrow };
        directionKeys[Direction.Down]  = new[] { KeyCode.S, KeyCode.DownArrow };
        directionKeys[Direction.Left]  = new[] { KeyCode.A, KeyCode.LeftArrow };
        directionKeys[Direction.Right] = new[] { KeyCode.D, KeyCode.RightArrow };
    }
Beispiel #11
0
 void Start()
 {
     audioSource = gameObject.GetComponent <AudioSource>();
     // noteActivate = GameObject.FindGameObjectWithTag("Finish").GetComponent<NoteActivated>();
     keyboard = GameObject.FindGameObjectWithTag("Player").GetComponent <KeyboardController>();
     if (audioSource == null)
     {
         GetComponent <AudioSource>();
     }
 }
 public void Keyman6_ActivateKeyboard_ReportsItWasActivated()
 {
     RequiresKeyman6();
     RequiresWindow();
     KeyboardController.KeyboardDescriptor d = KeyboardController.GetAvailableKeyboards(KeyboardController.Engines.Keyman6)[0];
     Application.DoEvents();             //required
     Keyboard.Controller.SetKeyboard(d.ShortName);
     Application.DoEvents();             //required
     Assert.AreEqual(d.ShortName, KeyboardController.GetActiveKeyboard());
 }
        public void ActivateKeyboard_FirstTime_NotCrash()
        {
            XklEngineResponder.SetGroupNames = new[] { KeyboardUSA };

            var adaptor = new XkbKeyboardRetrievingAdaptor(new XklEngineResponder());

            KeyboardController.Initialize(adaptor);
            Assert.That(() => adaptor.SwitchingAdaptor.ActivateKeyboard(
                            KeyboardController.Instance.Keyboards.First()), Throws.Nothing);
        }
        public void InstalledKeyboards_GB()
        {
            XklEngineResponder.SetGroupNames = new[] { KeyboardUK };

            KeyboardController.Initialize(new XkbKeyboardRetrievingAdaptor(new XklEngineResponder()));
            IKeyboardDefinition[] keyboards = Keyboard.Controller.AvailableKeyboards.ToArray();
            Assert.AreEqual(1, keyboards.Length);
            Assert.AreEqual("en-GB_gb", keyboards[0].Id);
            Assert.AreEqual(ExpectedKeyboardUK, keyboards[0].Name);
        }
        public void InstalledKeyboards_FrenchWithVariant()
        {
            XklEngineResponder.SetGroupNames = new[] { KeyboardFranceEliminateDeadKeys };

            KeyboardController.Initialize(new XkbKeyboardRetrievingAdaptor(new XklEngineResponder()));
            var keyboards = Keyboard.Controller.AvailableKeyboards;

            Assert.AreEqual(1, keyboards.Count());
            Assert.AreEqual(ExpectedKeyboardFranceEliminateDeadKeys, keyboards.First().Name);
        }
        public KeyboardControllerTest()
        {
            textBoxForm = new TextBoxTestForm();
            textBoxForm.Show();

            textBoxTester = new ControlTester("myTextBox");
            Assert.Equal("default", textBoxTester.Text);

            keyboardController = new KeyboardController(textBoxTester);
        }
        public void InvokeState()
        {
            var playView = new ConsolePlayView();

            var level = client.Login(login, sessionId);

            if (level == null)
            {
                throw new ArgumentException("Login already exists.");
            }

            var inputLoop = new InputLoop();

            var playerMoveInteractor  = new NetworkPlayerMoveInteractor(level, playView);
            var mobMoveInteractor     = new NetworkMobMoveInteractor(level, playView);
            var exitGameInteractor    = new ExitGameInteractor(level);
            var inventoryInteractor   = new InventoryInteractor(level, playView);
            var spawnPlayerInteractor = new SpawnPlayerInteractor(level, playView);

            var moveProcessor      = new MoveProcessor(playerMoveInteractor);
            var exitGameProcessor  = new ExitGameProcessor(exitGameInteractor);
            var inventoryProcessor = new InventoryProcessor(inventoryInteractor);

            var keyboardController = new KeyboardController(level, login);

            keyboardController.AddInputProcessor(client);

            keyboardController.AddInputProcessor(exitGameProcessor);

            client.AddInputProcessor(moveProcessor);
            client.AddInputProcessor(exitGameProcessor);
            client.AddInputProcessor(inventoryProcessor);

            client.SetMobInteractor(mobMoveInteractor);
            client.SetPlayerMoveInteractor(playerMoveInteractor);
            client.SetSpawnPlayerInteractor(spawnPlayerInteractor);

            inputLoop.AddUpdatable(keyboardController);
            inputLoop.AddUpdatable(client);

            level.CurrentPlayer = level.GetPlayer(login);

            level.CurrentPlayer.OnDie += (sender, args) =>
            {
                inputLoop.Stop();
            };

            exitGameInteractor.OnExit += (sender, player) =>
            {
                inputLoop.Stop();
            };

            playView.Draw(level);
            inputLoop.Start();
        }
Beispiel #18
0
        protected override void UpdateElement(GameTime gameTime)
        {
            if (this.IsEnabled)
            {
                var mouseState = MouseController.GetState();
                var mousePoint = new Point(mouseState.X, mouseState.Y);

                if (gameTime != null)
                {
                    this.elapsedTime += gameTime.ElapsedGameTime.Milliseconds / 1000f;

                    if (this.elapsedTime > this.blinkRate)
                    {
                        this.elapsedTime = 0;
                        this.ShowCursor  = !this.ShowCursor;
                    }
                }

                if (mouseState.LeftButtonDebounce == MonoButtonState.Pressed)
                {
                    if (this.Bounds.Contains(mousePoint))
                    {
                        this.IsActive  = true;
                        this.cursorPos = Math.Min(this.Text.Length == 0 ? 0 : (int)Math.Floor((mousePoint.X - this.Bounds.Left) / (this.TextWidth / this.Text.Length)), this.Text.Length);
                    }
                    else
                    {
                        this.IsActive = false;
                    }
                }

                if (this.IsActive && this.CanEdit)
                {
                    var ks   = KeyboardController.GetState();
                    var keys = ks.GetPressedKeys(true);
                    if (keys.Length > 0)
                    {
                        if (keys[0].IsAlpha() && this.cursorPos < (int)(this.Bounds.X / this.MaxCharWidth))
                        {
                            this.Text += ks.IsKeyDown(Keys.LeftShift) || ks.IsKeyDown(Keys.RightShift) ? keys[0].ToString() : keys[0].ToString().ToLower(CultureInfo.CurrentCulture);
                            this.cursorPos++;
                        }
                        else if (keys[0] == Keys.Back && this.cursorPos > 0)
                        {
                            this.Text      = this.Text.Remove(this.cursorPos - 1, 1);
                            this.cursorPos = Math.Max(this.cursorPos - 1, 0);
                        }
                        else if (keys[0] == Keys.Delete && this.cursorPos < this.Text.Length)
                        {
                            this.Text = this.Text.Remove(this.cursorPos, 1);
                        }
                    }
                }
            }
        }
Beispiel #19
0
        protected override void Initialize()
        {
            keyboardController = new KeyboardController();
            gamepadController  = new GamepadController();
            level     = new Level(this);
            lifeText  = new LifeText(this);
            resetTime = false;
            InitializeCommands();

            base.Initialize();
        }
Beispiel #20
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            AnimatedSpriteFactory.Instance.content = Content;

            keyboardController = new KeyboardController();
            mouseController    = new MouseController();

            this.IsMouseVisible = true;

            base.Initialize();
        }
    //TODO: Better Controller-Platform detection. Support for Xbox360Pad on Linux (it could already work, if not just add the appropriate name in UseOnPlatform)
    public static void RegisterControllers()
    {
        controllers = new List <ActionController> ();
        //initialize correct controller

        var os = SystemInfo.operatingSystem;

        Debug.Log(os);

        //If a keyboard is avaliable (aka : we are on PC) add it
        var keyboard = new KeyboardController();

        if (keyboard.useOnPlatform("keyboard"))
        {
            controllers.Add(keyboard);
            isOnPC = true;
        }

        //GetJoystickNames is not exported in WP8 builds because unity is dumb (it should just return 0 instead of #if)

#if !UNITY_WP8 || (UNITY_WP8 && UNITY_EDITOR)
        //Go trough every joystick and instantiate the correct controller (if it exist)
        var joysticks = Input.GetJoystickNames();
        Debug.Log("Found " + joysticks.Length + " joysticks");

        //instantiate valid controller for every platfom
        foreach (var joystick in joysticks)
        {
            var Xbox360Pad = new Xbox360Controller();

            if (Xbox360Pad.useOnPlatform(joystick))
            {
                Xbox360Pad.Start();
                controllers.Add(Xbox360Pad);
            }
        }
#endif

        //If we are on a touch enabled platform instantiate a touch controller
        var touchSensor = new TouchController();
        if (touchSensor.useOnPlatform("touch"))
        {
            controllers.Add(touchSensor);
        }

        if (controllers.Count == 1 && isOnPC)
        {
            currentController = 0; //Use keyboard if no controller and on PC
        }
        else if (isOnPC)
        {
            currentController = 1;
        }
    }
Beispiel #22
0
        /// <summary>
        /// Create a dummy keyboard controller
        /// </summary>
        public override void BeforeTest(TestDetails testDetails)
        {
            base.BeforeTest(testDetails);
            // If we already have a keyboard controller we'd better dispose it or we'll end up with missing dispose calls.
            if (Keyboard.Controller != null)
            {
                Keyboard.Controller.Dispose();
            }

            KeyboardController.Initialize(new DummyKeyboardAdaptor());
        }
Beispiel #23
0
        private void _keyman6TestBox_Enter(object sender, EventArgs e)
        {
#if WANT_PORT
            if (KeyboardController.EngineAvailable(KeyboardController.Engines.Keyman6))
            {
                string name = KeyboardController.GetAvailableKeyboards(KeyboardController.Engines.Keyman6)[0].ShortName;
                KeyboardController.ActivateKeyboard(name);
            }
            MessageBox.Show("keyman 6 not available");
#endif
        }
Beispiel #24
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="parent"></param>
        public KeyBindingsScreen(GameScreen parent, KeyboardController controller)
            : base()
        {
            _parent          = parent;
            _parent.Exiting += new EventHandler(_parent_Exiting);

            _controller = controller;

            _bindKeyTaskCancel = new CancellationTokenSource();
            _bindKeyTask       = Task <Keys> .Factory.StartNew(() => { return(Keys.None); }, _bindKeyTaskCancel.Token);
        }
Beispiel #25
0
        public void InstalledKeyboards_Germany_GermanCulture()
        {
            XklEngineResponder.SetGroupNames = new[] { KeyboardGermany };

            KeyboardController.Initialize(new XkbKeyboardRetrievingAdaptor(new XklEngineResponder()));
            var keyboards = Keyboard.Controller.AvailableKeyboards;

            Assert.AreEqual(1, keyboards.Count());
            Assert.AreEqual("de-DE_de", keyboards.First().Id);
            Assert.AreEqual("German - Deutsch (Deutschland)", keyboards.First().Name);
        }
        /// <summary>
        /// Creates and returns a keyboard definition object based on the ID.
        /// Note that this method is used when we do NOT have a matching available keyboard.
        /// Therefore we can presume that the created one is NOT available.
        /// </summary>
        public KeyboardDescription CreateKeyboardDefinition(string id)
        {
            string layout, locale;

            KeyboardController.GetLayoutAndLocaleFromLanguageId(id, out layout, out locale);

            string cultureName;
            var    inputLanguage = WinKeyboardUtils.GetInputLanguage(locale, layout, out cultureName);

            return(new WinKeyboardDescription(id, GetDisplayName(layout, cultureName), layout, cultureName, false, inputLanguage, this, default(TfInputProcessorProfile)));
        }
            public static void Init(GameLevel gameLevel, KeyboardController keyboard)
            {
                KeyboardEvents events = new KeyboardEvents(gameLevel);

                keyboard.MoveLeft    += events.Keyboard_MoveLeft;
                keyboard.MoveRight   += events.Keyboard_MoveRight;
                keyboard.MoveDown    += events.Keyboard_MoveDown;
                keyboard.RotateLeft  += events.Keyboard_RotateLeft;
                keyboard.RotateRight += events.Keyboard_RotateRight;
                keyboard.Pause       += events.Keyboard_Pause;
            }
        public void Keyman7_GetKeyboards_GivesAtLeastOneAndOnlyKeyman7Ones()
        {
            RequiresKeyman7();
            List <KeyboardController.KeyboardDescriptor> keyboards = KeyboardController.GetAvailableKeyboards(KeyboardController.Engines.Keyman7);

            Assert.Greater(keyboards.Count, 0);
            foreach (KeyboardController.KeyboardDescriptor keyboard in keyboards)
            {
                Assert.AreEqual(KeyboardController.Engines.Keyman7, keyboard.engine);
            }
        }
        protected override void OnRegistered()
        {
            base.OnRegistered();

            AddLayer(uiLayer);

            uiLayer.AddObject(
                new asd.GeometryObject2D()
            {
                Shape = new asd.RectangleShape()
                {
                    DrawingArea = new asd.RectF(
                        new asd.Vector2DF(0.0f, 0.0f)
                        , asd.Engine.WindowSize.To2DF()
                        )
                }
                , Color = new asd.Color(0, 100, 150)
            }
                );

            var button1 = CreateButton(1, -100.0f, -100.0f);
            var button2 = CreateButton(2, -100.0f, 100.0f);
            var button3 = CreateButton(3, 100.0f, 100.0f);
            var button4 = CreateButton(4, 100.0f, -100.0f);

            button1
            .Chain(button2, ButtonDirection.Down)
            .Chain(button3, ButtonDirection.Right)
            .Chain(button4, ButtonDirection.Up)
            .Chain(button1, ButtonDirection.Left)
            ;

            uiLayer.AddObject(button1.GetComponent().Owner);
            uiLayer.AddObject(button2.GetComponent().Owner);
            uiLayer.AddObject(button3.GetComponent().Owner);
            uiLayer.AddObject(button4.GetComponent().Owner);

            var selecter = new ControllerButtonSelecter(button1);

            var keyboard = new KeyboardController <ControllerSelect>();

            keyboard
            .BindKey(ControllerSelect.Up, asd.Keys.Up)
            .BindKey(ControllerSelect.Down, asd.Keys.Down)
            .BindKey(ControllerSelect.Right, asd.Keys.Right)
            .BindKey(ControllerSelect.Left, asd.Keys.Left)
            .BindKey(ControllerSelect.Select, asd.Keys.Space)
            .BindKey(ControllerSelect.Cancel, asd.Keys.Escape)
            ;

            selecter.AddController(keyboard);

            uiLayer.AddComponent(selecter, "Selecter");
        }
    // Resize UI Panel's height when a new line is added
    override protected void NewLineUIPanelResizing()
    {
        base.NewLineUIPanelResizing();
        float UIPanelHeightAugmentation = hiddenTextRect.rect.height * lineHeightFactor * text_text.lineSpacing;
        float controllerTranslation     = UIPanelHeightAugmentation / 2;

        UIPanelRect.sizeDelta = UIPanelRect.sizeDelta + new Vector2(0, UIPanelHeightAugmentation);
        if (panelVAlignment == VERTICAL_ALIGNMENT.UPPER_ALIGNMENT)
        {
            UIPanelRect.anchoredPosition = UIPanelRect.anchoredPosition + new Vector2(0, UIPanelHeightAugmentation / 2.0f);
            controllerTranslation        = UIPanelHeightAugmentation;
        }
        else if (panelVAlignment == VERTICAL_ALIGNMENT.LOWER_ALIGNMENT)
        {
            UIPanelRect.anchoredPosition = UIPanelRect.anchoredPosition - new Vector2(0, UIPanelHeightAugmentation / 2.0f);
            controllerTranslation        = 0;
        }

        // Move controller on Y axis
        if (automaticControllerPosition && linkWithController)
        {
            if (GamePadController != null && GamePadController.isActive)
            {
                GamePadController.TranslatePositionY(controllerTranslation);
            }
            if (KeyboardController != null && KeyboardController.isActive)
            {
                KeyboardController.TranslatePositionY(controllerTranslation);
            }
            if (MouseController != null && MouseController.isActive)
            {
                MouseController.TranslatePositionY(controllerTranslation);
            }
        }

        for (int i = 0; i < textList.Count; i++)
        {
            if (linesCount != i)
            {
                if (textList [i] != null)
                {
                    textList [i].GetComponent <Text> ().text = textList [i].GetComponent <Text> ().text + '\n';
                }
            }
            // Reposition texts GameObject when origin Y position is not 0
            if (originTextYPosition != 0)
            {
                if (textList [i] != null)
                {
                    textList [i].GetComponent <RectTransform> ().anchoredPosition = textList [i].GetComponent <RectTransform> ().anchoredPosition + new Vector2(0, originTextYPosition / 2.0f);
                }
            }
        }
    }
Beispiel #31
0
        public void ErrorKeyboards()
        {
            XklEngineResponder.SetGroupNames = new[] { "Fake" };

            KeyboardController.Initialize(new XkbKeyboardRetrievingAdaptor(new XklEngineResponder()));
            IEnumerable <IKeyboardDefinition> keyboards = Keyboard.Controller.AvailableKeyboards;

            Assert.AreEqual(0, keyboards.Count());
            //Assert.AreEqual(1, KeyboardController.ErrorKeyboards.Count);
            //Assert.AreEqual("Fake", KeyboardController.Errorkeyboards.First().Details);
        }
Beispiel #32
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            inputManager = new InputManager();
            KeyboardController kcontroller = new KeyboardController(inputManager);

            inputManager.AddController(kcontroller);

            LogManager.LogLevel = 0;

            base.Initialize();
        }
Beispiel #33
0
        /*
         * GameState Reqs
         */
        public override void Load()
        {
            UIManager = new UIEngine();
            UIManager.AddAndLoad(new UIFrames.BasicFrame()); // Setup for UI input + GUI stuff

            // For Key Mappings
            _controller = new KeyboardController(UIManager.ActiveFrame, DemoKeyMappings.WasdMapping);
            _controller.KeyControlEngaged    += new KeyControlEventHandler(_controller_KeyControlEngaged);
            _controller.KeyControlDisengaged += new KeyControlEventHandler(_controller_KeyControlDisengaged);

            Reload(); // For Map changes
        }
 public override void Initialize()
 {
     Controller   = new KeyboardController(myGame);
     levelManager = new LevelManager("Levelmanager/sprint4Level.xml");
     levelManager.LoadLevel();
     Level = levelManager.GetCurrentLevel();
     ItemFactory.Instance.SetLevel(Level);
     EnemyFactory.Instance.SetLevel(Level);
     collisionHandler = new CollisionDetection(Level);
     SoundFactory.Instance.Play(SoundFactory.ThemeSongs.MainTheme);
     PlayerOneCamera.Instance.Reset();
 }
Beispiel #35
0
 void ControlSet(GameObject selected, KeyboardController kbrdCtrl)
 {
     PlayerNumber(selected, ref selected.GetComponent <PlayerSelection>().playerNumber);
     selected.GetComponent <PlayerSelection> ().Kcontroller = kbrdCtrl;
     selected.GetComponent <PlayerSelection> ().isSet       = true;
     selected.GetComponent <PlayerSelection> ().isKeyboard  = true;
     selected.GetComponent <SpriteRenderer> ().enabled      = true;
     selected.GetComponent <PlayerSelection> ().Search("Arrow").GetComponent <SpriteRenderer> ().enabled = true;
     selected.GetComponent <PlayerSelection> ().Search("Text").GetComponent <TextMesh> ().text           = selected.GetComponent <PlayerSelection>().playerNumber;
     ableKeyboardList.Remove(kbrdCtrl);
     enableKeyboardList.Add(kbrdCtrl);
 }
		public void Run()
		{
			Engine.Initialize(nameof(Controller_Bundle), 640, 480, new EngineOption());

			var keyboard = new KeyboardController<MyAction>();	// KeyboardControllerクラスを作成
			keyboard.BindKey(Keys.Up, MyAction.Plus);			// 方向キーの上を"Plus"アクションに対応付け
			keyboard.BindKey(Keys.Down, MyAction.Minus);        // 方向キーの下を"Minus"アクションに対応付け

			// SteppingControllerクラスを作成
			var stepping = new SteppingController<MyAction>(keyboard);
			// "Plus"アクションを30Fの間押しっぱなしにしたら、2フレーム間隔で連続入力するよう設定
			stepping.EnableSteppingHold(MyAction.Plus, 30, 2);
			// "Minus"アクションを30Fの間押しっぱなしにしたら、2フレーム間隔で連続入力するよう設定
			stepping.EnableSteppingHold(MyAction.Minus, 30, 2);
			
			// アクションによって増減する値を表示するオブジェクトを作成する。
			var font = Engine.Graphics.CreateDynamicFont("", 24, new Color(255, 255, 255, 255), 0, new Color());
			int count = 10;
			var numText = new TextObject2D();
			numText.Position = new Vector2DF(0, 0);
			numText.Text = $"↑\n{count}\n↓";
			numText.Font = font;
			Engine.AddObject2D(numText);

			// メインループ
			while(Engine.DoEvents())
			{
				if (stepping.GetState(MyAction.Plus) == InputState.Push)
				{
					count++;
				}
				else if (stepping.GetState(MyAction.Minus) == InputState.Push)
				{
					count--;
				}
				numText.Text = $"↑\n{count}\n↓";

				stepping.Update();	// コントローラーの処理を進める
				Engine.Update();
				Recorder.TakeScreenShot(nameof(Controller_Bundle), 60);
			}

			Engine.Terminate();
		}
 public void EnableCtrl(bool enable)
 {
     myoCtrl = GetComponent<MyoCharacterController>();
     keyboardCtrl = GetComponent<KeyboardController>();
     if (enable && myoOrKeyboard)
     {
         myoCtrl.Active = true;
         keyboardCtrl.Active = false;
     }
     else if (enable && !myoOrKeyboard)
     {
         myoCtrl.Active = false;
         keyboardCtrl.Active = true;
     }
     else
     {
         myoCtrl.Active = false;
         keyboardCtrl.Active = false;
     }
 }
        protected override async void OnStart()
        {
            var controller = new KeyboardController<int>();
            controller.BindKey(Keys.Z, 0);

            var window = new MessageWindow()
            {
                Texture = Engine.Graphics.CreateTexture2D("TextWindow.png"),
                Scale = new Vector2DF(0.5f, 1),
            };
            window.TextObject.Font = Engine.Graphics.CreateDynamicFont("", 32, new Color(0, 0, 0, 255), 0, new Color(0, 0, 0, 0));
            window.TextObject.Position = new Vector2DF(30, 25);
            window.WaitIndicator.Texture = Engine.Graphics.CreateTexture2D("ZKey.png");
            window.WaitIndicator.Position = new Vector2DF(500, 110);
            window.SetReadControl(controller, 0);

            Engine.AddObject2D(window);

            await window.TalkMessageAsync(new string[] { "あいうえお", "かきくけこ", "口から\n魚の骨が\nどんどん出てくる" });
            window.Clear();
        }
    public void AddKeyboard1Controller()
    {
        Dictionary<KeyboardController.eSimulatedAxis, string> axis = new Dictionary<KeyboardController.eSimulatedAxis, string>();
        Dictionary<KeyboardController.eKeyboardButtonId, string> buttons = new Dictionary<KeyboardController.eKeyboardButtonId, string>();

        axis.Add(KeyboardController.eSimulatedAxis.UP_LEFT_JOYSTICK, "w");
        axis.Add(KeyboardController.eSimulatedAxis.LEFT_LEFT_JOYSTICK, "a");
        axis.Add(KeyboardController.eSimulatedAxis.DOWN_LEFT_JOYSTICK, "s");
        axis.Add(KeyboardController.eSimulatedAxis.RIGHT_LEFT_JOYSTICK, "d");

        axis.Add(KeyboardController.eSimulatedAxis.UP_RIGHT_JOYSTICK, "up");
        axis.Add(KeyboardController.eSimulatedAxis.LEFT_RIGHT_JOYSTICK, "left");
        axis.Add(KeyboardController.eSimulatedAxis.DOWN_RIGHT_JOYSTICK, "down");
        axis.Add(KeyboardController.eSimulatedAxis.RIGHT_RIGHT_JOYSTICK, "right");

        buttons.Add(KeyboardController.eKeyboardButtonId.ACTION, "space");
        buttons.Add(KeyboardController.eKeyboardButtonId.L1, "space");
        buttons.Add(KeyboardController.eKeyboardButtonId.R1, "return");

        KeyboardController controller = new KeyboardController(axis, buttons);
        m_Keyboard1ControllerId = ControllerInputManager.Instance.AddController(controller);
    }
		public void Run()
		{
			Engine.Initialize(nameof(Controller_Bundle), 640, 480, new EngineOption());

			var keyboard = new KeyboardController<MyAction>();    // KeyboardControllerクラスを作成
			keyboard.BindKey(Keys.Right, MyAction.Advance);       // 方向キーの右を"Advance"アクションに対応付け
			keyboard.BindKey(Keys.Left, MyAction.Back);           // 方向キーの左を"Back"アクションに対応付け
			keyboard.BindKey(Keys.Z, MyAction.Jump);              // Zキーを		"Jump"アクションに対応付け
			keyboard.BindKey(Keys.X, MyAction.Attack);            // Xキーを		"Attack"アクションに対応付け

			var joystick = new JoystickController<MyAction>(0);				// JoystickControllerクラスを作成
			joystick.BindAxis(0, AxisDirection.Positive, MyAction.Advance);	// 左スティックの右方向への入力を"Advance"アクションに対応付け
			joystick.BindAxis(0, AxisDirection.Negative, MyAction.Back);    // 左スティックの左方向への入力を"Back"アクションに対応付け
			joystick.BindButton(0, MyAction.Jump);                          // ボタン1の入力を"Jump"アクションに対応付け
			joystick.BindButton(1, MyAction.Attack);                        // ボタン2の入力を"Attack"アクションに対応付け

			// 用意したKeyboardControllerとJoystickControllerの入力を合体させた新しいコントローラーを作成
			var bundle = new BundleController<MyAction>(keyboard, joystick);

			//ボタンを押したときに表示するオブジェクトたちを作成
			var font = Engine.Graphics.CreateDynamicFont("", 24, new Color(255, 255, 255, 255), 0, new Color());

			var advanceText = new TextObject2D();
			advanceText.Position = new Vector2DF(0, 0);
			advanceText.Text = "Advance";
			advanceText.Font = font;
			Engine.AddObject2D(advanceText);

			var backText = new TextObject2D();
			backText.Position = new Vector2DF(0, 30);
			backText.Text = "Back";
			backText.Font = font;
			Engine.AddObject2D(backText);

			var jumpText = new TextObject2D();
			jumpText.Position = new Vector2DF(0, 60);
			jumpText.Text = "Jump";
			jumpText.Font = font;
			Engine.AddObject2D(jumpText);

			var attackText = new TextObject2D();
			attackText.Position = new Vector2DF(0, 90);
			attackText.Text = "Attack!";
			attackText.Font = font;
			Engine.AddObject2D(attackText);

			// メインループ
			while(Engine.DoEvents())
			{
				// "Advance"アクションに対応付けられたキーが押されているとき、"Advance"と表示する。以下もほぼ同じ
				// 合体して作ったBundleControllerのGetStateを呼び出せば、登録したコントローラーの入力を統合した結果が得られる
				advanceText.IsDrawn = bundle.GetState(MyAction.Advance) == InputState.Hold;
				backText.IsDrawn = bundle.GetState(MyAction.Back) == InputState.Hold;
				jumpText.IsDrawn = bundle.GetState(MyAction.Jump) == InputState.Hold;
				attackText.IsDrawn = bundle.GetState(MyAction.Attack) == InputState.Hold;

				bundle.Update();	// コントローラーの処理を進める
				Engine.Update();
				Recorder.TakeScreenShot(nameof(Controller_Bundle), 60);
			}

			Engine.Terminate();
		}
 void Awake() {
     keyboardController = GameObject.FindGameObjectWithTag("Keyboard").GetComponent<KeyboardController>();
     uiMove_Tool = GameObject.FindGameObjectWithTag("SelectedObj").GetComponent<UIMove_Tool>();
 }
Beispiel #42
0
        public void init()
        {
            verified = false;

            if (!SystemInformation.UserInteractive)
            {
                isUserInteractive.SetValue(null, true);
            }

            if (UseHidden)
            {
                testDesktop = new Desktop("MbUnitForms Test Desktop", DisplayHidden);
            }

            modal = new ModalFormTester();
            mouse = new MouseController();
            keyboard = new KeyboardController();

            Setup();
        }
    private string GetKeyCode(KeyboardController.eSimulatedAxis simulatedAxisId)
    {
        string keyCode = "";
        if (m_SimulatedAxisMaps.ContainsKey(simulatedAxisId))
        {
            keyCode = m_SimulatedAxisMaps[simulatedAxisId];
        }

        return keyCode;
    }
 private void AddButtonMap(KeyboardController.eKeyboardButtonId buttonId, string inputKey)
 {
     AddButtonMap((BaseController.eButtonId)buttonId, inputKey);
 }
 public bool GetButtonDown(KeyboardController.eKeyboardButtonId buttonId)
 {
     return GetButtonDown((BaseController.eButtonId)buttonId);
 }
    // Use this for initialization
    private void Start()
    {
        myoCtrl = GetComponent<MyoCharacterController>();
        keyboardCtrl = GetComponent<KeyboardController>();
        boxCollider = GetComponent<BoxCollider2D>();
        currVelocity = Vector2.zero;

        //EnableCtrl(true);
    }
Beispiel #47
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            Global.Content = Content;

            // Allow mouse
            //IsMouseVisible = true;
            cursor = CustomCusor.GetInstance();

            // Initialize map
            gridMap = WordGrid.GetInstance();
            //gridMap.Load(Content.Load<GridData>(Utils.GetMapFileName(Consts.DEFALT_MAP_NAME)));

            // Initialize dictionary
            dictionary = TrieDictionary.GetInstance();
            dictionary.Load(Content.Load<string[]>(Utils.GetDictionaryFileName(Consts.DEFAULT_DICTIONARY_NAME)));

            // Initialize logo panel
            logoPanel = LogoPanel.GetInstance();

            // Initialize menu
            menuContainer = MenuContainer.GetInstance();

            // Initialize background
            background = new Sprite2D(0, 0, Utils.LoadTextures(Utils.GetImageFileName("Background")));

            // Initialize notification
            notification = GameNotification.GetInstance();

            // Initialize controller
            mouseController = MouseController.GetInstance();
            keyboardController = KeyboardController.GetInstance();

            // Initialize button
            backButton = new TileButton(25, 620, Utils.GetImageFileName("Back"));
            soundButton = new TileButton(70, 620, Utils.GetImageFileName("Sound"));

            // Load sound effects
            Global.clickSound = Content.Load<SoundEffect>(@"Sound\click");
            Global.achieveSound = Content.Load<SoundEffect>(@"Sound\achieve");
            Global.themeSong = Content.Load<Song>(@"Sound\theme");

            Global.UpdatePhase(Phase.MENU_LOADING);
        }
 private PlayerGameController()
 {
     keyboardController = KeyboardController.GetInstance();
     mouseController = MouseController.GetInstance();
 }
 void Awake() {
     if(kc == null) {
         kc = NodeSystemEssentials.keyboardController;
     }
 }