コード例 #1
0
        public PlayerCharacterChoice(Player player)
        {
            this.player = player;

            ServerDbContext dbContext = ((GameMode)GameMode.Instance).DbContext;

            playerChars = dbContext.Characters.Select(c => c).Where(c => c.Account == player.AccountData).ToList();

            if (playerChars.Count == 0)
            {
                charCreationMenu = new PlayerCharacterCreation();
            }
            else
            {
                charList           = new ListDialog("Choix de personnage", "Confirmer", "Quitter");
                charList.Response += ChoiceResponse;

                foreach (Character chr in playerChars)
                {
                    charList.AddItem(chr.Name + " (Niveau " + chr.Level + " - " + Utils.SexUtils.SexToString(chr.Sex) + " de " + chr.Age + " ans)");
                }

                if (playerChars.Count < SemiRP.Constants.MAX_CHARACTERS)
                {
                    charList.AddItem(Color.DarkGray + "Créer un autre personnage...");
                }
            }
        }
コード例 #2
0
        public void ChoiceResponse(object sender, DialogResponseEventArgs e)
        {
            if (e.DialogButton == DialogButton.Right)
            {
                e.Player.Kick();
                return;
            }

            if (e.ListItem < playerChars.Count)
            {
                player.ActiveCharacter = playerChars[e.ListItem];
                player.SendClientMessage("Tu as choisi " + player.ActiveCharacter.Name);
                player.SpawnCharacter();
            }
            else
            {
                charCreationMenu = new PlayerCharacterCreation();
                this.Show();
            }
        }