Exemple #1
0
        /// <summary>
        /// Show Achievements for the selected game.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ListviewGames_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ListGames GameSelected = (ListGames)((ListBox)sender).SelectedItem;

            if (GameSelected != null)
            {
                listAchievementBorder.BorderThickness = new Thickness(0);


                Guid GameId = Guid.Parse(GameSelected.Id);

                GameAchievements    GameAchievements = AchievementsDatabase.Get(GameId);
                List <Achievements> ListAchievements = GameAchievements.Achievements;

                SuccessStory_Achievements_List.Children.Clear();
                SuccessStory_Achievements_List.Children.Add(new SuccessStoryAchievementsList(ListAchievements, this));
                SuccessStory_Achievements_List.UpdateLayout();


                AchievementsGraphicsDataCount GraphicsData       = AchievementsDatabase.GetCountByMonth(GameId);
                string[]         StatsGraphicsAchievementsLabels = GraphicsData.Labels;
                SeriesCollection StatsGraphicAchievementsSeries  = new SeriesCollection();
                StatsGraphicAchievementsSeries.Add(new LineSeries
                {
                    Title  = "",
                    Values = GraphicsData.Series
                });

                SuccessStory_Achievements_Graphics_Game.Children.Clear();
                SuccessStory_Achievements_Graphics_Game.Children.Add(new SuccessStoryAchievementsGraphics(StatsGraphicAchievementsSeries, StatsGraphicsAchievementsLabels, this));
                SuccessStory_Achievements_Graphics_Game.UpdateLayout();

                GC.Collect();
            }
        }
        private void Miner_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (EndGame == null)
            {
                ListGames lg = new ListGames();

                if (textBox_Timer.Text != "00:00")
                {
                    DialogResult dialog = MessageBox.Show("Игра только началась. Закрыть окно?", "Предупреждение", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dialog == DialogResult.Yes)
                    {
                        sound.Stop();
                        lg.Show();
                    }
                    if (dialog == DialogResult.No)
                    {
                        e.Cancel = true;
                    }
                }
                else
                {
                    sound.Stop();
                    lg.Show();
                }
            }
            else
            {
                sound.Stop();
            }
        }
