示例#1
0
        public static void Initialize(int targetCharacter)
        {
            _targetCharacter = targetCharacter;
            buttons.Clear();
            characters.Clear();
            buttonCount = 0;
            keyReady    = characterReady = false;
            Task.Run(() =>
            {
                USM.OnMessageReceived += (m) =>
                {
                    if (m is CharacterListMessage message)
                    {
                        characters     = message.Characters;
                        characterReady = true;

                        while (!keyReady)
                        {
                            Thread.Sleep(10);
                        }
                        InitializeGrid();
                    }
                };
                USM.Send(new GetCharacterListMessage());
            }).Wait();
        }
示例#2
0
 public override void KeyPressed(KeyPayload payload)
 {
     if (!USM.IsConnected)
     {
         Connection.ShowAlert();
         return;
     }
     USM.Send(new SwapPlayerMessage());
 }
        public ChangeCharacter(SDConnection connection, InitialPayload payload) : base(connection, payload)
        {
            USM.OnMessageReceived += OnMessage;
            USM.Send(new GetCurrentCharactersMessage());

            if (payload.Settings.ContainsKey("playerId"))
            {
                string playerIdString = payload.Settings["playerId"].ToString();
                playerId = int.Parse(playerIdString);
            }
        }
 public override void KeyPressed(KeyPayload payload)
 {
     if (!USM.IsConnected)
     {
         Connection.ShowAlert();
         return;
     }
     USM.Send(new DecrementPlayerScoreMessage {
         Player = playerId
     });
 }
示例#5
0
        private static void LoadAltGrid(CharacterInfo pickedCharacter, int sourcePage, int altPage)
        {
            int minPage = 0;
            int maxPage = pickedCharacter.Alts.Count / 10;

            foreach (var button in buttons)
            {
                KeyCoordinates coordinates = button.ButtonInfo.Coordinates;
                if (coordinates.Row == 0)
                {
                    switch (coordinates.Column)
                    {
                    case 0:     // Return button
                        button.SetImage(Path.Combine(_executionFolder, @"Images\back.png"));
                        button.OnClick = () => { ChangeGridPage(sourcePage); };
                        break;

                    case 2:     // Prev button
                        button.SetImage(Path.Combine(_executionFolder, @"Images\previous.png"));
                        if (altPage > minPage)
                        {
                            button.OnClick = () => { LoadAltGrid(pickedCharacter, sourcePage, altPage - 1); }
                        }
                        ;
                        else
                        {
                            button.OnClick = null;
                        }
                        break;

                    case 3:     // Indicator
                        button.Connection.SetTitleAsync($"{altPage + 1}/{Math.Ceiling(pickedCharacter.Alts.Count/10f)}");
                        break;

                    case 4:     // Next button
                        button.SetImage(Path.Combine(_executionFolder, @"Images\next.png"));
                        if (altPage < maxPage)
                        {
                            button.OnClick = () => { LoadAltGrid(pickedCharacter, sourcePage, altPage + 1); }
                        }
                        ;
                        else
                        {
                            button.OnClick = null;
                        }
                        break;

                    case 1:     // Unused button
                    default:
                        break;
                    }
                }
                else
                {
                    int altCharacterPosition = altPage * 10 + coordinates.Column + (coordinates.Row - 1) * 5;
                    if (altCharacterPosition >= pickedCharacter.Alts.Count)
                    {
                        button.ResetImage();
                    }
                    else
                    {
                        var pickedAlt = pickedCharacter.Alts[altCharacterPosition];
                        button.SetImage(pickedAlt.IconPath);
                        button.OnClick = () =>
                        {
                            USM.Send(new ChangeCharacterMessage {
                                CharacterName = pickedAlt.Name, PlayerId = _targetCharacter
                            });
                            button.Connection.SwitchProfileAsync("");
                        };
                    }
                }
            }
        }
示例#6
0
 static void Main(string[] args)
 {
     USM.Run();
     SDWrapper.Run(args);
 }
 public DisplayScore(SDConnection connection, InitialPayload payload) : base(connection, payload)
 {
     USM.OnMessageReceived += OnMessage;
     USM.Send(new GetCurrentScoreMessage());
 }