public CharacterSelection(string builder) { string[] pieces = builder.Split(delim); visibleTiles = Tile.TileCollectionFromString(pieces[0]); CentralCharacter = new Character(pieces[1]); visibleCharacters = DisplayCharacter.DisplayCharacterCollectionFromString(pieces[2]); }
public static void Set(Form primaryForm, CharacterSelection initialScene) { host = primaryForm; DrivingCharacter = initialScene.CentralCharacter; playScene = new PlayScene(); playScene.Location = new Point(padding, padding); playScene.Size = new Size(host.ClientRectangle.Width - padding * 2, host.ClientRectangle.Height - padding * 2); host.Resize += host_Resize; if(!_eventsInitialized) { _eventsInitialized = true; if (DrivingCharacter.IsDM) { host.KeyDown += playScene_DM_KeyDown; playScene.TileSelected += playScene_DM_TileSelected; } else { host.KeyDown += playScene_KeyDown; playScene.TileSelected += playScene_TileSelected; } } playScene.ViewCenterX = initialScene.CentralCharacter.LocationX; playScene.ViewCenterY = initialScene.CentralCharacter.LocationY; playScene.ViewCenterZ = initialScene.CentralCharacter.LocationZ; host.Controls.Add(playScene); playScene.Add(initialScene.visibleTiles); playScene.Add(initialScene.visibleCharacters); Updater = new BackgroundWorker(); Updater.DoWork += Updater_DoWork; Updater.RunWorkerCompleted += Updater_RunWorkerCompleted; Updater.RunWorkerAsync(); }
public MoveRequest(Character ch, int x, int y, int z, Direction facing) { AccountName = ch.AccountName; CharacterName = ch.CharacterName; X = x; Y = y; Z = z; Facing = facing; }
public CharacterSelection(Character character) { if (!Map.LoadedMaps.ContainsKey(character.Map)) { Map.LoadedMaps.Add(character.Map, new Map() { Name = character.Map }); } // We need to check if this character is already present just in case this is a character // relogging. Map currentMap = Map.LoadedMaps[character.Map]; if (!currentMap.PresentCharacters.Contains(character)) { currentMap.AddCharacter(character); } visibleTiles = currentMap.GetNearby(character.LocationX, character.LocationY, character.LocationZ); visibleCharacters = currentMap.GetNearbyCharacters(character.LocationX, character.LocationY, character.LocationZ); CentralCharacter = character; }
private void equipItem(InventorySlot slot, string identifier) { if (ChInv.Equipment.ContainsKey((int)slot)) { string ret = ServiceConsumer.EquipItem(PlayerInterface.DrivingCharacter.AccountName, PlayerInterface.DrivingCharacter.CharacterName, ChInv.AccountName, ChInv.CharacterName, identifier, (int)slot); if (ret.StartsWith("Error")) return; else { ChInv = new Character(ret); RefreshInventory(); return; } } }
public CharacterPanel(Character toDisplay, bool readOnly) { Init(toDisplay, readOnly); }
public CharacterPanel(Character toDisplay) { Init(toDisplay, true); }
private void Init(Character toDisplay, bool readOnly) { ShownCharacter = toDisplay; this.Text = ShownCharacter.CharacterName; this.BackColor = Color.Black; this.ForeColor = Color.White; this.Width = 600; this.Height = 700; ReadOnly = readOnly; int currentY= 0; if (readOnly) { LabelName.Text = ShownCharacter.CharacterName; StyleLabel(LabelName); LabelName.Location = new Point(Math.Max(0, (this.Width - LabelName.Width) / 2), padding); Controls.Add(LabelName); currentY = LabelName.Location.Y + LabelName.Height; } else { TextBox ChangeName = new TextBox(); ChangeName.Text = ShownCharacter.CharacterName; StyleLabel(ChangeName); ChangeName.BackColor = Color.DarkGray; ChangeName.Width = 500; ChangeName.Location = new Point(Math.Max(0, (this.Width - ChangeName.Width) / 2), padding); ChangeName.TextChanged += ChangeName_TextChanged; Controls.Add(ChangeName); currentY = ChangeName.Location.Y + ChangeName.Height; } if (readOnly) { LabelSexRace.Text = Race.GetRace(ShownCharacter.CharacterRace).Name; if (ShownCharacter.Sex == 1) { LabelSexRace.Text += " Male "; } else { LabelSexRace.Text += " Female "; } LabelSexRace.Text += Profession.GetProfession(ShownCharacter.CharacterProfession).Name; StyleLabel(LabelSexRace); LabelSexRace.Location = new Point(Math.Max(0, (this.Width - LabelSexRace.Width) / 2), currentY); currentY = LabelSexRace.Location.Y + LabelSexRace.Height; } else { ComboBox ComboRace = new ComboBox(); ComboRace.ForeColor = Color.White; ComboRace.BackColor = Color.Black; ComboRace.Height = ComboRace.PreferredHeight; ComboRace.Width = 90; foreach(Race race in Race.GetRaces()) { ComboRace.Items.Add(race.Name); } ComboRace.AutoCompleteMode = AutoCompleteMode.Suggest; ComboRace.AutoCompleteSource = AutoCompleteSource.CustomSource; ComboRace.AutoCompleteCustomSource = new AutoCompleteStringCollection(); ComboRace.Text = Race.GetRace(ShownCharacter.CharacterRace).Name; ComboRace.SelectedIndexChanged += ComboRace_SelectedIndexChanged; ComboRace.Location = new Point(100, currentY); this.Controls.Add(ComboRace); ComboBox ComboSex = new ComboBox(); ComboSex.ForeColor = Color.White; ComboSex.BackColor = Color.Black; ComboSex.Height = ComboSex.PreferredHeight; ComboSex.Width = 90; ComboSex.Items.Add("Female"); ComboSex.Items.Add("Male"); ComboSex.AutoCompleteMode = AutoCompleteMode.Suggest; ComboSex.AutoCompleteSource = AutoCompleteSource.CustomSource; ComboSex.AutoCompleteCustomSource = new AutoCompleteStringCollection(); if(ShownCharacter.Sex == 1) { ComboSex.Text = "Male"; } else { ComboSex.Text = "Female"; } ComboSex.SelectedIndexChanged += ComboSex_SelectedIndexChanged; ComboSex.Location = new Point(200, currentY); this.Controls.Add(ComboSex); ComboBox ComboProfession = new ComboBox(); ComboProfession.ForeColor = Color.White; ComboProfession.BackColor = Color.Black; ComboProfession.Height = ComboProfession.PreferredHeight; ComboProfession.Width = 200; foreach(Profession prof in Profession.GetProfessions()) { ComboProfession.Items.Add(prof.Name); } ComboProfession.AutoCompleteMode = AutoCompleteMode.Suggest; ComboProfession.AutoCompleteSource = AutoCompleteSource.CustomSource; ComboProfession.AutoCompleteCustomSource = new AutoCompleteStringCollection(); ComboProfession.Text = Profession.GetProfession(ShownCharacter.CharacterProfession).Name; ComboProfession.SelectedIndexChanged += ComboProfession_SelectedIndexChanged; ComboProfession.Location = new Point(300, currentY); this.Controls.Add(ComboProfession); currentY = ComboProfession.Location.Y + ComboProfession.Height; } LabelAbilityHead.Text = "Abilities"; StyleLabel(LabelAbilityHead); LabelAbilityHead.Location = new Point(Math.Max(0, (this.Width - LabelAbilityHead.Width) / 2), currentY + (padding * 2)); int colWidth = (this.ClientRectangle.Width - (padding * 5)) / 4; LabelPhysicalHead.Text = "Physical"; StyleLabel(LabelPhysicalHead); LabelPhysicalHead.Location = new Point(padding, LabelAbilityHead.Location.Y + LabelAbilityHead.Height); LabelMentalHead.Text = "Mental"; StyleLabel(LabelMentalHead); LabelMentalHead.Location = new Point((padding * 2) + colWidth, LabelAbilityHead.Location.Y + LabelAbilityHead.Height); LabelSocialHead.Text = "Social"; StyleLabel(LabelSocialHead); LabelSocialHead.Location = new Point((padding * 3) + (colWidth * 2), LabelAbilityHead.Location.Y + LabelAbilityHead.Height); LabelSupernaturalHead.Text = "Supernatural"; StyleLabel(LabelSupernaturalHead); LabelSupernaturalHead.Location = new Point((padding * 4) + (colWidth * 3), LabelAbilityHead.Location.Y + LabelAbilityHead.Height); Control lastAb = null; int lastCol = -1; foreach(Ability ab in Ability.GetAbilities()) { Label abilityLabel = new Label(); abilityLabel.Text = ab.Name; StyleLabelLesser(abilityLabel); if (readOnly) { Label scoreLabel = new Label(); scoreLabel.Text = ShownCharacter.Abilities[ab.Id].ToString(); StyleLabelLesser(scoreLabel); int col = (int)ab.Id / 3; if (col > 3) col = 3; if (lastCol != col || lastAb == null) { abilityLabel.Location = new Point((padding * (col + 1)) + (colWidth * col), LabelSupernaturalHead.Location.Y + LabelAbilityHead.Height); scoreLabel.Location = new Point((padding * (col + 1)) + (colWidth * (col + 1)) - scoreLabel.Width, LabelSupernaturalHead.Location.Y + LabelAbilityHead.Height); lastAb = abilityLabel; } else { abilityLabel.Location = new Point((padding * (col + 1)) + (colWidth * col), lastAb.Location.Y + scoreLabel.Height); scoreLabel.Location = new Point((padding * (col + 1)) + (colWidth * (col + 1)) - scoreLabel.Width, lastAb.Location.Y + scoreLabel.Height); lastAb = abilityLabel; } lastCol = col; Controls.Add(abilityLabel); Controls.Add(scoreLabel); } else { StatBox scoreLabel = new StatBox(ab.Id); scoreLabel.Value = ShownCharacter.Abilities[ab.Id]; scoreLabel.ValueChanged += scoreLabel_ValueChanged; int col = (int)ab.Id / 3; if (col > 3) col = 3; if (lastCol != col || lastAb == null) { abilityLabel.Location = new Point((padding * (col + 1)) + (colWidth * col), LabelSupernaturalHead.Location.Y + LabelAbilityHead.Height); scoreLabel.Location = new Point((padding * (col + 1)) + (colWidth * (col + 1)) - scoreLabel.Width, LabelSupernaturalHead.Location.Y + LabelAbilityHead.Height); lastAb = abilityLabel; } else { abilityLabel.Location = new Point((padding * (col + 1)) + (colWidth * col), lastAb.Location.Y + scoreLabel.Height); scoreLabel.Location = new Point((padding * (col + 1)) + (colWidth * (col + 1)) - scoreLabel.Width, lastAb.Location.Y + scoreLabel.Height); lastAb = abilityLabel; } lastCol = col; Controls.Add(abilityLabel); Controls.Add(scoreLabel); } } Dictionary<uint, int> combatSkills = new Dictionary<uint, int>(); Dictionary<uint, int> artisanSkills = new Dictionary<uint, int>(); Dictionary<uint, int> scholarshipSkills = new Dictionary<uint, int>(); Dictionary<uint, int> socialSkills = new Dictionary<uint, int>(); Dictionary<uint, int> survivalSkills = new Dictionary<uint, int>(); Dictionary<uint, int> supernaturalSkills = new Dictionary<uint, int>(); foreach(KeyValuePair<uint, int> skillPair in ShownCharacter.Skills) { switch(Skill.GetSkill(skillPair.Key).Category) { case SkillCategory.Artisan: artisanSkills.Add(skillPair.Key, skillPair.Value); break; case SkillCategory.Combat: combatSkills.Add(skillPair.Key, skillPair.Value); break; case SkillCategory.Scholarship: scholarshipSkills.Add(skillPair.Key, skillPair.Value); break; case SkillCategory.Social: socialSkills.Add(skillPair.Key, skillPair.Value); break; case SkillCategory.Supernatural: supernaturalSkills.Add(skillPair.Key, skillPair.Value); break; case SkillCategory.Survival: survivalSkills.Add(skillPair.Key, skillPair.Value); break; } } int currentPosY = lastAb.Location.Y + lastAb.Height; if(artisanSkills.Count > 0) { int nCount = 0; LabelArtisanSkillHead.Text = "Artisan Skills"; StyleLabel(LabelArtisanSkillHead); LabelArtisanSkillHead.Location = new Point(Math.Max(((this.ClientRectangle.Width - LabelArtisanSkillHead.Width) / 2), 0), currentPosY + (padding * 3)); this.Controls.Add(LabelArtisanSkillHead); foreach(KeyValuePair<uint, int> skillPair in artisanSkills) { Skill nSk = Skill.GetSkill(skillPair.Key); Label addingSkill = new Label(); addingSkill.Text = nSk.Name; StyleLabelLesser(addingSkill); int col = nCount % 4; int row = nCount / 4; addingSkill.Location = new Point((padding * (col + 1)) + (colWidth * col), LabelArtisanSkillHead.Location.Y + LabelArtisanSkillHead.Height + (lastAb.Height * row)); if(readOnly) { Label addingSkillScore = new Label(); addingSkillScore.Text = skillPair.Value.ToString(); StyleLabelLesser(addingSkillScore); addingSkillScore.Location = new Point((padding * (col + 1)) + (colWidth * (col + 1)) - addingSkillScore.Width, LabelArtisanSkillHead.Location.Y + LabelArtisanSkillHead.Height + (lastAb.Height * row)); currentPosY = addingSkill.Location.Y + addingSkill.Height; this.Controls.Add(addingSkillScore); } else { SkillBox addingSkillScore = new SkillBox(nSk.Id); addingSkillScore.Value = skillPair.Value; addingSkillScore.Location = new Point((padding * (col + 1)) + (colWidth * (col + 1)) - addingSkillScore.Width, LabelArtisanSkillHead.Location.Y + LabelArtisanSkillHead.Height + (lastAb.Height * row)); currentPosY = addingSkillScore.Location.Y + addingSkillScore.Height; addingSkillScore.ValueChanged += addingSkillScore_ValueChanged; lastAb = addingSkillScore; this.Controls.Add(addingSkillScore); } currentPosY = addingSkill.Location.Y + addingSkill.Height; this.Controls.Add(addingSkill); nCount++; } } if(combatSkills.Count > 0) { int nCount = 0; LabelCombatSkillHead.Text = "Combat Skills"; StyleLabel(LabelCombatSkillHead); LabelCombatSkillHead.Location = new Point(Math.Max(((this.ClientRectangle.Width - LabelCombatSkillHead.Width) / 2), 0), currentPosY + (padding * 3)); this.Controls.Add(LabelCombatSkillHead); foreach (KeyValuePair<uint, int> skillPair in combatSkills) { Skill nSk = Skill.GetSkill(skillPair.Key); Label addingSkill = new Label(); addingSkill.Text = nSk.Name; StyleLabelLesser(addingSkill); int col = nCount % 4; int row = nCount / 4; addingSkill.Location = new Point((padding * (col + 1)) + (colWidth * col), LabelCombatSkillHead.Location.Y + LabelCombatSkillHead.Height + (lastAb.Height * row)); if (readOnly) { Label addingSkillScore = new Label(); addingSkillScore.Text = skillPair.Value.ToString(); StyleLabelLesser(addingSkillScore); addingSkillScore.Location = new Point((padding * (col + 1)) + (colWidth * (col + 1)) - addingSkillScore.Width, LabelCombatSkillHead.Location.Y + LabelCombatSkillHead.Height + (lastAb.Height * row)); currentPosY = addingSkill.Location.Y + addingSkill.Height; this.Controls.Add(addingSkillScore); } else { SkillBox addingSkillScore = new SkillBox(nSk.Id); addingSkillScore.Value = skillPair.Value; addingSkillScore.Location = new Point((padding * (col + 1)) + (colWidth * (col + 1)) - addingSkillScore.Width, LabelCombatSkillHead.Location.Y + LabelCombatSkillHead.Height + (lastAb.Height * row)); currentPosY = addingSkillScore.Location.Y + addingSkillScore.Height; addingSkillScore.ValueChanged += addingSkillScore_ValueChanged; lastAb = addingSkillScore; this.Controls.Add(addingSkillScore); } currentPosY = addingSkill.Location.Y + addingSkill.Height; this.Controls.Add(addingSkill); nCount++; } } if (scholarshipSkills.Count > 0) { int nCount = 0; LabelScholarshipSkillHead.Text = "Scholarship Skills"; StyleLabel(LabelScholarshipSkillHead); LabelScholarshipSkillHead.Location = new Point(Math.Max(((this.ClientRectangle.Width - LabelScholarshipSkillHead.Width) / 2), 0), currentPosY + (padding * 3)); this.Controls.Add(LabelScholarshipSkillHead); foreach (KeyValuePair<uint, int> skillPair in scholarshipSkills) { Skill nSk = Skill.GetSkill(skillPair.Key); Label addingSkill = new Label(); addingSkill.Text = nSk.Name; StyleLabelLesser(addingSkill); int col = nCount % 4; int row = nCount / 4; addingSkill.Location = new Point((padding * (col + 1)) + (colWidth * col), LabelScholarshipSkillHead.Location.Y + LabelScholarshipSkillHead.Height + (lastAb.Height * row)); if (readOnly) { Label addingSkillScore = new Label(); addingSkillScore.Text = skillPair.Value.ToString(); StyleLabelLesser(addingSkillScore); addingSkillScore.Location = new Point((padding * (col + 1)) + (colWidth * (col + 1)) - addingSkillScore.Width, LabelScholarshipSkillHead.Location.Y + LabelScholarshipSkillHead.Height + (lastAb.Height * row)); currentPosY = addingSkill.Location.Y + addingSkill.Height; this.Controls.Add(addingSkillScore); } else { SkillBox addingSkillScore = new SkillBox(nSk.Id); addingSkillScore.Value = skillPair.Value; addingSkillScore.Location = new Point((padding * (col + 1)) + (colWidth * (col + 1)) - addingSkillScore.Width, LabelScholarshipSkillHead.Location.Y + LabelScholarshipSkillHead.Height + (lastAb.Height * row)); currentPosY = addingSkillScore.Location.Y + addingSkillScore.Height; addingSkillScore.ValueChanged += addingSkillScore_ValueChanged; lastAb = addingSkillScore; this.Controls.Add(addingSkillScore); } currentPosY = addingSkill.Location.Y + addingSkill.Height; this.Controls.Add(addingSkill); nCount++; } } if (socialSkills.Count > 0) { int nCount = 0; LabelSocialSkillHead.Text = "Social Skills"; StyleLabel(LabelSocialSkillHead); LabelSocialSkillHead.Location = new Point(Math.Max(((this.ClientRectangle.Width - LabelSocialSkillHead.Width) / 2), 0), currentPosY + (padding * 3)); this.Controls.Add(LabelSocialSkillHead); foreach (KeyValuePair<uint, int> skillPair in socialSkills) { Skill nSk = Skill.GetSkill(skillPair.Key); Label addingSkill = new Label(); addingSkill.Text = nSk.Name; StyleLabelLesser(addingSkill); int col = nCount % 4; int row = nCount / 4; addingSkill.Location = new Point((padding * (col + 1)) + (colWidth * col), LabelSocialSkillHead.Location.Y + LabelSocialSkillHead.Height + (lastAb.Height * row)); if (readOnly) { Label addingSkillScore = new Label(); addingSkillScore.Text = skillPair.Value.ToString(); StyleLabelLesser(addingSkillScore); addingSkillScore.Location = new Point((padding * (col + 1)) + (colWidth * (col + 1)) - addingSkillScore.Width, LabelSocialSkillHead.Location.Y + LabelSocialSkillHead.Height + (lastAb.Height * row)); currentPosY = addingSkill.Location.Y + addingSkill.Height; this.Controls.Add(addingSkillScore); } else { SkillBox addingSkillScore = new SkillBox(nSk.Id); addingSkillScore.Value = skillPair.Value; addingSkillScore.Location = new Point((padding * (col + 1)) + (colWidth * (col + 1)) - addingSkillScore.Width, LabelSocialSkillHead.Location.Y + LabelSocialSkillHead.Height + (lastAb.Height * row)); currentPosY = addingSkillScore.Location.Y + addingSkillScore.Height; addingSkillScore.ValueChanged += addingSkillScore_ValueChanged; lastAb = addingSkillScore; this.Controls.Add(addingSkillScore); } currentPosY = addingSkill.Location.Y + addingSkill.Height; this.Controls.Add(addingSkill); nCount++; } } if (supernaturalSkills.Count > 0) { int nCount = 0; LabelSupernaturalSkillHead.Text = "Supernatural Skills"; StyleLabel(LabelSupernaturalSkillHead); LabelSupernaturalSkillHead.Location = new Point(Math.Max(((this.ClientRectangle.Width - LabelSupernaturalSkillHead.Width) / 2), 0), currentPosY + (padding * 3)); this.Controls.Add(LabelSupernaturalSkillHead); foreach (KeyValuePair<uint, int> skillPair in supernaturalSkills) { Skill nSk = Skill.GetSkill(skillPair.Key); Label addingSkill = new Label(); addingSkill.Text = nSk.Name; StyleLabelLesser(addingSkill); int col = nCount % 4; int row = nCount / 4; addingSkill.Location = new Point((padding * (col + 1)) + (colWidth * col), LabelSupernaturalSkillHead.Location.Y + LabelSupernaturalSkillHead.Height + (lastAb.Height * row)); if (readOnly) { Label addingSkillScore = new Label(); addingSkillScore.Text = skillPair.Value.ToString(); StyleLabelLesser(addingSkillScore); addingSkillScore.Location = new Point((padding * (col + 1)) + (colWidth * (col + 1)) - addingSkillScore.Width, LabelSupernaturalSkillHead.Location.Y + LabelSupernaturalSkillHead.Height + (lastAb.Height * row)); currentPosY = addingSkill.Location.Y + addingSkill.Height; this.Controls.Add(addingSkillScore); } else { SkillBox addingSkillScore = new SkillBox(nSk.Id); addingSkillScore.Value = skillPair.Value; addingSkillScore.Location = new Point((padding * (col + 1)) + (colWidth * (col + 1)) - addingSkillScore.Width, LabelSupernaturalSkillHead.Location.Y + LabelSupernaturalSkillHead.Height + (lastAb.Height * row)); currentPosY = addingSkillScore.Location.Y + addingSkillScore.Height; addingSkillScore.ValueChanged += addingSkillScore_ValueChanged; lastAb = addingSkillScore; this.Controls.Add(addingSkillScore); } currentPosY = addingSkill.Location.Y + addingSkill.Height; this.Controls.Add(addingSkill); nCount++; } } if (survivalSkills.Count > 0) { int nCount = 0; LabelSurvivalSkillHead.Text = "Survival Skills"; StyleLabel(LabelSurvivalSkillHead); LabelSurvivalSkillHead.Location = new Point(Math.Max(((this.ClientRectangle.Width - LabelSurvivalSkillHead.Width) / 2), 0), currentPosY + (padding * 3)); this.Controls.Add(LabelSurvivalSkillHead); foreach (KeyValuePair<uint, int> skillPair in survivalSkills) { Skill nSk = Skill.GetSkill(skillPair.Key); Label addingSkill = new Label(); addingSkill.Text = nSk.Name; StyleLabelLesser(addingSkill); int col = nCount % 4; int row = nCount / 4; addingSkill.Location = new Point((padding * (col + 1)) + (colWidth * col), LabelSurvivalSkillHead.Location.Y + LabelSurvivalSkillHead.Height + (lastAb.Height * row)); if (readOnly) { Label addingSkillScore = new Label(); addingSkillScore.Text = skillPair.Value.ToString(); StyleLabelLesser(addingSkillScore); addingSkillScore.Location = new Point((padding * (col + 1)) + (colWidth * (col + 1)) - addingSkillScore.Width, LabelSurvivalSkillHead.Location.Y + LabelSurvivalSkillHead.Height + (lastAb.Height * row)); currentPosY = addingSkill.Location.Y + addingSkill.Height; this.Controls.Add(addingSkillScore); } else { SkillBox addingSkillScore = new SkillBox(nSk.Id); addingSkillScore.Value = skillPair.Value; addingSkillScore.Location = new Point((padding * (col + 1)) + (colWidth * (col + 1)) - addingSkillScore.Width, LabelSurvivalSkillHead.Location.Y + LabelSurvivalSkillHead.Height + (addingSkillScore.Height * row)); currentPosY = addingSkillScore.Location.Y + addingSkillScore.Height; addingSkillScore.ValueChanged += addingSkillScore_ValueChanged; lastAb = addingSkillScore; this.Controls.Add(addingSkillScore); } currentPosY = addingSkill.Location.Y + addingSkill.Height; this.Controls.Add(addingSkill); nCount++; } } if(!readOnly) { ComboBox addSkill = new ComboBox(); addSkill.ForeColor = Color.White; addSkill.BackColor = Color.Black; addSkill.Height = addSkill.PreferredHeight; addSkill.Width = 300; foreach(Skill sk in Skill.GetSkills()) { if(!ShownCharacter.Skills.Keys.Contains(sk.Id)) { addSkill.Items.Add(sk.Name); } } addSkill.AutoCompleteMode = AutoCompleteMode.Suggest; addSkill.AutoCompleteSource = AutoCompleteSource.CustomSource; addSkill.AutoCompleteCustomSource = new AutoCompleteStringCollection(); addSkill.Text = "<Add a Skill>"; addSkill.SelectedIndexChanged += addSkill_SelectedIndexChanged; addSkill.Location = new Point(padding, currentPosY + (padding * 2)); currentPosY = addSkill.Location.Y + addSkill.Height; this.Controls.Add(addSkill); } Label Virt = new Label(); Virtue chVirt = Virtue.GetVirtue(ShownCharacter.CharacterVirtue); if (chVirt != null) { Virt.Text = "Virtue: " + chVirt.Name; } else { Virt.Text = "Virtue: not selected"; } StyleLabel(Virt); Virt.Location = new Point(padding, currentPosY + padding); this.Controls.Add(Virt); Label Vic = new Label(); Vice chVic = Vice.GetVice(ShownCharacter.CharacterVice); if (chVic != null) { Vic.Text = "Vice: " + chVic.Name; } else { Vic.Text = "Vice: not selected"; } StyleLabel(Vic); Vic.Location = new Point(this.ClientRectangle.Width / 2 + padding, currentPosY + padding); this.Controls.Add(Vic); currentPosY = Vic.Location.Y + Vic.Height; Label auth = new Label(); Authority chAuth = Authority.GetAuthority(ShownCharacter.MoralsAuthority); if (chAuth != null) { auth.Text = "Authority: " + chAuth.Name; } else { auth.Text = "Authority: not selected"; } StyleLabel(auth); auth.Location = new Point(padding, currentPosY + padding); this.Controls.Add(auth); Label care = new Label(); Care chCare = Care.GetCare(ShownCharacter.MoralsCare); if (chCare != null) { care.Text = "Care: " + chCare.Name; } else { care.Text = "Care: not selected"; } StyleLabel(care); care.Location = new Point(padding, auth.Location.Y + auth.Height + padding); this.Controls.Add(care); Label fairness = new Label(); Fairness chFairness = Fairness.GetFairness(ShownCharacter.MoralsFairness); if (chFairness != null) { fairness.Text = "Fairness: " + chFairness.Name; } else { fairness.Text = "Fairness: not selected"; } StyleLabel(fairness); fairness.Location = new Point(padding, care.Location.Y + care.Height + padding); this.Controls.Add(fairness); Label loyalty = new Label(); Loyalty chLoyalty = Loyalty.GetLoyalty(ShownCharacter.MoralsLoyalty); if (chLoyalty != null) { loyalty.Text = "Loyalty: " + chLoyalty.Name; } else { loyalty.Text = "Loyalty: not selected"; } StyleLabel(loyalty); loyalty.Location = new Point(padding, fairness.Location.Y + fairness.Height + padding); this.Controls.Add(loyalty); Label trad = new Label(); Tradition chTrad = Tradition.GetTradition(ShownCharacter.MoralsTradition); if (chTrad != null) { trad.Text = "Tradition: " + chTrad.Name; } else { trad.Text = "Tradition: not selected"; } StyleLabel(trad); trad.Location = new Point(padding, loyalty.Location.Y + loyalty.Height + padding); this.Controls.Add(trad); Controls.Add(LabelSexRace); Controls.Add(LabelAbilityHead); Controls.Add(LabelPhysicalHead); Controls.Add(LabelMentalHead); Controls.Add(LabelSocialHead); Controls.Add(LabelSupernaturalHead); }
/// <summary> /// Saves a character object /// </summary> /// <param name="chr">The character to save</param> /// <returns>true on success, false on failure</returns> public bool SaveCharacter(Character chr) { try { string path = GetPathForId(UserName); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } if(!Characters.Contains(chr.CharacterName)) { Characters.Add(chr.CharacterName); } using (FileStream stream = new FileStream(path + chr.CharacterName + ".chr", FileMode.Create)) { DataContractSerializer ser = new DataContractSerializer(typeof(Character)); ser.WriteObject(stream, chr); } _lastAccessed = DateTime.UtcNow; SaveAccount(); return true; } catch { return false; } }
private static void SetCharacterDetails(Character cha) { StringBuilder sb = new StringBuilder(); sb.Append(cha.CharacterName); sb.Append(Environment.NewLine); if(cha.Sex == 0) { sb.Append(StringLibrary.GetString(10)); } else { sb.Append(StringLibrary.GetString(11)); } sb.Append(" "); sb.Append(Race.GetRace(cha.CharacterRace).Name); sb.Append(Environment.NewLine); sb.Append(Environment.NewLine); sb.Append(StringLibrary.GetString(26)); sb.Append(Environment.NewLine); sb.Append(" "); sb.Append(Virtue.GetVirtue(cha.CharacterVirtue).Name); sb.Append(Environment.NewLine); sb.Append(" "); sb.Append(Vice.GetVice(cha.CharacterVice).Name); sb.Append(Environment.NewLine); sb.Append(Environment.NewLine); sb.Append(StringLibrary.GetString(27)); sb.Append(Environment.NewLine); sb.Append(" "); sb.Append(Authority.GetAuthority(cha.MoralsAuthority).Name); sb.Append(Environment.NewLine); sb.Append(" "); sb.Append(Care.GetCare(cha.MoralsCare).Name); sb.Append(Environment.NewLine); sb.Append(" "); sb.Append(Fairness.GetFairness(cha.MoralsFairness).Name); sb.Append(Environment.NewLine); sb.Append(" "); sb.Append(Loyalty.GetLoyalty(cha.MoralsLoyalty).Name); sb.Append(Environment.NewLine); sb.Append(" "); sb.Append(Tradition.GetTradition(cha.MoralsTradition).Name); sb.Append(Environment.NewLine); sb.Append(Environment.NewLine); sb.Append(StringLibrary.GetString(28)); sb.Append(Environment.NewLine); sb.Append(" "); sb.Append(StringLibrary.GetString(31) + ": "); sb.Append(Profession.GetProfession(cha.CharacterProfession).Name); sb.Append(Environment.NewLine); sb.Append(" "); sb.Append(StringLibrary.GetString(33) + ": "); sb.Append(Skill.GetSkill(cha.CharacterHobby).Name); sb.Append(Environment.NewLine); sb.Append(" "); sb.Append(StringLibrary.GetString(32) + ": "); sb.Append(Ability.GetAbility(cha.CharacterTalent).Name); sb.Append(Environment.NewLine); sb.Append(Environment.NewLine); sb.Append(StringLibrary.GetString(29)); foreach(KeyValuePair<uint, int> keyval in cha.Abilities) { sb.Append(Environment.NewLine); sb.Append(" "); sb.Append(Ability.GetAbility(keyval.Key).Name + ": " + keyval.Value.ToString()); } sb.Append(Environment.NewLine); sb.Append(Environment.NewLine); sb.Append(StringLibrary.GetString(30)); foreach (KeyValuePair<uint, int> keyval in cha.Skills) { sb.Append(Environment.NewLine); sb.Append(" "); sb.Append(Skill.GetSkill(keyval.Key).Name + ": " + keyval.Value.ToString()); } _descriptionBox.Text = sb.ToString(); }
private static void ShowCharacterPreview() { if(_race == -1 || _abilityProfession == -1 || _abilityHobby == -1 || _abilityTalent == -1 || _abilityAspiration == -1) { return; } Character ch = new Character(); ch.Abilities = new Dictionary<uint, int>(); ch.Skills = new Dictionary<uint, int>(); ch.CharacterName = _name; ch.MoralsAuthority = (uint)_moralsAuthority; ch.MoralsCare = (uint)_moralsCare; ch.MoralsFairness = (uint)_moralsFairness; ch.MoralsLoyalty = (uint)_moralsLoyalty; ch.MoralsTradition = (uint)_moralsTradition; ch.CharacterHobby = (uint)_abilityHobby; ch.CharacterRace = (uint)_race; ch.CharacterProfession = (uint)_abilityProfession; ch.Sex = _sex; ch.CharacterTalent = (uint)_abilityTalent; ch.CharacterVice = (uint)_traitVice; ch.CharacterVirtue = (uint)_traitVirtue; ch.HairColor = (uint)_displayCharacter.HairColor; ch.HairStyle = (uint)_displayCharacter.Hair; ch.SkinColor = (uint)_displayCharacter.SkinColor; Race r = Race.GetRace(ch.CharacterRace); ch.Abilities.Add(0, r.Strength); ch.Abilities.Add(1, r.Agility); ch.Abilities.Add(2, r.Endurance); ch.Abilities.Add(3, r.Perception); ch.Abilities.Add(4, r.Quickness); ch.Abilities.Add(5, r.Memory); ch.Abilities.Add(6, r.Persuasion); ch.Abilities.Add(7, r.Glibness); ch.Abilities.Add(8, r.Appearance); ch.Abilities.Add(9, r.Force); ch.Abilities.Add(10, r.Control); ch.Abilities.Add(11, r.Discipline); Profession prof = Profession.GetProfession(ch.CharacterProfession); ch.Abilities[prof.PrimaryAbility] = ch.Abilities[prof.PrimaryAbility] + 1; ch.Skills.Add(prof.SkillOne, 3); ch.Skills.Add(prof.SkillTwo, 3); ch.Skills.Add(prof.SkillThree, 3); ch.Abilities[ch.CharacterTalent]++; if(ch.Skills.Keys.Contains(ch.CharacterHobby)) { ch.Skills[ch.CharacterHobby]++; } else { ch.Skills.Add(ch.CharacterHobby, 2); } Aspiration asp = Aspiration.GetAspiration((uint)_abilityAspiration); foreach (uint ab in asp.Abilities) { ch.Abilities[ab] += 1; } int skills = 3; foreach (uint sk in asp.Skills) { if (!ch.Skills.ContainsKey(sk)) { ch.Skills.Add(sk, 2); skills--; } if (skills == 0) break; } if(chPanel != null) { chPanel.Close(); chPanel.Dispose(); } chPanel = new CharacterPanel(ch, true); chPanel.Show(); }
public static DisplayCharacter GetDisplayCharacter(Character ch) { if (ch.CachedDisplay != null && ch.CachedDisplay.x == ch.LocationX && ch.CachedDisplay.y == ch.LocationY && ch.CachedDisplay.z == ch.LocationZ && ch.CachedDisplay.Facing == ch.LocationFacing) { if(ch.Equipment != null && ch.Equipment.ContainsKey((int)InventorySlot.Chest) && ch.Equipment[(int)InventorySlot.Chest].Appearance == ch.CachedDisplay.Clothes && ch.Equipment[(int)InventorySlot.Chest].PrimaryColor == ch.CachedDisplay.ClothColorA && ch.Equipment[(int)InventorySlot.Chest].SecondaryColor == ch.CachedDisplay.ClothColorB) { return ch.CachedDisplay; } else if((ch.Equipment == null || ch.Equipment.ContainsKey((int)InventorySlot.Chest)) && ch.CachedDisplay.Clothes == 0) { return ch.CachedDisplay; } } return new DisplayCharacter(ch); }
private DisplayCharacter(Character ch) { if(ch.CachedDisplay == null) { CharacterId = currentId++; } else { CharacterId = ch.CachedDisplay.CharacterId; } Height = Race.GetRace(ch.CharacterRace).Height; x = ch.LocationX; y = ch.LocationY; z = ch.LocationZ; Facing = ch.LocationFacing; CharacterRace = ch.CharacterRace; SkinColor = (int)ch.SkinColor; HairColor = (int)ch.HairColor; Sex = ch.Sex; Hair = (int)ch.HairStyle; if(ch.Equipment != null && ch.Equipment.ContainsKey((int)InventorySlot.Chest)) { InventoryItem clothes = ch.Equipment[(int)InventorySlot.Chest]; Clothes = clothes.Appearance; ClothColorA = clothes.PrimaryColor; ClothColorB = clothes.SecondaryColor; } ch.CachedDisplay = this; }
public string CreateCharacter(string message) { CharacterCreation nChar = new CharacterCreation(message); Account targetAccount = Account.LoadAccount(nChar.UserId); if(targetAccount == null) { return "Invalid account"; } if (targetAccount.SessionId != nChar.SessionId) { return "Invalid session Id"; } Character chr; try { chr = new Character() { AccountName = targetAccount.UserName, CharacterHobby = (uint)nChar.Hobby, CharacterName = nChar.Name, CharacterProfession = (uint)nChar.Profession, CharacterRace = (uint)nChar.Race, CharacterTalent = (uint)nChar.Talent, CharacterVice = (uint)nChar.Vice, CharacterVirtue = (uint)nChar.Virtue, MoralsAuthority = (uint)nChar.Authority, MoralsCare = (uint)nChar.Authority, MoralsFairness = (uint)nChar.Fairness, MoralsLoyalty = (uint)nChar.Loyalty, MoralsTradition = (uint)nChar.Tradition, Sex = nChar.Sex, SkinColor = (uint)nChar.SkinColor, HairColor = (uint)nChar.HairColor, HairStyle = (uint)nChar.HairStyle, }; } catch { return "Invalid character data; likely a negative number passed to an unsigned field."; } if (!chr.ValidateCharacter()) { return "Character violates rules of character creation."; } if(targetAccount.LoadCharacter(chr.CharacterName) != null) { return "A character with that name already exists"; } if (!targetAccount.NewCharacter(chr)) { return "Unable to save character"; } try { Aspiration asp = Aspiration.GetAspiration((uint)nChar.Aspiration); foreach (uint ab in asp.Abilities) { chr.Abilities[ab] += 1; } int skills = 3; foreach (uint sk in asp.Skills) { if (!chr.Skills.ContainsKey(sk)) { chr.Skills.Add(sk, 2); skills--; } if (skills == 0) break; } } catch { return "Failed to parse aspiration."; } if (!targetAccount.SaveCharacter(chr)) { return "Could not save character."; } return "Success: " + chr.CharacterName; }
public InventoryForm(Character ch) { ChInv = ch; if(ch.Equipment.ContainsKey((int)InventorySlot.Chest)) { ChestPanel.BackgroundImage = GetInventoryIconByTag(ch.Equipment[(int)InventorySlot.Chest].Icon); } else { ChestPanel.BackgroundImage = GetInventoryIconByTag("EmptyChest"); } if(ch.Equipment.ContainsKey((int)InventorySlot.Neck)) { NeckSlotPanel.BackgroundImage = GetInventoryIconByTag(ch.Equipment[(int)InventorySlot.Neck].Icon); } else { NeckSlotPanel.BackgroundImage = GetInventoryIconByTag("EmptyNeck"); } if (ch.Equipment.ContainsKey((int)InventorySlot.Belt)) { BeltPanel.BackgroundImage = GetInventoryIconByTag(ch.Equipment[(int)InventorySlot.Belt].Icon); } else { BeltPanel.BackgroundImage = GetInventoryIconByTag("EmptyBelt"); } if (ch.Equipment.ContainsKey((int)InventorySlot.LeftRing)) { LeftRingPanel.BackgroundImage = GetInventoryIconByTag(ch.Equipment[(int)InventorySlot.LeftRing].Icon); } else { LeftRingPanel.BackgroundImage = GetInventoryIconByTag("EmptyRing"); } if (ch.Equipment.ContainsKey((int)InventorySlot.RightRing)) { RightRingPanel.BackgroundImage = GetInventoryIconByTag(ch.Equipment[(int)InventorySlot.RightRing].Icon); } else { RightRingPanel.BackgroundImage = GetInventoryIconByTag("EmptyRing"); } if (ch.Equipment.ContainsKey((int)InventorySlot.LeftHand)) { LeftHandPanel.BackgroundImage = GetInventoryIconByTag(ch.Equipment[(int)InventorySlot.LeftHand].Icon); } else { LeftHandPanel.BackgroundImage = GetInventoryIconByTag("EmptyHand"); } if (ch.Equipment.ContainsKey((int)InventorySlot.RightHand)) { RightHandPanel.BackgroundImage = GetInventoryIconByTag(ch.Equipment[(int)InventorySlot.RightHand].Icon); } else { RightHandPanel.BackgroundImage = GetInventoryIconByTag("EmptyHand"); } NeckSlotPanel.Size = IconSize; LeftRingPanel.Size = IconSize; RightRingPanel.Size = IconSize; LeftHandPanel.Size = IconSize; RightHandPanel.Size = IconSize; ChestPanel.Size = IconSize; BeltPanel.Size = IconSize; LeftHandPanel.Location = new Point(InventoryPadding, InventoryPadding * 2 + IconSize.Height); LeftRingPanel.Location = new Point(InventoryPadding, InventoryPadding * 3 + IconSize.Height * 2); NeckSlotPanel.Location = new Point(InventoryPadding * 2 + IconSize.Width, InventoryPadding); ChestPanel.Location = new Point(InventoryPadding * 2 + IconSize.Width, InventoryPadding * 2 + IconSize.Height); BeltPanel.Location = new Point(InventoryPadding * 2 + IconSize.Width, InventoryPadding * 3 + IconSize.Height * 2); RightHandPanel.Location = new Point(InventoryPadding * 3 + IconSize.Width * 2, InventoryPadding * 2 + IconSize.Height); RightRingPanel.Location = new Point(InventoryPadding * 3 + IconSize.Width * 2, InventoryPadding * 3 + IconSize.Height * 2); ImageList imgs = new ImageList(); imgs.ImageSize = IconSize; imgs.ColorDepth = ColorDepth.Depth32Bit; unequippedItems.Location = new Point(InventoryPadding * 4 + IconSize.Width * 3, InventoryPadding); unequippedItems.Width = 300; unequippedItems.Height = InventoryPadding * 2 + IconSize.Height * 3; StyleListView(unequippedItems); unequippedItems.DoubleClick += unequippedItems_DoubleClick; int imageIndex = 0; foreach(InventoryItem item in ch.Inventory) { ListViewItem toAdd = new ListViewItem(new string[] { "", item.Name }); toAdd.Tag = item.Identifier; toAdd.ImageIndex = imageIndex; StyleListViewItem(toAdd); imgs.Images.Add(GetInventoryIconByTag(item.Icon)); imageIndex++; unequippedItems.Items.Add(toAdd); } unequippedItems.SmallImageList = imgs; this.BackColor = Color.Black; this.Size = new Size(InventoryPadding * 5 + IconSize.Width * 3 + 300 + this.Size.Width - this.ClientRectangle.Size.Width, InventoryPadding * 4 + IconSize.Height * 3 + this.Size.Height - this.ClientRectangle.Size.Height); Controls.Add(NeckSlotPanel); Controls.Add(LeftRingPanel); Controls.Add(RightRingPanel); Controls.Add(LeftHandPanel); Controls.Add(RightHandPanel); Controls.Add(ChestPanel); Controls.Add(BeltPanel); Controls.Add(unequippedItems); this.FormClosed += InventoryForm_OnClosed; this.KeyDown += InventoryForm_KeyPress; }
public bool MoveCharacter(Character ch, int X, int Y, int Z, Direction Facing) { Tile targetTile = GetTileExact(X, Y, Z); if(targetTile != null) { int characterHeight = Race.GetRace(ch.CharacterRace).Height; int testedHeight = characterHeight; while(testedHeight > 0) { if(GetTileOverlap(X, Y, Z + testedHeight) != null) { return false; } testedHeight--; } ch.LocationX = X; ch.LocationY = Y; ch.LocationZ = Z; ch.LocationFacing = Facing; DisplayCharacter dch = DisplayCharacter.GetDisplayCharacter(ch); foreach(Character observer in PresentCharacters) { if(!MapDeltas.ContainsKey(observer)) { MapDeltas.Add(observer, new MapDelta()); } if (MapDeltas[observer].ChangedCharacters.ContainsKey(dch.CharacterId)) { MapDeltas[observer].ChangedCharacters[dch.CharacterId] = dch; } else { MapDeltas[observer].ChangedCharacters.Add(dch.CharacterId, dch); } if (MapDeltas[observer].RemovedCharacters.ContainsKey(dch.CharacterId)) { MapDeltas[observer].RemovedCharacters.Remove(dch.CharacterId); } } return true; } return false; }
public bool RemoveCharacter(Character ch) { DisplayCharacter dch = DisplayCharacter.GetDisplayCharacter(ch); foreach (Character observer in PresentCharacters) { if (!MapDeltas.ContainsKey(observer)) { MapDeltas.Add(observer, new MapDelta()); } if (MapDeltas[observer].RemovedCharacters.ContainsKey(dch.CharacterId)) { MapDeltas[observer].RemovedCharacters[dch.CharacterId] = dch; } else { MapDeltas[observer].RemovedCharacters.Add(dch.CharacterId, dch); } if(MapDeltas[observer].AddedCharacters.ContainsKey(dch.CharacterId)) { MapDeltas[observer].AddedCharacters.Remove(dch.CharacterId); } if(MapDeltas[observer].ChangedCharacters.ContainsKey(dch.CharacterId)) { MapDeltas[observer].ChangedCharacters.Remove(dch.CharacterId); } } if (PresentCharacters.Contains(ch)) { PresentCharacters.Remove(ch); } return true; }
static void _characterList_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) { if(e.IsSelected) { string ret = Mundasia.Communication.ServiceConsumer.CharacterDetails(e.Item.SubItems[0].Text); Character ch = new Character(ret); SetCharacterDetails(ch); } }
/// <summary> /// Create a character for this account with the chr character object. /// /// Assumes that the character object has passed validation. /// </summary> /// <param name="chr">The character to add to this account</param> /// <returns>true on success, or false on failure</returns> public bool NewCharacter(Character chr) { chr.AccountName = this.UserName; Characters.Add(chr.CharacterName); LoadedCharacters.Add(chr); return SaveCharacter(chr); }