Exemple #3
0
        private void buttonExit_Click(object sender, EventArgs e)
        {
            selectForm.Close();
            this.Close();
            ListGames LG = new ListGames();

            LG.Show();
        }
 private void GameScreen_KeyDown(object sender, KeyEventArgs e)
 {
     //выход на ESC
     if (e.KeyCode == Keys.Escape && m_active)
     {
         m_timer.Dispose();
         ListGames list = new ListGames();
         list.Show();
         Close();
     }
 }
 private void BtnAddGame_Click(object sender, EventArgs e)
 {
     Logger.Trace($"{nameof(BtnAddGame_Click)}(..., ...);");
     using (var dialog = new AddGameDialog())
     {
         if (dialog.ShowDialog() == DialogResult.OK)
         {
             Configuration.Games.GamesToAdd = Configuration.Games.GamesToAdd.Append(dialog.GameInfo);
             ListGames.UpdateItems(Configuration.Games.GamesToAdd);
             Logger.Debug($"{dialog.GameInfo.SubId}:{dialog.GameInfo.Name} added.");
         }
     }
 }
        private async void ScanGamesMenuItem_Click(object sender, RoutedEventArgs e)
        {
            var emulator = ((MenuItem)sender).DataContext as PlatformableEmulator;
            var path     = Dialogs.SelectFolder(this);

            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            await Model.SearchGames(path, emulator);

            ListGames.ScrollIntoView(Model.GamesList.Count == 0 ? null : Model.GamesList.Last());
        }
        private void BtnRemoveGame_Click(object sender, EventArgs e)
        {
            Logger.Trace($"{nameof(BtnRemoveGame_Click)}(..., ...);");
            var index = ListGames.SelectedIndex;

            if (index < 0 || index >= ListGames.Items.Count)
            {
                return;
            }

            var _temp = Configuration.Games.GamesToAdd.ToList();
            var _game = _temp.ElementAtOrDefault(index);

            Logger.Debug($"{(_game?.SubId)?.ToString() ?? "NULL"}:{_game?.Name ?? "NULL"} removed.");
            _temp.RemoveAt(index);
            Configuration.Games.GamesToAdd = _temp;
            ListGames.UpdateItems(Configuration.Games.GamesToAdd);
        }
    // Use this for initialization
    void Start()
    {
        Debug.Log("Starting network now!");
        this.send_to_address   = IPAddress.Parse("127.0.0.1");
        this.sending_end_point = new IPEndPoint(send_to_address, 24816);
        sending_socket.Connect(this.sending_end_point);

        // 1. Fetch network!
        ListGames outmsg = new ListGames();

        this.sendNetPacket(MsgType.ListGames, outmsg);

        // Start Receive and a new Accept
        try
        {
            sending_socket.BeginReceive(this.buff, 0, this.buff.Length, SocketFlags.None, new AsyncCallback(ReceiveCallback), null);
        }
        catch (SocketException e)
        {
            // DO something
            System.Console.WriteLine(e.ToString());
        }
    }
        private void BtnLoadIds_Click(object sender, EventArgs e)
        {
            Logger.Trace($"void {nameof(BtnLoadIds_Click)}();");

            openFileDialog1.Filter = "All supported|*.txt;*.json|Text file|*.txt|JSON file|*.json|Try to parse from any type|*.*";
            openFileDialog1.Title  = "Load game sub IDs";

            if (openFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            Logger.Trace($"Selected id's file: {openFileDialog1.FileName}");

            var fileData = System.IO.File.ReadAllText(openFileDialog1.FileName);

            Configuration.Games.GamesToAdd = Configuration.Games.GamesToAdd ?? new Models.GameInfo[0];
            try
            {
                var games = Newtonsoft.Json.JsonConvert.DeserializeObject <IEnumerable <Models.GameInfo> >(fileData);
                var _temp = Configuration.Games.GamesToAdd.ToList();

                games = games.Where(x => !_temp.Any(g => g.Equals(x)));
                _temp.AddRange(games);

                Configuration.Games.GamesToAdd = _temp;
            }
            catch (Newtonsoft.Json.JsonException jEx)
            {
                Logger.Error("JSON exception was thrown... It's probably file don't contains JSON data. Trying to parse it...", jEx);
                try
                {
                    var matches = Regex.Matches(fileData, @"(\d+):(.*)", RegexOptions.IgnoreCase);
                    foreach (Match match in matches)
                    {
                        try
                        {
                            var game = new Models.GameInfo()
                            {
                                SubId = int.Parse(match.Groups[1].Value),
                                Name  = match.Groups[2].Value
                            };

                            if (!Configuration.Games.GamesToAdd.Any(x => x.Equals(game)))
                            {
                                Configuration.Games.GamesToAdd = Configuration.Games.GamesToAdd.Append(game);
                            }
                        }
                        catch (Exception cEx) { Logger.Error("Parsing error (in foreach)!", cEx); }
                    }
                }
                catch (Exception ex)
                {
                    Logger.Error("Parsing via regexp. error!", ex);
                }
            }
            catch (Exception ex)
            {
                Logger.Error("Parsing error!", ex);
            }

            Logger.Trace($"Updating {nameof(ListGames)}... Count of games: {Configuration.Games.GamesToAdd.Count()}");
            ListGames.UpdateItems(Configuration.Games.GamesToAdd);
        }
Exemple #10
0
// ParseNetMessage accepts input of raw bytes from a NetMessage. Parses and returns a Net message.
    public static INet Parse(ushort msgType, byte[] content)
    {
        INet    msg = null;
        MsgType mt  = (MsgType)msgType;

        switch (mt)
        {
        case MsgType.Multipart:
            msg = new Multipart();
            break;

        case MsgType.Heartbeat:
            msg = new Heartbeat();
            break;

        case MsgType.Connected:
            msg = new Connected();
            break;

        case MsgType.Disconnected:
            msg = new Disconnected();
            break;

        case MsgType.CreateAcct:
            msg = new CreateAcct();
            break;

        case MsgType.CreateAcctResp:
            msg = new CreateAcctResp();
            break;

        case MsgType.Login:
            msg = new Login();
            break;

        case MsgType.LoginResp:
            msg = new LoginResp();
            break;

        case MsgType.Character:
            msg = new Character();
            break;

        case MsgType.ListGames:
            msg = new ListGames();
            break;

        case MsgType.ListGamesResp:
            msg = new ListGamesResp();
            break;

        case MsgType.CreateGame:
            msg = new CreateGame();
            break;

        case MsgType.CreateGameResp:
            msg = new CreateGameResp();
            break;

        case MsgType.JoinGame:
            msg = new JoinGame();
            break;

        case MsgType.GameConnected:
            msg = new GameConnected();
            break;

        case MsgType.GameMasterFrame:
            msg = new GameMasterFrame();
            break;

        case MsgType.Entity:
            msg = new Entity();
            break;

        case MsgType.MovePlayer:
            msg = new MovePlayer();
            break;

        case MsgType.UseAbility:
            msg = new UseAbility();
            break;

        case MsgType.AbilityResult:
            msg = new AbilityResult();
            break;

        case MsgType.EndGame:
            msg = new EndGame();
            break;
        }
        MemoryStream ms = new MemoryStream(content);

        msg.Deserialize(new BinaryReader(ms));
        return(msg);
    }