Ejemplo n.º 1
0
    public void ButtonClick(ButtonKind button)
    {
        switch (button)
        {
        case ButtonKind.BeginGame:
            //切换场景,准备开始游戏
            print("开始游戏");
            //panel.SetActive(false);
            //if (panel == null)
            //    print("获取失败");
            //panel.SetActive(true);
            SceneManager.LoadScene(1);
            break;

        case ButtonKind.LoadGame:
            //加载游戏
            //暂未实现
            print("加载游戏");
            break;

        case ButtonKind.LeaveGame:
            //退出游戏
            print("离开游戏");
            Application.Quit();
            break;

        case ButtonKind.About:
            //关于
            print("关于");
            break;

        default:
            break;
        }
    }
Ejemplo n.º 2
0
 public Button(string text, ButtonKind kind, ButtonBorderStyle style)
 {
     _ButtonBorderStyle = style;
     _Kind     = kind;
     _Text     = text;
     _Visible  = true;
     _Painter  = CreatePainter();
     _ViewInfo = CreateViewInfo();
 }
Ejemplo n.º 3
0
        private string GetButtonName(ButtonKind kind)
        {
            var buttonDict = new Dictionary <ButtonKind, string>
            {
                //ツリー名変更(Tsuchiya)
                { ButtonKind.Right, "PicArea/RightButton" },
                { ButtonKind.Left, "PicArea/LeftButton" },
                { ButtonKind.Center, "PicArea/CenterButton" }
            };

            return(buttonDict[kind]);
        }
 //ButtonKindを入力ボタンに変換する
 private Key Get_Key(ButtonKind kind)
 {
     if (kind == ButtonKind.jump)
     {
         return(Key.Jump);
     }
     if (kind == ButtonKind.attack)
     {
         return(Key.Attack);
     }
     if (kind == ButtonKind.fly)
     {
         return(Key.Fly);
     }
     return(null);
 }
Ejemplo n.º 5
0
        private void SetButtonTexture(ButtonKind kind, Texture2D btnTex)
        {
            var img = GetButton(GetButtonName(kind)).GetComponent <UnityEngine.UI.Image>();

            img.overrideSprite = Sprite.Create(btnTex, new Rect(0, 0, btnTex.width, btnTex.height), new Vector2(0, 0));
        }
Ejemplo n.º 6
0
			internal Button(ButtonKind kind, String title)
			{
				m_Kind = kind;
				m_Title = title;
			}
Ejemplo n.º 7
0
 public void RebindKey(ButtonKind button)
 {
     _keyToRebind = button;
     RebindStatus = true;
 }
Ejemplo n.º 8
0
        public void UpdateInput()
        {
            //checking with held
            foreach (var button in ButtonStates.ToArray())
            {
                if (button.Value == ButtonState.Press)
                {
                    ButtonStates[button.Key] = ButtonState.Held;
                }
                else if (button.Value == ButtonState.Lifted)
                {
                    ButtonStates[button.Key] = ButtonState.Off;
                }
            }



            if (!WindowManager.isFocused() && FocusInput)
            {
                return;
            }

            int queueSize = _inputQueue.Count;

            for (int i = 0; i < queueSize; i++)
            {
                RawInputState rawInputState;
                while (!_inputQueue.TryDequeue(out rawInputState))
                {
                    Console.WriteLine("");
                    Thread.Yield();
                }

                //for rebinding
                if (RebindStatus)
                {
                    if (rawInputState.State)
                    {
                        //thas the one
                        //this code, is bad.
                        foreach (var item in _buttonBindings.ToArray())
                        {
                            if (item.Value == _keyToRebind)
                            {
                                _buttonBindings.Remove(item.Key);
                                _buttonBindings.Add(rawInputState.Code, _keyToRebind);

                                RebindStatus = false;
                                Logger.DebugLog(JsonConvert.SerializeObject(_buttonBindings));
                            }
                        }
                    }
                    return;
                }


                if (_buttonBindings.ContainsKey(rawInputState.Code))
                {
                    ButtonKind buttonKind = _buttonBindings[rawInputState.Code];
                    if (rawInputState.State && (ButtonStates[buttonKind] == ButtonState.Off || ButtonStates[buttonKind] == ButtonState.Lifted))
                    {
                        ButtonStates[buttonKind] = ButtonState.Press;
                    }
                    else if (!rawInputState.State && (ButtonStates[buttonKind] == ButtonState.Press || ButtonStates[buttonKind] == ButtonState.Held))
                    {
                        ButtonStates[buttonKind] = ButtonState.Lifted;
                    }
                }
            }
        }
 protected virtual Button CreateButton(string text, ButtonKind kind, ButtonBorderStyle style)
 {
     return(new Button(text, kind, style));
 }
