public World() { NPCs.Clear(); Signs.Clear(); Chests.Clear(); CharacterNames.Clear(); }
public World() { NPCs.Clear(); Signs.Clear(); Chests.Clear(); CharacterNames.Clear(); TileFrameImportant = SettingsTileFrameImportant.ToArray(); // clone for "new" world. Loaded worlds will replace this with file data }
private void DungeonColumns_OnScrollChanged(object sender, ScrollChangedEventArgs e) { var headerSw = DungeonHeaders.GetChild <ScrollViewer>(); var namesSw = CharacterNames.GetChild <ScrollViewer>(); headerSw.ScrollToHorizontalOffset(e.HorizontalOffset); namesSw.ScrollToVerticalOffset(e.VerticalOffset); }
public string GetRandomName(NameList nameList) { if (nameList.Characters is null || nameList.Characters.Count == 0 || nameList.Characters.All(x => x.IsEmpty)) { return(string.Empty); } CharacterNames characterNames = nameList.Characters.Where(x => !x.IsEmpty).GetRandomElement(); bool takeMale = new List <bool> { true, false }.GetRandomElement(); if (characterNames.FullNames.Any(x => !x.IsEmpty)) { return(characterNames.FullNames.SelectMany(x => x.Values).GetRandomElement()); } if (takeMale && characterNames.MaleFullNames.Any(x => !x.IsEmpty)) { return(characterNames.MaleFullNames.SelectMany(x => x.Values).GetRandomElement()); } if (!takeMale && characterNames.FemaleFullNames.Any(x => !x.IsEmpty)) { return(characterNames.FemaleFullNames.SelectMany(x => x.Values).GetRandomElement()); } if (characterNames.SecondNames.Any(x => !x.IsEmpty)) { if (characterNames.FirstNames.Any(x => !x.IsEmpty)) { return (characterNames.FirstNames.SelectMany(x => x.Values).GetRandomElement() + " " + characterNames.SecondNames.SelectMany(x => x.Values).GetRandomElement()); } if (takeMale && characterNames.MaleFirstNames.Any(x => !x.IsEmpty)) { return (characterNames.MaleFirstNames.SelectMany(x => x.Values).GetRandomElement() + " " + characterNames.SecondNames.SelectMany(x => x.Values).GetRandomElement()); } if (!takeMale && characterNames.FemaleFirstNames.Any(x => !x.IsEmpty)) { return (characterNames.FemaleFirstNames.SelectMany(x => x.Values).GetRandomElement() + " " + characterNames.SecondNames.SelectMany(x => x.Values).GetRandomElement()); } } return(string.Empty); }
public NpcName GetNpc(int id) { NpcName npc = CharacterNames.FirstOrDefault(c => c.Id == id); if (npc != null) { return(npc); } return(GetNewNpc(id)); }
public static string AttemptTranslate(ByteArrayStream stream, int depthLeft = 2) { var code = stream.Byte(); if (code >= 0x80) { return(BasicTable.Lookup(code)); } if (code < 0x30) { if (code == 0x01) { return($"{{windowbreak}}"); } if (code == 0x05) { return($"{{05:{stream.Byte().ToString("x2")}}}"); } if (code == 0x1b) { return($"{{swapspeaker:{stream.Byte().ToString("x2")}}}"); } if (code == 0x1d) { return($"{{character:{CharacterNames.GetString(stream.Byte())}}}"); } if (code == 0x1e) { return($"{{item:{ItemNames.GetString(stream.Byte())}}}"); } if (code == 0x1f) { return($"{{location:{LocationNames.GetString(stream.Byte())}}}"); } //if (code == 0x2f) { // return $"{{if:{stream.Byte().ToString("x2")} {stream.Byte().ToString("x2")} {stream.Byte().ToString("x2")}}}"; //} return($"{{{code.ToString("x2")}}}"); } if (depthLeft == 0) { return($"{{{code.ToString("x2")}}}"); } //var text = string.Join("", LookupBytes(code).Select(x => AttemptTranslate(x, depthLeft - 1))); var text = AttemptTranslateLine(LookupBytes(code), depthLeft - 1); return(text); }
public void FixNpcs() { DispatcherHelper.CheckBeginInvokeOnUI( () => { int[] npcids = {17, 18, 19, 20, 22, 54, 38, 107, 108, 124, 160, 178, 207, 208, 209, 227, 228, 229}; foreach (int npcid in npcids) { if (CharacterNames.All(c => c.Id != npcid)) CharacterNames.Add(GetNewNpc(npcid)); } }); }
public void FixNpcs() { TEdit.MvvmLight.Threading.DispatcherHelper.CheckBeginInvokeOnUI( () => { int[] npcids = { 17, 18, 19, 20, 22, 54, 38, 107, 108, 124, 160, 178, 207, 208, 209, 227, 228, 229, 353, 369, 441 }; foreach (int npcid in npcids) { if (CharacterNames.All(c => c.Id != npcid)) { CharacterNames.Add(GetNewNpc(npcid)); } } }); }
public CharacterSelectionViewModel(MainWindowViewModel main) { this.main = main; this.ConfirmCommand = new DelegateCommand(this.PressConfirm); TxtReader charReader = new TxtReader(characterFile); characters = charReader.ReadCharacters(); UpdateCharacter(); foreach (var character in characters) { CharacterNames.Add(character.Name); } }
public static bool Load(string path, string key) { SilkroadPath = GetSetting("SilkroadPath", path); MediaPk2Key = GetSetting("MediaPk2Key", key); if (string.IsNullOrEmpty(SilkroadPath) || string.IsNullOrEmpty(MediaPk2Key)) { if (!string.IsNullOrEmpty(path) && !string.IsNullOrEmpty(key)) { SilkroadPath = GetSetting("SilkroadPath", path, true); MediaPk2Key = GetSetting("MediaPk2Key", key, true); } else { return(false); } } _reader = new Pk2Reader(SilkroadPath + @"\Media.pk2", MediaPk2Key); var isUpdate = GetSetting("GameVersion", 0); var needUpdate = isUpdate == 0 || isUpdate < Version(); GameVerison = GetSetting("GameVersion", Version(), needUpdate); GatewayPort = ushort.Parse(GetSetting("GatewayPort", GatePort(), needUpdate).ToString()); DivisionServers = DivisionInfo().ToList(); if (!needUpdate) { return(true); } LiteDatabase.DropCollection(Skills.Name); LiteDatabase.DropCollection(Items.Name); LoadTextData(); Skills.Insert(LoadSkillsData().GroupBy(x => x.Id).Select(x => x.OrderBy(y => y.Id).First())); Items.Insert(LoadItemsData().GroupBy(x => x.Id).Select(x => x.OrderBy(y => y.Id).First())); Characters.Insert(LoadCharacterData().GroupBy(x => x.Id).Select(x => x.OrderBy(y => y.Id).First())); ItemNames.Clear(); SkillNames.Clear(); CharacterNames.Clear(); RegionNames.Clear(); GC.Collect(); GC.WaitForPendingFinalizers(); return(true); }
public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state) { //gets the book from the passed parameter string url = (string)parameter; var client = new GoTService(); CurrentBook = await client.GetBookByUrlAsync(url); foreach (var povCharacter in CurrentBook.PovCharacters) { Character c = await client.GetCharacterByUrlAsync(povCharacter); //Saves the name field to a collection that is shown on the UI PovCharacterNames.Add(c.Name); //Saves the entire type, needed for navigation _povCharacters.Add(c); } //sets a specific limit, so the app wont get overwhelmed with too much data int limit = 20; int i = 0; foreach (var character in CurrentBook.Characters) { if (i >= limit) { break; } Character c = await client.GetCharacterByUrlAsync(character); if (c.Name != "") { //Saves the name field to a collection that is shown on the UI CharacterNames.Add(c.Name); //Saves the entire type, needed for navigation _characters.Add(c); } i++; } await base.OnNavigatedToAsync(parameter, mode, state); }
string BuildCharacterNamesArray(CharacterNames characterNames) { string content = string.Empty; string characterNamesId = characterNames.Id; if (string.IsNullOrWhiteSpace(characterNamesId)) { characterNamesId = $"names{DateTime.Now.Ticks}"; } content += $"{GetIndentation(2)}{characterNamesId} = {{{Environment.NewLine}"; content += $"{GetIndentation(3)}weight = {characterNames.Weight}{Environment.NewLine}"; string innerContent = string.Empty; innerContent += BuildNameArray(characterNames.FullNames, "full_names", 3); innerContent += BuildNameArray(characterNames.FirstNames, "first_names", 3); innerContent += BuildNameArray(characterNames.RoyalFirstNames, "regnal_first_names", 3); innerContent += BuildNameArray(characterNames.MaleFullNames, "full_names_male", 3); innerContent += BuildNameArray(characterNames.MaleFirstNames, "first_names_male", 3); innerContent += BuildNameArray(characterNames.MaleRoyalFirstNames, "regnal_first_names_male", 3); innerContent += BuildNameArray(characterNames.FemaleFullNames, "full_names_female", 3); innerContent += BuildNameArray(characterNames.FemaleFirstNames, "first_names_female", 3); innerContent += BuildNameArray(characterNames.FemaleRoyalFirstNames, "regnal_first_names_female", 3); innerContent += BuildNameArray(characterNames.SecondNames, "second_names", 3); innerContent += BuildNameArray(characterNames.RoyalSecondNames, "regnal_second_names", 3); if (string.IsNullOrWhiteSpace(innerContent)) { return(string.Empty); } content += innerContent; content += $"{GetIndentation(2)}}}{Environment.NewLine}"; return(content); }
public virtual void OnMakeClone(CharacterNames name) { }
public virtual void OnHalfSkillImageAnimation(CharacterNames fighterName, int pMirror) { }
public virtual void OnWinView(int playernum, CharacterNames fighterName, bool view) { }
/// <summary> /// Returns the character class of the given build url. /// </summary> public virtual string GetCharacterClass() { var classId = GetCharacterClassId(); return(CharacterNames.GetClassNameFromChartype(classId)); }
public virtual void SetPlayerUiImages(int player, CharacterNames name) { }
private static IEnumerable <Character> LoadCharacterData() { return(from fileName in _reader.GetFileText("characterdata.txt").Split('\n') where fileName != string.Empty from data in _reader.GetFileText(fileName.Trim()).Split('\n').Where(line => line != string.Empty).Select(line => line.Split('\t')) select new Character(data, CharacterNames.ContainsKey(data[5]) ? CharacterNames[data[5]] : "")); }
public void Save(string filename, bool resetTime = false) { lock (_fileLock) { if (resetTime) { OnProgressChanged(this, new ProgressChangedEventArgs(0, "Resetting Time...")); ResetTime(); } if (filename == null) { return; } string temp = filename + ".tmp"; using (var fs = new FileStream(temp, FileMode.Create)) { using (var bw = new BinaryWriter(fs)) { bw.Write(World.CompatibleVersion); bw.Write(Title); bw.Write(WorldId); bw.Write((int)LeftWorld); bw.Write((int)RightWorld); bw.Write((int)TopWorld); bw.Write((int)BottomWorld); bw.Write(TilesHigh); bw.Write(TilesWide); bw.Write(SpawnX); bw.Write(SpawnY); bw.Write(GroundLevel); bw.Write(RockLevel); bw.Write(Time); bw.Write(DayTime); bw.Write(MoonPhase); bw.Write(BloodMoon); bw.Write(DungeonX); bw.Write(DungeonY); bw.Write(DownedBoss1); bw.Write(DownedBoss2); bw.Write(DownedBoss3); bw.Write(SavedGoblin); bw.Write(SavedWizard); bw.Write(SavedMech); bw.Write(DownedGoblins); bw.Write(DownedClown); bw.Write(DownedFrost); bw.Write(ShadowOrbSmashed); bw.Write(SpawnMeteor); bw.Write((byte)ShadowOrbCount); bw.Write(AltarCount); bw.Write(HardMode); bw.Write(InvasionDelay); bw.Write(InvasionSize); bw.Write(InvasionType); bw.Write(InvasionX); for (int x = 0; x < TilesWide; ++x) { OnProgressChanged(this, new ProgressChangedEventArgs(x.ProgressPercentage(TilesWide), "Saving Tiles...")); int rle = 0; for (int y = 0; y < TilesHigh; y = y + rle + 1) { var curTile = Tiles[x, y]; bw.Write(curTile.IsActive); if (curTile.IsActive) { bw.Write(curTile.Type); if (TileProperties[curTile.Type].IsFramed) { bw.Write(curTile.U); bw.Write(curTile.V); // TODO: Let Validate handle these //validate chest entry exists if (curTile.Type == 21) { if (GetChestAtTile(x, y) == null) { Chests.Add(new Chest(x, y)); } } //validate sign entry exists else if (curTile.Type == 55 || curTile.Type == 85) { if (GetSignAtTile(x, y) == null) { Signs.Add(new Sign(x, y, string.Empty)); } } } } if ((int)curTile.Wall > 0) { bw.Write(true); bw.Write(curTile.Wall); } else { bw.Write(false); } if ((int)curTile.Liquid > 0) { bw.Write(true); bw.Write(curTile.Liquid); bw.Write(curTile.IsLava); } else { bw.Write(false); } bw.Write(curTile.HasWire); int rleTemp = 1; while (y + rleTemp < TilesHigh && curTile.Equals(Tiles[x, (y + rleTemp)])) { ++rleTemp; } rle = rleTemp - 1; bw.Write((short)rle); } } OnProgressChanged(null, new ProgressChangedEventArgs(100, "Saving Chests...")); for (int i = 0; i < 1000; ++i) { if (i >= Chests.Count) { bw.Write(false); } else { Chest curChest = Chests[i]; bw.Write(true); bw.Write(curChest.X); bw.Write(curChest.Y); for (int j = 0; j < Chest.MaxItems; ++j) { if (curChest.Items.Count > j) { bw.Write((byte)curChest.Items[j].StackSize); if (curChest.Items[j].StackSize > 0) { bw.Write(curChest.Items[j].NetId); // TODO Verify bw.Write(curChest.Items[j].Prefix); } } else { bw.Write((byte)0); } } } } OnProgressChanged(null, new ProgressChangedEventArgs(100, "Saving Signs...")); for (int i = 0; i < 1000; ++i) { if (i >= Signs.Count || string.IsNullOrWhiteSpace(Signs[i].Text)) { bw.Write(false); } else { var curSign = Signs[i]; bw.Write(true); bw.Write(curSign.Text); bw.Write(curSign.X); bw.Write(curSign.Y); } } OnProgressChanged(null, new ProgressChangedEventArgs(100, "Saving NPC Data...")); foreach (NPC curNpc in NPCs) { bw.Write(true); bw.Write(curNpc.Name); bw.Write(curNpc.Position.X); bw.Write(curNpc.Position.Y); bw.Write(curNpc.IsHomeless); bw.Write(curNpc.Home.X); bw.Write(curNpc.Home.Y); } bw.Write(false); OnProgressChanged(null, new ProgressChangedEventArgs(100, "Saving NPC Names...")); bw.Write(CharacterNames.FirstOrDefault(c => c.Id == 17).Name); bw.Write(CharacterNames.FirstOrDefault(c => c.Id == 18).Name); bw.Write(CharacterNames.FirstOrDefault(c => c.Id == 19).Name); bw.Write(CharacterNames.FirstOrDefault(c => c.Id == 20).Name); bw.Write(CharacterNames.FirstOrDefault(c => c.Id == 22).Name); bw.Write(CharacterNames.FirstOrDefault(c => c.Id == 54).Name); bw.Write(CharacterNames.FirstOrDefault(c => c.Id == 38).Name); bw.Write(CharacterNames.FirstOrDefault(c => c.Id == 107).Name); bw.Write(CharacterNames.FirstOrDefault(c => c.Id == 108).Name); bw.Write(CharacterNames.FirstOrDefault(c => c.Id == 124).Name); OnProgressChanged(null, new ProgressChangedEventArgs(100, "Saving Validation Data...")); bw.Write(true); bw.Write(Title); bw.Write(WorldId); bw.Close(); fs.Close(); // make a backup of current file if it exists if (File.Exists(filename)) { string backup = filename + ".TEdit"; File.Copy(filename, backup, true); } // replace actual file with temp save file File.Copy(temp, filename, true); // delete temp save file File.Delete(temp); OnProgressChanged(null, new ProgressChangedEventArgs(0, "World Save Complete.")); } } _lastSave = File.GetLastWriteTimeUtc(filename); } }
private void SetTalkingCharacter(CharacterNames character) { characters.ForEach(a => a.SetTalking(a.CharacterName == character)); }