//Function to add Actions to Array public void AddEvent(actions action) { checkpoint = AtomicTags.FindByTag(checkpointTag.Value).GetComponent <SavePoint>(); if (myActions == null) { myActions = new actions[checkpoint.hasBeenActivated.Length + 1]; } /*for (int i=checkpoint.numActive+1;i<checkpoint.hasBeenActivated.Length;i++) * { * if (!checkpoint.hasBeenActivated[i]) * { * events[i] -= action; * events[i] += action; * Debug.Log("Added " + action.GetMethodInfo() +" to checksave " +i); * } * }*/ if (checkpoint.numActive >= myActions.Length) { Debug.Log("returning empty"); return; } Debug.Log(action.GetMethodInfo()); myActions[checkpoint.numActive + 1] -= action; myActions[checkpoint.numActive + 1] += action; }
// Start is called before the first frame update void Start() { savepoint = this; alpha = saveAlpha.color; alpha.a = 0f; }
internal static void SavePoin() { //сохранить достижения игрока List <Tybing1> Tybing1 = new List <Tybing1>(); List <Tybing2> Tybing2 = new List <Tybing2>(); List <Tybing3> Tybing3 = new List <Tybing3>(); List <Tybing4> Tybing4 = new List <Tybing4>(); List <Brick> Brick = new List <Brick>(); for (int y = 0; y < Map.SizeY; y++) { for (int x = 0; x < Map.SizeX; x++) { var _tybing = Map.MapTybings[y, x]; if (_tybing is Tybing1) { Tybing1.Add((Tybing1)Map.MapTybings[y, x]); } if (_tybing is Tybing2) { Tybing2.Add((Tybing2)Map.MapTybings[y, x]); } if (_tybing is Tybing3) { Tybing3.Add((Tybing3)Map.MapTybings[y, x]); } if (_tybing is Tybing4) { Tybing4.Add((Tybing4)Map.MapTybings[y, x]); } if (_tybing is Brick) { Brick.Add((Brick)Map.MapTybings[y, x]); } } } SavePoint savePoint = new SavePoint() { player = _Player, FinishTybing = Map.FinishTybing, IsCompletedAllConnectedTybing = Map.IsCompletedAllConnectedTybing, Tybing1 = Tybing1, Tybing2 = Tybing2, Tybing3 = Tybing3, Tybing4 = Tybing4, Brick = Brick, NameLevel = Map.NameLevel, SizeX = Map.SizeX, SizeY = Map.SizeY, StartTybing = Map.StartTybing, Time = Map.Time, TravelTime = Map.TravelTime }; System.IO.File.WriteAllText("SavePoint.json", JsonConvert.SerializeObject(savePoint)); }
/// <summary> /// Notify that everything has been saved and create a save point in the action stack. /// </summary> public void NotifySave() { savePoint = ActionStack.CreateSavePoint(true); actionItems.ForEach(x => x.IsSavePoint = x.ActionItem.Identifier == savePoint.ActionItemIdentifier); var dirtiableManager = ServiceProvider.TryGet<DirtiableManager>(); dirtiableManager.NotifySave(); }
void OnTriggerEnter2D(Collider2D other) { switch (other.gameObject.tag) { case "SavePoint": IsOnSavePoint = true; SavePoint = other.gameObject; if (IsOnSavePoint && player2.GetComponent <Player2>().IsOnSavePoint) { SavedPoint = SavePoint.transform.position; SavePoint.GetComponent <SavePoint>().Save(); player2.GetComponent <Player2>().SavedPoint = player2.GetComponent <Player2>().SavePoint.transform.position; player2.GetComponent <Player2>().SavePoint.GetComponent <SavePoint>().Save(); } break; case "WireCabinet": isNearWireCabinet = true; wireCabinet = other.gameObject.transform.parent.gameObject; break; case "IItem": PickupItem(other.gameObject.name); break; default: break; } }
private void OnTriggerStay2D(Collider2D col) { Collider2D savePoint = col; switch (col.gameObject.tag) { case "SavePoint": SavePoint obj = savePoint.gameObject.GetComponent <SavePoint>(); StartCoroutine(obj.Show(0.005f)); bool save = false; if (Input.GetKeyDown(controller.interact) && rb.velocity.magnitude < 1 && save == false) { SavePlayer(); DialogueManagement.Dialogue.READ_DIALOGUE_SET(2); } break; case "Treasure": if (Input.GetKeyDown(controller.interact) && rb.velocity.magnitude < 1) { col.gameObject.GetComponent <Treasure_Chest>().OpenChest(); DialogueManagement.Dialogue.READ_DIALOGUE_SET(3); } break; } }
// Start is called before the first frame update void Start() { anim = GetComponent <Animator>(); savePoint = FindObjectOfType <SavePoint>(); LoadButton(); /*if (door.GetComponent<AutomaticDoor>()) { * if (door.GetComponent<AutomaticDoor>().canOpen) { * anim.SetBool("isPushed", true); * isPushedString = "true"; * } * else if (!door.GetComponent<AutomaticDoor>().canOpen) { * anim.SetBool("isPushed", false); * isPushedString = "false"; * } * } * * if (door.GetComponent<ActivatedDoor>()) { * if (door.GetComponent<ActivatedDoor>().canOpen) { * anim.SetBool("isPushed", true); * isPushedString = "true"; * } * else if (!door.GetComponent<ActivatedDoor>().canOpen) { * anim.SetBool("isPushed", false); * isPushedString = "false"; * } * }*/ if (isPushedString == "true") { if (door.GetComponent <AutomaticDoor>()) { door.GetComponent <AutomaticDoor>().canOpen = true; isPushed = true; anim.SetBool("isPushed", true); } if (door.GetComponent <ActivatedDoor>()) { door.GetComponent <ActivatedDoor>().canOpen = true; isPushed = true; anim.SetBool("isPushed", true); } } if (isPushedString == "false") { if (door.GetComponent <AutomaticDoor>()) { door.GetComponent <AutomaticDoor>().canOpen = false; isPushed = false; anim.SetBool("isPushed", false); } if (door.GetComponent <ActivatedDoor>()) { door.GetComponent <ActivatedDoor>().canOpen = false; isPushed = false; anim.SetBool("isPushed", false); } } }
public static void ResetLevel() { Oscar.Instance.ResetToInitialState(); LivesManager.Instance.Reset(); UI.Instance.Reset(); SavePoint.ResetSavePoints(); }
internal void AddSavePoint(ref Match match, int data) { var savepoint = new SavePoint(match.CheckPoint(), this.SyntaxIndex); savepoint.stack.Push(data); AddSavePoint(savepoint); }
//-------------------------------------------------------------------------------------------------- //-- SAVE //-------------------------------------------------------------------------------------------------- public void Save(SavePoint savePoint) { lastSaveData = CreateSaveData(savePoint); Thread _t1 = new Thread(SaveToFile); _t1.Start(); }
// Use this for initialization void Start() { //bgm bgms = GameObject.FindGameObjectWithTag("MainCamera").GetComponents <AudioSource>(); PlatformerBgm = bgms[1]; ChaseBgm = bgms[2]; EndingBgm = bgms[3]; RemoveHeartSound = bgms[4]; gameoverBgm = bgms[5]; savePointBgm = bgms[6]; scoreText.text = "Coin x " + coinScore.ToString(); instance = this; player = GameObject.FindGameObjectWithTag("Player"); playerScript = player.GetComponent <PlayerMove_refine>(); playerTrans = player.GetComponent <Transform>(); playerAudio = player.GetComponent <AudioSource>(); savePoint = player.GetComponent <SavePoint>(); fadeScript = fadeEffectUI.transform.GetChild(1).gameObject.GetComponent <FadeEffect>(); // FadeIn 캐싱 fadeIn = fadeEffectUI.transform.GetChild(0).gameObject; // FadeIn 실행 fadeIn.SetActive(true); fadeEffectUI.transform.GetChild(0).GetComponent <FadeEffect>().StartFade(); //for gameover startPosition = player.GetComponent <Transform>().position; //Packman Control packmanControl = GameObject.Find("PackmanManager").GetComponent <PackmanControl>(); chasePackman = GameObject.Find("CollisionBox").GetComponent <ChasePackman>(); }
/// <summary> /// Notify that everything has been saved and create a save point in the action stack. /// </summary> public void NotifySave() { savePoint = ActionStack.CreateSavePoint(true); actionItems.ForEach(x => x.IsSavePoint = x.ActionItem.Identifier == savePoint.ActionItemIdentifier); var dirtiableManager = ServiceProvider.TryGet <DirtiableManager>(); dirtiableManager.NotifySave(); }
private bool AcceptOfNonvalidDbfSetup(SavePoint save) { DialogResult reply = MessageBox.Show(catalog.GetStringFmt( "The selected file contains Debrief Eval data.\nBut Debrief Evaluation checkbox (Main menu) is unchecked.\nYou cannot continue with the Evaluation on course.\n\nContinue?"), Application.ProductName + " " + VersionInfo.VersionOrBuild, MessageBoxButtons.YesNo, MessageBoxIcon.Information); return(reply == DialogResult.Yes); }
public void LoadSavePoint(SavePoint savePoint) { if (savePoint != null) { SavePointSingleton.GetInstance(savePoint); DataSingleton.GetInstance(savePoint.IdPhase, savePoint.IdSoftwareTool); } }
void AddSavePoint(SavePoint savepoint) { if (backtrackingStack == null) { backtrackingStack = new List <SavePoint>(); } backtrackingStack.Add(savepoint); }
private bool AcceptUseOfNonvalidSave(SavePoint save) { DialogResult reply = MessageBox.Show(catalog.GetString( $"Restoring from a save made by version {save.ProgramVersion} of {RuntimeInfo.ProductName} may be incompatible with current version {VersionInfo.Version}. Please do not report any problems that may result.\n\nContinue?"), $"{RuntimeInfo.ProductName} {VersionInfo.Version}", MessageBoxButtons.YesNo, MessageBoxIcon.Question); return(reply == DialogResult.Yes); }
public void CheckInSavePoint(SavePoint p) { if (p.isFirst) { firstSave = p; } allSavePoints.Add(p); }
/// <summary> /// Restores the app from the given save point. /// </summary> /// <param name="checkpoint"></param> public void Restore(SavePoint checkpoint) { ScriptManager.Instance.StopAllProcessors(() => { StorageManager.RestoreGameData("savePoints", checkpoint.Id); ScriptManager.Instance.RunScripts(); }); }
public void UpdateSavePoint(Vector3 position, SavePoint point) { if (LastSavePoint) { LastSavePoint.Fire.color = Color.white; } LastSaveposition = position; LastSavePoint = point; }
public static SavePointSingleton GetInstance(SavePoint savePoint) { if (instance is null) { instance = new SavePointSingleton(); } instance.SetIndicators(savePoint); return(instance); }
public void SaveElement(SavePoint savePoint, string path) { XmlSerializer xml = new XmlSerializer(typeof(SavePoint)); using (TextWriter writer = new StreamWriter(path)) { xml.Serialize(writer, savePoint); } }
private bool AcceptUseOfNonvalidSave(SavePoint save) { DialogResult reply = MessageBox.Show(catalog.GetStringFmt( "Restoring from a save made by version {1} of {0} may be incompatible with current version {2}. Please do not report any problems that may result.\n\nContinue?", Application.ProductName, save.VersionOrBuild, VersionInfo.VersionOrBuild), Application.ProductName + " " + VersionInfo.VersionOrBuild, MessageBoxButtons.YesNo, MessageBoxIcon.Question); return(reply == DialogResult.Yes); }
private async void ButtonImportExportSaves_Click(object sender, EventArgs e) { SavePoint save = saveBindingSource.Current as SavePoint; using (ImportExportSaveForm form = new ImportExportSaveForm(save, catalog)) { form.ShowDialog(); } await LoadSavePointsAsync().ConfigureAwait(true); }
// Methods public void SetSave(SavePoint save) { if (currentSave != save) { if (currentSave != null) { currentSave.DecorateAsNotCurrentSave(); } currentSave = save; currentSave.DecorateAsCurrentSave(); } }
} //Debrief Eval public static Task <List <SavePoint> > GetSavePoints(string directory, string prefix, string build, string routeName, int failedRestoreVersion, string warnings, System.Threading.CancellationToken token) { TaskCompletionSource <List <SavePoint> > tcs = new TaskCompletionSource <List <SavePoint> >(); List <SavePoint> result = new List <SavePoint>(); Parallel.ForEach(Directory.GetFiles(directory, prefix + "*.save"), (saveFile, state) => { if (token.IsCancellationRequested) { tcs.SetCanceled(); state.Stop(); } try { // SavePacks are all in the same folder and activities may have the same name // (e.g. Short Passenger Run shrtpass.act) but belong to a different route, // so pick only the activities for the current route. SavePoint save = new SavePoint(saveFile, build, failedRestoreVersion); if (string.IsNullOrEmpty(routeName) || save.RouteName == routeName) { if (!save.IsMultiplayer ^ Multiplayer) { lock (result) { result.Add(save); } } } else // In case you receive a SavePack where the activity is recognised but the route has been renamed. // Checks the route is not in your list of routes. // If so, add it with a warning. { if (!globalRoutes.Any(el => el.Name == save.RouteName)) { if (!save.IsMultiplayer ^ Multiplayer) { lock (result) { result.Add(save); } } // SavePoint a warning to show later. warnings += catalog.GetStringFmt("Warning: Save {0} found from a route with an unexpected name:\n{1}.\n\n", save.RealTime, save.RouteName); } } } catch { } }); tcs.TrySetResult(result); return(tcs.Task); }
public void ReStart(SavePoint s) { if (s == SavePoint.Map1Level1) { PlayerManager.Instance.BombLock = true; } PlayerManager.Instance.FireLock = false; PlayerManager.Instance.MoveLock = false; PlayerManager.Instance.transform.position = SavePos[(int)s].position; PlayerManager.Instance.health = PlayerManager.Instance.maxHealth; Destroy(Story2Temp); ReLoad(s); }
public void InvokeEvent() { checkpoint = AtomicTags.FindByTag(checkpointTag.Value).GetComponent <SavePoint>(); //Debug.Log(checkpoint.numActive+1 +" checkpoints are active"); Debug.Log("a cockroach"); if (checkpoint.numActive >= 0) { //Debug.Log("invoke action from set " + checkpoint.numActive ); //Debug.Log(myActions?[checkpoint.numActive]?.GetMethodInfo()); Debug.Log("in a bunker"); myActions?[checkpoint.numActive]?.Invoke(); } } //on death
public void ActivateSavePoint(ResourceActivationContext context, SavePoint resource) { StorageManager.CopyGameData("savePoints", resource.Id); m_checkpoints.RemoveAll(c => c.Checkpoint.Id == resource.Id); m_checkpoints.Add(new SavePointState { Time = DateTime.Now, Checkpoint = resource }); SaveState(); }
private void DeleteSavePoint(SavePoint savePoint) { if (null != savePoint) { foreach (string fileName in Directory.GetFiles(Path.GetDirectoryName(savePoint.File), savePoint.Name + ".*")) { try { File.Move(fileName, Path.Combine(UserSettings.DeletedSaveFolder, Path.GetFileName(fileName))); } catch { } } } }
private void ResumeSave() { SavePoint save = saveBindingSource.Current as SavePoint; if (null != save) { //Debrief Eval if (save.DebriefEvaluation && !settings.DebriefActivityEval) { if (!AcceptOfNonvalidDbfSetup()) { return; } } if (save.Valid != false && Found(save)) // I.e. true or null. Check is for safety as buttons should be disabled if SavePoint is invalid. { if (save.Valid == null) { if (!AcceptUseOfNonvalidSave(save)) { return; } } SelectedSaveFile = save.File; MainForm.UserAction selectedAction = SelectedAction; switch (SelectedAction) { case MainForm.UserAction.SinglePlayerTimetableGame: selectedAction = MainForm.UserAction.SinglePlayerResumeTimetableGame; break; case MainForm.UserAction.SingleplayerNewGame: selectedAction = MainForm.UserAction.SingleplayerResumeSave; break; case MainForm.UserAction.MultiplayerClient: selectedAction = MainForm.UserAction.MultiplayerClientResumeSave; break; case MainForm.UserAction.MultiplayerServer: selectedAction = MainForm.UserAction.MultiplayerServerResumeSave; break; } SelectedAction = selectedAction; DialogResult = DialogResult.OK; } } }
private async Task LoadSavePointsAsync() { lock (savePoints) { if (ctsLoader != null && !ctsLoader.IsCancellationRequested) { ctsLoader.Cancel(); ctsLoader.Dispose(); } ctsLoader = new System.Threading.CancellationTokenSource(); } string warnings = string.Empty; string build = VersionInfo.Build.Contains(" ") ? VersionInfo.Build.Substring(VersionInfo.Build.IndexOf(" ") + 1) : null; var prefix = string.Empty; if (SelectedAction == MainForm.UserAction.SinglePlayerTimetableGame) { prefix = Path.GetFileName(route.Path) + " " + Path.GetFileNameWithoutExtension(timeTable.FileName); } else if (activity.FilePath != null) { prefix = Path.GetFileNameWithoutExtension(activity.FilePath); } else if (activity.Name == "- " + catalog.GetString("Explore Route") + " -") { prefix = Path.GetFileName(route.Path); } // Explore in activity mode else { prefix = "ea$" + Path.GetFileName(route.Path) + "$"; } savePoints = (await Task.Run(() => SavePoint.GetSavePoints(UserSettings.UserDataFolder, prefix, build, route.Name, settings.YoungestFailedToRestore, warnings, ctsLoader.Token))).OrderBy(s => s.RealTime).Reverse().ToList(); saveBindingSource.DataSource = savePoints; labelInvalidSaves.Text = catalog.GetString( "To prevent crashes and unexpected behaviour, Open Rails invalidates games saved from older versions if they fail to restore.\n") + catalog.GetStringFmt("{0} of {1} saves for this route are no longer valid.", savePoints.Count(s => (s.Valid == false)), savePoints.Count); GridSaves_SelectionChanged(null, null); // Show warning after the list has been updated as this is more useful. if (!string.IsNullOrEmpty(warnings)) { MessageBox.Show(warnings, Application.ProductName + " " + VersionInfo.VersionOrBuild); } }
// Create object in room upon user click private void MakeSpaceObject(string texName, Image tex, DrawPoint mp) { texName = texName.Replace(".png", ""); int numberOfFrames = SpaceObject.GetNumberOfFrames(texName); //Much repeated code to account for each possible object if (rb_WallStatic.Checked) { mp.X -= (texture.Width / (numberOfFrames * 2)); mp.Y -= (texture.Height / 2); WallStatic wall = new WallStatic( Conversion.DrawPointToVector2(mp), currdir + "\\" + texName + ".tri"); wall.TextureName = texName; currentlySelectedRoom.AddObject(wall); } else if (rb_WallDynamic.Checked) { mp.X -= (texture.Width / (numberOfFrames * 2)); mp.Y -= (texture.Height / 2); WallDynamic wall = new WallDynamic( Conversion.DrawPointToVector2(mp), new Vector2(0, 0), currdir + "\\" + texName + ".tri"); wall.TextureName = texName; currentlySelectedRoom.AddObject(wall); } else if (rb_HazardStatic.Checked) { mp.X -= (texture.Width / (numberOfFrames * 2)); mp.Y -= (texture.Height / 2); HazardStatic hazard = new HazardStatic( Conversion.DrawPointToVector2(mp), currdir + "\\" + texName + ".tri"); hazard.TextureName = texName; currentlySelectedRoom.AddObject(hazard); } else if (rb_HazardDynamic.Checked) { mp.X -= (texture.Width / (numberOfFrames * 2)); mp.Y -= (texture.Height / 2); HazardDynamic hazard = new HazardDynamic( Conversion.DrawPointToVector2(mp), new Vector2(0, 0), currdir + "\\" + texName + ".tri"); hazard.TextureName = texName; currentlySelectedRoom.AddObject(hazard); } else if (rb_Parts.Checked) { mp.X -= (texture.Width / (numberOfFrames * 2)); mp.Y -= (texture.Height / 2); Part part = new Part( Conversion.DrawPointToVector2(mp), currdir + "\\" + texName + ".tri"); part.TextureName = texName; currentlySelectedRoom.AddObject(part); } else if (rb_Survivors.Checked) { mp.X -= (texture.Width / (numberOfFrames * 2)); mp.Y -= (texture.Height / 2); Survivor survivor = new Survivor( Conversion.DrawPointToVector2(mp), currdir + "\\" + texName + ".tri"); survivor.TextureName = texName; //sets up the survivor color as appropriate switch (survivor.TextureName) { case "Art\\Survivors\\SurvivorBlue": survivor.SColor = Survivor.survivorColor.BLUE; break; case "Art\\Survivors\\SurvivorRed": survivor.SColor = Survivor.survivorColor.RED; break; case "Art\\Survivors\\SurvivorYellow": survivor.SColor = Survivor.survivorColor.YELLOW; break; case "Art\\Survivors\\SurvivorPurple": survivor.SColor = Survivor.survivorColor.PURPLE; break; case "Art\\Survivors\\SurvivorOrange": survivor.SColor = Survivor.survivorColor.ORANGE; break; case "Art\\Survivors\\Survivor": survivor.SColor = Survivor.survivorColor.GREEN; break; default: break; } currentlySelectedRoom.AddObject(survivor); } else if (rb_Vanish_Walls.Checked) { mp.X -= (texture.Width / (numberOfFrames * 2)); mp.Y -= (texture.Height / 2); VanishWall vanish = new VanishWall( Conversion.DrawPointToVector2(mp), currdir + "\\" + texName + ".tri"); vanish.TextureName = texName; currentlySelectedRoom.AddObject(vanish); } else if (rb_Handlebars.Checked) { mp.X -= (texture.Width / 2); mp.Y -= (texture.Height / 2); Handlebar hdlbar = new Handlebar( Conversion.DrawPointToVector2(mp), new Vector2(0, 0), currdir + "\\" + texName + ".tri"); hdlbar.TextureName = texName; currentlySelectedRoom.AddObject(hdlbar); } else if (rb_VictoryTest.Checked) { mp.X -= (texture.Width / 2); mp.Y -= (texture.Height / 2); VictoryTest victest = new VictoryTest( Conversion.DrawPointToVector2(mp), currdir + "\\" + texName + ".tri"); victest.TextureName = texName; currentlySelectedRoom.AddObject(victest); } else if (rb_SavePoint.Checked) { mp.X -= (texture.Width / (numberOfFrames * 2)); mp.Y -= (texture.Height / 2); SavePoint savePoint = new SavePoint( Conversion.DrawPointToVector2(mp), currdir + "\\" + texName + ".tri"); savePoint.TextureName = texName; currentlySelectedRoom.AddObject(savePoint); } else if (rb_Player.Checked) { mp.X -= (int)((texture.Width * Constants.PLAYER_SCALE) / 2); mp.Y -= (int)((texture.Height * Constants.PLAYER_SCALE) / 2); world.player = new Player( Conversion.DrawPointToVector2(mp), currdir + "\\" + texName + ".tri" ); world.CurrentRoom = currentlySelectedRoom; world.player.TextureName = texName; } }
/// <summary> /// Notify that everything has been saved and create a save point in the action stack. /// </summary> public void NotifySave() { savePoint = actionStack.CreateSavePoint(true); actionItems.ForEach(x => x.IsSavePoint = x.ActionItem.Identifier == savePoint.ActionItemIdentifier); }