Ejemplo n.º 1
0
 // Key bindings
 void BindKeys()
 {
     keyboard.BindKey(KeyCode.F, F_Key);
     keyboard.BindKey(KeyCode.G, G_Key);
     keyboard.BindKey(KeyCode.J, J_Key);
     keyboard.BindKey(KeyCode.K, K_Key);
 }
Ejemplo n.º 2
0
        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);
		}
Ejemplo n.º 3
0
		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();
		}
Ejemplo n.º 4
0
        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");
        }
Ejemplo n.º 5
0
        protected override void OnRegistered()
        {
            base.OnRegistered();

            AddLayer(uiLayer);

            var background = new asd.TextureObject2D();

            background.Texture = asd.Engine.Graphics.CreateTexture2D("Resources/Menu.png");
            uiLayer.AddObject(background);

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

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

            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.Z)
            .BindKey(ControllerSelect.Cancel, asd.Keys.X)
            ;

            selecter.AddController(keyboard);

            uiLayer.AddComponent(selecter, "Selecter");
        }
Ejemplo n.º 6
0
        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();
        }
Ejemplo n.º 7
0
        protected override void OnRegistered()
        {
            base.OnRegistered();

            AddLayer(uiLayer);

            var background = new asd.TextureObject2D();

            background.Texture = asd.Engine.Graphics.CreateTexture2D("Resources/Menu.png");
            uiLayer.AddObject(background);

            // フォントを生成する。
            var font = asd.Engine.Graphics.CreateFont("font.aff");



            // 描画に使うフォントを設定する。
            PlayerSelectText.Font = font;

            // 描画位置を指定する。
            PlayerSelectText.Position = new asd.Vector2DF(0, 0);

            Singleton.Getsingleton();
            // 描画する文字列を指定する。
            PlayerSelectText.Text = "";

            // 文字描画オブジェクトのインスタンスをエンジンへ追加する。
            uiLayer.AddObject(PlayerSelectText);

            var button1 = CreateButton(PlayerType.Normal, -150.0f, 0.0f, typelist);
            var button2 = CreateButton(PlayerType.Speed, -50.0f, 0.0f, typelist);
            var button3 = CreateButton(PlayerType.Sniper, 50.0f, 0.0f, typelist);


            button1
            .Chain(button2, ButtonDirection.Right)
            .Chain(button3, ButtonDirection.Right)
            .Chain(button1, ButtonDirection.Right)
            ;

            uiLayer.AddObject(button1.GetComponent().Owner);
            uiLayer.AddObject(button2.GetComponent().Owner);
            uiLayer.AddObject(button3.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.Z)
            .BindKey(ControllerSelect.Cancel, asd.Keys.X)
            ;

            selecter.AddController(keyboard);

            uiLayer.AddComponent(selecter, "Selecter");
        }
Ejemplo n.º 8
0
		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();
		}