Ejemplo n.º 10
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            if (handlingClick)
            {
                return;
            }

            this.viewModel.StatusMessage = "Running ...";

            handlingClick = true;
            try
            {
                buttonKind = ButtonKindFromModel();

                // Get the list of Microsoft Bands paired to the phone.
                IBandInfo[] pairedBands = await BandClientManager.Instance.GetBandsAsync();

                if (pairedBands.Length < 1)
                {
                    this.viewModel.StatusMessage = "This sample app requires a Microsoft Band paired to your device. Also make sure that you have the latest firmware installed on your Band, as provided by the latest Microsoft Health app.";
                    return;
                }

                // Connect to Microsoft Band.
                using (IBandClient bandClient = await BandClientManager.Instance.ConnectAsync(pairedBands[0]))
                {
                    // Create a Tile with a TextButton on it.
                    // WARNING! This tile guid is only an example. Please do not copy it to your test application;
                    // always create a unique guid for each application.
                    // If one application installs its tile, a second application using the same guid will fail to install
                    // its tile due to a guid conflict. In the event of such a failure, the text of the exception will not
                    // report that the tile with the same guid already exists on the band.
                    // There might be other unexpected behavior.
                    Guid     myTileId = new Guid("497B746E-4F5F-44D4-96E2-FC46D407B6E3");
                    BandTile myTile   = new BandTile(myTileId)
                    {
                        Name      = "My Tile",
                        TileIcon  = await LoadIcon("ms-appx:///Assets/SampleTileIconLarge.png"),
                        SmallIcon = await LoadIcon("ms-appx:///Assets/SampleTileIconSmall.png")
                    };

                    await BuildLayout(myTile);

                    // Remove the Tile from the Band, if present. An application won't need to do this everytime it runs.
                    // But in case you modify this sample code and run it again, let's make sure to start fresh.
                    await bandClient.TileManager.RemoveTileAsync(myTileId);

                    // Create the Tile on the Band.
                    await bandClient.TileManager.AddTileAsync(myTile);

                    await bandClient.TileManager.SetPagesAsync(myTileId, new PageData(new Guid("5F5FD06E-BD37-4B71-B36C-3ED9D721F200"), 0, GetPageElementData()));

                    // Subscribe to Tile events.
                    int buttonPressedCount = 0;
                    TaskCompletionSource <bool> closePressed = new TaskCompletionSource <bool>();

                    bandClient.TileManager.TileButtonPressed += (s, args) =>
                    {
                        Dispatcher.RunAsync(
                            CoreDispatcherPriority.Normal,
                            () =>
                        {
                            buttonPressedCount++;
                            this.viewModel.StatusMessage = string.Format("TileButtonPressed = {0}", buttonPressedCount);
                        }
                            );
                    };
                    bandClient.TileManager.TileClosed += (s, args) =>
                    {
                        closePressed.TrySetResult(true);
                    };

                    await bandClient.TileManager.StartReadingsAsync();

                    // Receive events until the Tile is closed.
                    this.viewModel.StatusMessage = "Check the Tile on your Band (it's the last Tile). Waiting for events ...";

                    await closePressed.Task;

                    // Stop listening for Tile events.
                    await bandClient.TileManager.StopReadingsAsync();

                    this.viewModel.StatusMessage = "Done.";
                }
            }
            catch (Exception ex)
            {
                this.viewModel.StatusMessage = ex.ToString();
            }
            finally
            {
                handlingClick = false;
            }
        }
Ejemplo n.º 11
0
 public bool GetButtonUp(ButtonKind button = ButtonKind.Trigger)
 {
     return(_device.GetPressUp(BUTTONMASKS[button]));
 }