public override void Randomize(int seed) { _generator = new Random(seed); foreach (TR23ScriptedLevel lvl in Levels) { if (SaveMonitor.IsCancelled) { return; } //SaveMonitor.FireSaveStateBeginning(TRSaveCategory.Custom, string.Format("Randomizing textures in {0}", lvl.Name)); LoadLevelInstance(lvl); string appDir = Directory.GetCurrentDirectory(); string lvlName = lvl.LevelFileBaseName.ToUpper(); //Access texture packs directory for the specified level Directory.SetCurrentDirectory(@"Resources\TexturePacks\" + lvlName.Remove(lvlName.IndexOf('.'))); try { //List the sub directories string[] packDirs = Directory.GetDirectories(Directory.GetCurrentDirectory()); //Repeat // Pick a random sub-directory and enter it //Until no more directories int DepthCount = 0; while (packDirs.Count() > 0 && DepthCount <= 6) { Directory.SetCurrentDirectory(packDirs[_generator.Next(0, packDirs.Count())]); packDirs = Directory.GetDirectories(Directory.GetCurrentDirectory()); DepthCount++; } //Apply each texture to the correct textile index for (int i = 0; i < _levelInstance.NumImages; i++) { string textureFileName = lvlName + i + ".png"; if (File.Exists(textureFileName)) { _levelInstance.Images16[i].Pixels = T16Importer.ImportFrom32PNG(textureFileName); } } SaveLevelInstance(); SaveMonitor.FireSaveStateChanged(1); } finally { //Restore app working directory Directory.SetCurrentDirectory(appDir); } } }
public override void Randomize(int seed) { _generator = new Random(seed); Dictionary <string, List <Location> > Locations = JsonConvert.DeserializeObject <Dictionary <string, List <Location> > >(File.ReadAllText(@"Resources\locations.json")); foreach (TR23ScriptedLevel lvl in Levels) { if (SaveMonitor.IsCancelled) { return; } //SaveMonitor.FireSaveStateBeginning(TRSaveCategory.Custom, string.Format("Randomizing secrets in {0}", lvl.Name)); //Read the level into a level object LoadLevelInstance(lvl); //Apply the modifications RandomizeSecrets(Locations[lvl.LevelFileBaseName.ToUpper()], lvl); //Write back the level file SaveLevelInstance(); SaveMonitor.FireSaveStateChanged(1); } }
public void Initialize() { GameData = new EmbeddedData(); SaveMonitor.Start(); Behaviors = new BehaviorDb(this); QuestPortraits.Add("Eyeguard of Surrender", 20); Player.HandleQuests(GameData); Merchant.HandleMerchant(GameData); AddWorld((int)WorldID.NEXUS_ID, Worlds[0] = new Nexus()); AddWorld((int)WorldID.MARKET, new ClothBazaar()); AddWorld((int)WorldID.TEST_ID, new Test()); AddWorld((int)WorldID.TUT_ID, new Tutorial(true)); AddWorld((int)WorldID.DAILY_QUEST_ID, new DailyQuestRoom()); Monitor = new RealmPortalMonitor(this); Task.Factory.StartNew(() => GameWorld.AutoName(1, true)).ContinueWith(_ => AddWorld(_.Result), TaskScheduler.Default); InterServer = new ISManager(this); Chat = new ChatManager(this); Commands = new CommandManager(this); NPCs npcs = new NPCs(); npcs.Initialize(this); Log.Info($"\t- {NPCs.Database.Count}\tNPC{(NPCs.Database.Count > 1 ? "s" : "")}."); }
private void Awake() { if (activeGC) { Destroy(gameObject); } else { activeGC = this; DontDestroyOnLoad(gameObject); SaveMonitor.LoadGame(); } }
public void Stop() { SaveMonitor.Stop(); Terminating = true; List <Client> saveAccountUnlock = new List <Client>(); foreach (ClientData cData in ClientManager.Values) { saveAccountUnlock.Add(cData.Client); TryDisconnect(cData.Client, DisconnectReason.STOPPING_REALM_MANAGER); } GameData.Dispose(); Logic.Dispose(); }
public override void Randomize(int seed) { _generator = new Random(seed); Dictionary <string, List <Location> > locations = JsonConvert.DeserializeObject <Dictionary <string, List <Location> > >(File.ReadAllText(@"Resources\item_locations.json")); foreach (TR23ScriptedLevel lvl in Levels) { if (SaveMonitor.IsCancelled) { return; } //SaveMonitor.FireSaveStateBeginning(TRSaveCategory.Custom, string.Format("Randomizing items in {0}", lvl.Name)); //Read the level into a level object LoadLevelInstance(lvl); FindAndCleanUnarmedPistolLocation(lvl); if (lvl.Is(LevelNames.HOME)) { InjectHSHWeaponTextures(); CleanHSHCloset(); } //Apply the modifications RepositionItems(locations[lvl.LevelFileBaseName.ToUpper()], lvl.LevelFileBaseName.ToUpper()); //#44 - Randomize OR pistol type if (lvl.RemovesWeapons) { RandomizeORPistol(); } //#47 - Randomize the HSH weapon closet if (lvl.Is(LevelNames.HOME)) { PopulateHSHCloset(); } //Write back the level file SaveLevelInstance(); SaveMonitor.FireSaveStateChanged(1); } }
public void SetUp() { QTEController qtec = FindObjectOfType <QTEController>(); Score.text = qtec.score.ToString(); CadeauScore.text = "x " + qtec.giftvalidated.ToString() + " = " + getGiftScore(); finalScore.text = "Total = " + qtec.computeTotalScore(); if (qtec.computeTotalScore() > GameController.activeGC.maxScore) { GameController.activeGC.maxScore = qtec.computeTotalScore(); record.enabled = true; } try { SaveMonitor.Save(); } catch (Exception e) { Debug.LogError("Could not save : " + e.StackTrace); } }
public override void Randomize(int seed) { _generator = new Random(seed); foreach (TR23ScriptedLevel lvl in Levels) { if (SaveMonitor.IsCancelled) { return; } //SaveMonitor.FireSaveStateBeginning(TRSaveCategory.Custom, string.Format("Randomizing enemies in {0}", lvl.Name)); //Read the level into a level object LoadLevelInstance(lvl); //Apply the modifications RandomizeEnemyTypes(lvl); //Write back the level file SaveLevelInstance(); SaveMonitor.FireSaveStateChanged(1); } }