public SweetTreatRestorationElement(RestoreTypes restorationType, double movementDur, Vector2 startPosition, Vector2 endPosition) { RestorationType = restorationType; MovementDur = movementDur; StartPosition = startPosition; EndPosition = endPosition; //Initialize Initialize(); }
private void SetupRestorationDict(IList <int> restorationTypeCounts) { for (int i = 0; i < AllowedRestorationTypes.Count; i++) { //Add the type and count RestoreTypes restoreType = AllowedRestorationTypes[i]; if (RestorationTypeTracker.ContainsKey(restoreType) == false) { RestorationTypeTracker.Add(restoreType, restorationTypeCounts[i]); } } }
public SweetTreatRestorationElement(BattleUIManager bUIManager, RestoreTypes restorationType, double movementDur, Vector2 startPosition, Vector2 endPosition) { BUIManager = bUIManager; RestorationType = restorationType; MovementDur = movementDur; StartPosition = startPosition; EndPosition = endPosition; //Initialize Initialize(); }
protected void SpawnElement() { //Get an element to spawn RestoreTypes restoreType = ChooseElementToSpawn(); //If we get this value, we shouldn't be spawning if (restoreType == RestoreTypes.None) { Debug.LogError($"{nameof(SweetTreatElementSpawner)} is trying to spawn an element when it shouldn't be!"); return; } int randColRow = GeneralGlobals.Randomizer.Next(0, ColumnRows); float valAdd = randColRow * ColumnRowDiffVal; //Create the element Vector2 startPos = StartSpawnPos; Vector2 endPos = EndSpawnPos; if (IsVertical == true) { startPos.X += valAdd; endPos.X += valAdd; } else { startPos.Y += valAdd; endPos.Y += valAdd; } SweetTreatRestorationElement element = new SweetTreatRestorationElement(restoreType, MovementDur, startPos, endPos); RestorationElements.Add(element); BattleUIManager.Instance.AddUIElement(element); //Remove from this element RestorationTypeTracker[restoreType]--; //Remove the entry if we shouldn't spawn any more of them if (RestorationTypeTracker[restoreType] <= 0) { RestorationTypeTracker.Remove(restoreType); AllowedRestorationTypes.Remove(restoreType); } }
public override void StartInput(params object[] values) { base.StartInput(values); ElapsedTime = 0d; PrevThrow = 0d; StartPosition = Camera.Instance.SpriteToUIPos((Vector2)values[0]); //Count how many BattleEntities are affected //If there's only one, then don't add any of the Partner information int entitiesAffected = (int)values[1]; CursorAngle = MinCursorAngle; //Define the spawner Vector2 startPos = new Vector2(500, 15); Vector2 endPos = new Vector2(startPos.X, BattleGlobals.PartnerPos.Y + 350f); RestoreTypes[] restoreTypes = null; int[] restoreTypeCounts = null; if (entitiesAffected <= 1) { restoreTypes = new RestoreTypes[] { RestoreTypes.MarioHP, RestoreTypes.FP, RestoreTypes.PoisonMushroom }; restoreTypeCounts = new int[] { 14, 6, 2 }; } else { restoreTypes = new RestoreTypes[] { RestoreTypes.MarioHP, RestoreTypes.PartnerHP, RestoreTypes.FP, RestoreTypes.PoisonMushroom }; restoreTypeCounts = new int[] { 7, 7, 6, 2 }; } IconSpawner = new SweetTreatElementSpawner(BUIManager, 4, 40f, 5000d, 750d, startPos, endPos, restoreTypes, restoreTypeCounts); HealingResponse = default(SweetTreatResponse); }
public bool RestoreData(int cacheID, RestoreTypes type) { byte[] tmp = FileCache.GetFileFromCache(cacheID); if (tmp == null) return false; bool ret=true; ZipFile zf = new ZipFile(new MemoryStream(tmp), true); switch (type) { case RestoreTypes.Database: foreach (ZipFile.sZippedFile zfi in zf.Files) { if (zfi.Name == "database.rdpbk") { Stream ms = new MemoryStream(zfi.Data); ret = BackupManager.RestoreDataFromStream(ConnectionPoolManager.GetPool(typeof(Extension)), ref ms); } } break; case RestoreTypes.Voicemail: Log.Trace("Cleaning out voicemail directory..."); CleanDirectory(Settings.Current[Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Constants.DEFAULT_VOICEMAIL_PATH); Log.Trace("Examining all content within uploaded zip file..."); foreach(sZippedFolder fold in zf.Folders) { if (fold.Name == "voicemail") { RestoreFiles(fold, Settings.Current[Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Constants.DEFAULT_VOICEMAIL_PATH); break; } } foreach (ZipFile.sZippedFile file in zf.Files) { if (file.Name == "voicemail_restore.sql") { Utility.ExecuteCommandToFreeswitchDB(FileDownloader.VM_DB, System.Text.ASCIIEncoding.ASCII.GetString(file.Data)); break; } } break; case RestoreTypes.Recordings: Log.Trace("Cleaning out recordings directory..."); CleanDirectory(Settings.Current[Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.DEFAULT_RECORDINGS_DIRECTORY); Log.Trace("Examining all content within uploaded zip file..."); foreach (sZippedFolder fold in zf.Folders) { if (fold.Name == "recordings") { RestoreFiles(fold, Settings.Current[Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.DEFAULT_RECORDINGS_DIRECTORY); } } break; case RestoreTypes.Script: Log.Trace("Cleaning out scripts directory..."); CleanDirectory(Settings.Current[Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.DEFAULT_SCRIPTS_DIRECTORY); Log.Trace("Examining all content within uploaded zip file..."); foreach (sZippedFolder fold in zf.Folders) { if (fold.Name == "scripts") { RestoreFiles(fold,Settings.Current[Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.DEFAULT_SCRIPTS_DIRECTORY); } } break; case RestoreTypes.Sounds: Log.Trace("Cleaning out sounds directory..."); CleanDirectory(Settings.Current[Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.DEFAULT_SOUNDS_DIRECTORY); Log.Trace("Examining all content within uploaded zip file..."); foreach (sZippedFolder fold in zf.Folders) { if (fold.Name == "sounds") { RestoreFiles(fold, Settings.Current[Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.DEFAULT_SOUNDS_DIRECTORY); } } break; case RestoreTypes.Complete: Log.Trace("Cleaning out directories to perform complete restore..."); CleanDirectory(Settings.Current[Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Constants.DEFAULT_VOICEMAIL_PATH); CleanDirectory(Settings.Current[Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.DEFAULT_RECORDINGS_DIRECTORY); CleanDirectory(Settings.Current[Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.DEFAULT_SCRIPTS_DIRECTORY); CleanDirectory(Settings.Current[Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.DEFAULT_SOUNDS_DIRECTORY); Log.Trace("Restoring data from the zip file to the system..."); foreach (sZippedFolder fold in zf.Folders) { switch (fold.Name) { case "voicemail": RestoreFiles(fold, Settings.Current[Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Constants.DEFAULT_VOICEMAIL_PATH); break; case "recordings": RestoreFiles(fold, Settings.Current[Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.DEFAULT_RECORDINGS_DIRECTORY); break; case "scripts": RestoreFiles(fold, Settings.Current[Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.DEFAULT_SCRIPTS_DIRECTORY); break; case "sounds": RestoreFiles(fold, Settings.Current[Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.DEFAULT_SOUNDS_DIRECTORY); break; } } foreach (ZipFile.sZippedFile zfi in zf.Files) { switch (zfi.Name) { case "database.rdpbk": Stream ms = new MemoryStream(zfi.Data); ret = BackupManager.RestoreDataFromStream(ConnectionPoolManager.GetPool(typeof(Extension)), ref ms); break; case "voicemail_restore.sql": Utility.ExecuteCommandToFreeswitchDB(FileDownloader.VM_DB, System.Text.ASCIIEncoding.ASCII.GetString(zfi.Data)); break; } } break; } zf.Close(); return ret; }
public override void StartInput(params object[] values) { base.StartInput(values); ElapsedTime = 0d; PrevThrow = 0d; StartPosition = Camera.Instance.SpriteToUIPos((Vector2)values[0]); //Count how many BattleEntities are affected //If there's only one, then don't add any of the Partner information int entitiesAffected = (int)values[1]; CursorAngle = MinCursorAngle; //Define the UI to display Texture2D battleGFX = AssetManager.Instance.LoadRawTexture2D($"{ContentGlobals.BattleGFX}.png"); CroppedTexture2D croppedTex2D = new CroppedTexture2D(battleGFX, new Rectangle(14, 273, 46, 46)); Cursor = new UIFourPiecedTex(croppedTex2D, croppedTex2D.WidthHeightToVector2(), .5f, Color.White); MarioHPIcon = new UICroppedTexture2D(new CroppedTexture2D(battleGFX, new Rectangle(324, 407, 61, 58))); FPIcon = new UICroppedTexture2D(new CroppedTexture2D(battleGFX, new Rectangle(179, 416, 40, 39))); MarioHPText = new UIText("0", Color.Black); FPText = new UIText("0", Color.Black); //Set UI properties MarioHPIcon.Position = MarioHPText.Position = StartPosition + new Vector2(-10, -45); FPIcon.Position = FPText.Position = StartPosition + new Vector2(-45, -95); MarioHPText.Position += new Vector2(0f, 10f); FPText.Position += new Vector2(0f, 10f); if (entitiesAffected > 1) { PartnerHPIcon = new UICroppedTexture2D(new CroppedTexture2D(battleGFX, new Rectangle(324, 407, 61, 58))); PartnerHPText = new UIText("0", Color.Black); PartnerHPIcon.Position = PartnerHPText.Position = StartPosition + new Vector2(-80, -45); PartnerHPText.Position += new Vector2(0f, 10f); PartnerHPIcon.Origin = PartnerHPText.Origin = new Vector2(.5f, .5f); PartnerHPIcon.Depth = .6f; PartnerHPText.Depth = .61f; } MarioHPIcon.Depth = FPIcon.Depth = .6f; MarioHPText.Depth = FPText.Depth = .61f; MarioHPIcon.Origin = FPIcon.Origin = MarioHPText.Origin = FPText.Origin = new Vector2(.5f, .5f); //Set cursor position Cursor.Position = UtilityGlobals.GetPointAroundCircle(new Circle(StartPosition, CircleRadius), CursorAngle, true); //Define the spawner Vector2 startPos = new Vector2(500, 15); Vector2 endPos = new Vector2(startPos.X, BattleManager.Instance.PartnerPos.Y + 350f); RestoreTypes[] restoreTypes = null; int[] restoreTypeCounts = null; if (entitiesAffected <= 1) { restoreTypes = new RestoreTypes[] { RestoreTypes.MarioHP, RestoreTypes.FP, RestoreTypes.PoisonMushroom }; restoreTypeCounts = new int[] { 14, 6, 2 }; } else { restoreTypes = new RestoreTypes[] { RestoreTypes.MarioHP, RestoreTypes.PartnerHP, RestoreTypes.FP, RestoreTypes.PoisonMushroom }; restoreTypeCounts = new int[] { 7, 7, 6, 2 }; } IconSpawner = new SweetTreatElementSpawner(4, 40f, 5000d, 750d, startPos, endPos, restoreTypes, restoreTypeCounts); //Add the cursor and other UI elements BattleUIManager.Instance.AddUIElement(Cursor); BattleUIManager.Instance.AddUIElement(MarioHPIcon); BattleUIManager.Instance.AddUIElement(FPIcon); BattleUIManager.Instance.AddUIElement(MarioHPText); BattleUIManager.Instance.AddUIElement(FPText); if (entitiesAffected > 1) { BattleUIManager.Instance.AddUIElement(PartnerHPIcon); BattleUIManager.Instance.AddUIElement(PartnerHPText); } HealingResponse = default(SweetTreatResponse); }
public bool RestoreData(int cacheID, RestoreTypes type) { byte[] tmp = FileCache.GetFileFromCache(cacheID); if (tmp == null) { return(false); } bool ret = true; ZipFile zf = new ZipFile(new MemoryStream(tmp), true); switch (type) { case RestoreTypes.Database: foreach (ZipFile.sZippedFile zfi in zf.Files) { if (zfi.Name == "database.rdpbk") { Stream ms = new MemoryStream(zfi.Data); ret = BackupManager.RestoreDataFromStream(ConnectionPoolManager.GetPool(typeof(Extension)), ref ms); } } break; case RestoreTypes.Voicemail: Log.Trace("Cleaning out voicemail directory..."); CleanDirectory(Settings.Current[Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Constants.DEFAULT_VOICEMAIL_PATH); Log.Trace("Examining all content within uploaded zip file..."); foreach (sZippedFolder fold in zf.Folders) { if (fold.Name == "voicemail") { RestoreFiles(fold, Settings.Current[Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Constants.DEFAULT_VOICEMAIL_PATH); break; } } foreach (ZipFile.sZippedFile file in zf.Files) { if (file.Name == "voicemail_restore.sql") { Utility.ExecuteCommandToFreeswitchDB(FileDownloader.VM_DB, System.Text.ASCIIEncoding.ASCII.GetString(file.Data)); break; } } break; case RestoreTypes.Recordings: Log.Trace("Cleaning out recordings directory..."); CleanDirectory(Settings.Current[Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.DEFAULT_RECORDINGS_DIRECTORY); Log.Trace("Examining all content within uploaded zip file..."); foreach (sZippedFolder fold in zf.Folders) { if (fold.Name == "recordings") { RestoreFiles(fold, Settings.Current[Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.DEFAULT_RECORDINGS_DIRECTORY); } } break; case RestoreTypes.Script: Log.Trace("Cleaning out scripts directory..."); CleanDirectory(Settings.Current[Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.DEFAULT_SCRIPTS_DIRECTORY); Log.Trace("Examining all content within uploaded zip file..."); foreach (sZippedFolder fold in zf.Folders) { if (fold.Name == "scripts") { RestoreFiles(fold, Settings.Current[Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.DEFAULT_SCRIPTS_DIRECTORY); } } break; case RestoreTypes.Sounds: Log.Trace("Cleaning out sounds directory..."); CleanDirectory(Settings.Current[Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.DEFAULT_SOUNDS_DIRECTORY); Log.Trace("Examining all content within uploaded zip file..."); foreach (sZippedFolder fold in zf.Folders) { if (fold.Name == "sounds") { RestoreFiles(fold, Settings.Current[Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.DEFAULT_SOUNDS_DIRECTORY); } } break; case RestoreTypes.Complete: Log.Trace("Cleaning out directories to perform complete restore..."); CleanDirectory(Settings.Current[Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Constants.DEFAULT_VOICEMAIL_PATH); CleanDirectory(Settings.Current[Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.DEFAULT_RECORDINGS_DIRECTORY); CleanDirectory(Settings.Current[Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.DEFAULT_SCRIPTS_DIRECTORY); CleanDirectory(Settings.Current[Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.DEFAULT_SOUNDS_DIRECTORY); Log.Trace("Restoring data from the zip file to the system..."); foreach (sZippedFolder fold in zf.Folders) { switch (fold.Name) { case "voicemail": RestoreFiles(fold, Settings.Current[Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Constants.DEFAULT_VOICEMAIL_PATH); break; case "recordings": RestoreFiles(fold, Settings.Current[Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.DEFAULT_RECORDINGS_DIRECTORY); break; case "scripts": RestoreFiles(fold, Settings.Current[Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.DEFAULT_SCRIPTS_DIRECTORY); break; case "sounds": RestoreFiles(fold, Settings.Current[Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Org.Reddragonit.FreeSwitchConfig.DataCore.Constants.DEFAULT_SOUNDS_DIRECTORY); break; } } foreach (ZipFile.sZippedFile zfi in zf.Files) { switch (zfi.Name) { case "database.rdpbk": Stream ms = new MemoryStream(zfi.Data); ret = BackupManager.RestoreDataFromStream(ConnectionPoolManager.GetPool(typeof(Extension)), ref ms); break; case "voicemail_restore.sql": Utility.ExecuteCommandToFreeswitchDB(FileDownloader.VM_DB, System.Text.ASCIIEncoding.ASCII.GetString(zfi.Data)); break; } } break; } zf.Close(); return(ret); }