public void StopRewind(float elapsedTime) { if (!RewindManager.RewindStarted) { return; } RewindableScript rs = GetComponent <RewindableScript>(); if (rs != null) { rs.WillStopRewinding(elapsedTime); } RewindManager.StopRewind(); if (collection) { _rm.RewUnits.RemoveAll(rewindUnits.Contains); } else { _rm.RewUnits.Remove(gameObject); } }
public void StartRewind() { if (RewindManager.RewindStarted) { return; } RewindableScript rs = GetComponent <RewindableScript>(); if (rs != null) { rs.WillStartRewinding(); } if (collection) { _rm.RewUnits.AddRange(rewindUnits); } else { _rm.RewUnits.Add(gameObject); } RewindManager.StartRewind(); }
// Use this for initialization public override void Start() { base.Start(); collection = (renderer == null); _rm = RewindManager.RewindObj.GetComponent <RewindManager>(); // if mesh renderer if (!collection) { renderer.material.SetColor("_Color", new Color(0.85f, 0.11f, 0.11f, 0)); } else // am I a collection ? { rewindUnits = new List <GameObject>(); foreach (Transform to in transform) { if (to.gameObject.GetComponent <RewindUnit>() != null) { to.gameObject.renderer.material.SetColor("_Color", new Color(0.85f, 0.11f, 0.11f, 0)); rewindUnits.Add(to.gameObject); } } } }
private void HandleRewind(GameTime gameTime) { if (!helpMenuVisible && !fileDialogVisible) { if (timeSinceLastRewindCycle > 1.0 / rewindFrequency) { timeSinceLastRewindCycle = 0; if (Keyboard.GetState().IsKeyDown(rewindKey)) { isRewinding = true; cpu.ApplyState(RewindManager.Rewind()); } else { isRewinding = false; if (!frameAdvance && !isPaused) { RewindManager.Record(cpu.GetState()); } } } else { timeSinceLastRewindCycle += gameTime.ElapsedGameTime.TotalSeconds; } } }
void Start() { npcManager = NPCManager.instance; Ground = GroundFind.instance.gameObject; rewind = RewindManager.instance; player = PlayerController.instance; rb2d = GetComponent <Rigidbody2D>(); collider2D = GetComponent <Collider2D>(); dialogueUI = GetComponentInChildren <DialogueUI>(); health = GetComponent <Health>(); anim = GetComponent <Animator>(); currentPathTargetIndex = 0; if (path != null) { currentPathTarget = path.positions[currentPathTargetIndex]; } if (canBeHostile) { weaponGameObject = Instantiate(items.Find(x => x.itemType == ItemType.Gun).gameObject, rb2d.position, Quaternion.identity); weaponGameObject.GetComponent <PickupObject>().canPickup = false; weaponGameObject.GetComponent <SpriteRenderer>().enabled = false; weaponGameObject.transform.parent = Ground.transform; weapon = weaponGameObject.GetComponent <Item>(); shotAudioSource = GetComponent <AudioSource>(); weaponLight = GetComponentInChildren <Light2D>(); } }
void Awake() { if (instance != null) { return; } instance = this; }
void Start() { rewind = RewindManager.instance; rb2d = GetComponent <Rigidbody2D>(); playerAnim = GetComponentInChildren <PlayerAnimation>(); pc = GetComponent <PlayerController>(); }
void Start() { npcManager = NPCManager.instance; rewind = RewindManager.instance; positions = new LinkedList <ObjectInTime>(); rigidbody = GetComponent <Rigidbody2D>(); isReallyKinematic = rigidbody.isKinematic; health = GetComponent <Health>(); }
protected virtual void Start() { if (!id.Equals("")) { return; } id = count.ToString(); count++; RewindManager.Register(this); }
private void Awake() { if (_instance != null && _instance != this) { Debug.LogError("more than one rewindManager!"); Destroy(this.gameObject); } else { _instance = this; } }
void Start() { npcManager = NPCManager.instance; npcMemory = npcManager.GetComponent <InMemoryVariableStorage>(); rewind = RewindManager.instance; light = GetComponentInChildren <Light2D>(); inventory = Inventory.instance; playerShooting = GetComponent <PlayerShooting>(); isInDialogue = false; }
private void Awake() { if (Instance) { Destroy(gameObject); return; } else { Instance = this; } ObjectsToSave = new List <ObjectSaver>(); _queue = new Queue <Dictionary <ObjectSaver, TypeDataPair[]> >(queueLength); }
private IEnumerator repeatedlyRewind() { RewindScreen.SetActive(true); rewindSound.pitch = 0.5f; rewindSound.Play(); RewindManager.Rewind(); float x = 1; while (true) { float waitTime = (float)(0.5 / Math.Sqrt(4 * x)); yield return(new WaitForSeconds(waitTime)); x += waitTime; rewindSound.pitch = x / 2; RewindManager.Rewind(); } }
private void Awake() { Instance = this; }
// Start is called before the first frame update void Start() { rewind = RewindManager.instance; remainingRewindsText.text = rewind.rewindsRemaining.ToString(); rewindLogic.onRewindUsedCallback += UpdateUI; }
private void Start() { rewind = RewindManager.instance; inRange = false; otherObject = null; }
protected override void Initialize() { MyraEnvironment.Game = this; LoadConfig(); messages = new List <Message>(); _graphics.PreferredBackBufferWidth = 640; _graphics.PreferredBackBufferHeight = 320; _graphics.ApplyChanges(); isPaused = false; isRunning = false; InputHandler.SetBindings(new Dictionary <int, Keys> { { 0, Keys.X }, { 1, Keys.D1 }, { 2, Keys.D2 }, { 3, Keys.D3 }, { 4, Keys.Q }, { 5, Keys.W }, { 6, Keys.E }, { 7, Keys.A }, { 8, Keys.S }, { 9, Keys.D }, { 10, Keys.Z }, { 11, Keys.C }, { 12, Keys.D4 }, { 13, Keys.R }, { 14, Keys.F }, { 15, Keys.V } }); pixel = new Texture2D(_graphics.GraphicsDevice, 10, 10); Color[] data = new Color[10 * 10]; for (int i = 0; i < data.Length; i++) { data[i] = Color.White; } pixel.SetData(data); TargetElapsedTime = TimeSpan.FromSeconds(1f / cyclesPerSecond); IsFixedTimeStep = true; cpu = new CPU(); cpu.hiResMode = true; cpu.Reset(); apu = new APU(); apu.Initialize(); SavestateManager.Initialize(savestateSlots); RewindManager.Initialize(rewindBufferSize); ShowMessage("Welcome to Crispy! Press F3 to load a game, or press F1 for help.", 9999); base.Initialize(); }
private void HandleFunctionKeys() { InputHandler.HandleKeypress(loadRomKey, () => { if (!fileDialogVisible && !helpMenuVisible) { fileDialog = new FileDialog(FileDialogMode.OpenFile) { Filter = "*.ch8" }; fileDialog.Closed += (s, a) => { isPaused = false; fileDialogVisible = false; if (!fileDialog.Result) { return; } currentRomPath = fileDialog.FilePath; cpu.Reset(); currentRom = File.ReadAllBytes(currentRomPath); currentRomName = Path.GetFileNameWithoutExtension(currentRomPath); SavestateManager.romName = currentRomName; cpu.LoadProgram(currentRom); RewindManager.Initialize(rewindBufferSize); isRunning = true; RemoveAllMessages(); }; isPaused = true; fileDialog.ShowModal(); fileDialogVisible = true; } else if (fileDialogVisible) { fileDialog.Close(); fileDialogVisible = false; } }); InputHandler.HandleKeypress(resetKey, () => { if (isRunning && !helpMenuVisible && !fileDialogVisible) { cpu.Reset(); cpu.LoadProgram(currentRom); ShowMessage("Reset", 2.5f); } }); InputHandler.HandleKeypress(nextSaveStateSlotKey, () => { if (isRunning && !helpMenuVisible && !fileDialogVisible) { SavestateManager.SelectNextSlot(); ShowMessage($"Selected slot {SavestateManager.selectedSlot} {(SavestateManager.IsSelectedSlotEmpty() ? "(empty)" : "")}", 2.5f); } }); InputHandler.HandleKeypress(previousSaveStateSlotKey, () => { if (isRunning && !helpMenuVisible && !fileDialogVisible) { SavestateManager.SelectPreviousSlot(); ShowMessage($"Selected slot {SavestateManager.selectedSlot} {(SavestateManager.IsSelectedSlotEmpty() ? "(empty)" : "")}", 2.5f); } }); InputHandler.HandleKeypress(helpKey, () => { if (!helpMenuVisible && !fileDialogVisible) { helpMenu = new Window { Title = "Welcome to Crispy!" }; Label text = new Label { Text = readme, VerticalAlignment = VerticalAlignment.Stretch, Wrap = true }; ScrollViewer scrollViewer = new ScrollViewer { Content = text }; helpMenu.Content = scrollViewer; helpMenu.Closed += (s, a) => { helpMenuVisible = false; }; helpMenu.ShowModal(); helpMenuVisible = true; } else if (helpMenuVisible) { helpMenu.Close(); helpMenuVisible = false; } }); InputHandler.HandleKeypress(screenshotKey, () => { if (!helpMenuVisible && !fileDialogVisible) { string screenshotPath = $"Screenshots/{DateTime.Now.ToString().Replace("/", "-").Replace(":", "-")}.jpg"; if (!File.Exists(screenshotPath)) { try { File.Create(screenshotPath).Dispose(); } catch (DirectoryNotFoundException) { Directory.CreateDirectory(Path.GetDirectoryName(screenshotPath)); } } using (Texture2D screenshot = TakeScreenshot()) SaveScreenshot(screenshot, File.OpenWrite(screenshotPath)); ShowMessage($"Saved screenshot as {Path.GetFileName(screenshotPath)}", 2.5f); } }); }
private void OnDestroy() { RewindManager.Remove(getId(), prefab); }
private void Rewind() { RewindManager.Rewind(); }
private void Save() { RewindManager.SaveCurrentState(); }