IEnumerator flickering() { for(int i = 0; i < NumberOfFlickering; i++){ if(FlickeringObject[0].enabled){ FlickeringObject[0].enabled = false; FlickeringObject[1].enabled = true; } else { FlickeringObject[0].enabled = true; FlickeringObject[1].enabled = false; } yield return new WaitForSeconds(TimeOutFlickering); } FlickeringObject[0].enabled = false; FlickeringObject[1].enabled = true; state = MirrorState.collapse; yield return new WaitForSeconds(0); }
public void Start() { if (State != MirrorState.Connected) { throw new InvalidOperationException("You may call Start only if the state is Connected"); } if (_terminatePollingThread == null) { _terminatePollingThread = new ManualResetEvent(false); } else { _terminatePollingThread.Reset(); } f.WriteLine("Before Start"); _pollingThread = new Thread(pollingThreadProc) { IsBackground = true }; _pollingThread.Start(); f.WriteLine("After Start"); State = MirrorState.Running; }
public void Stop() { if (State != MirrorState.Running) { return; } if (_pollingThreadTerminated == null) { _pollingThreadTerminated = new ManualResetEvent(false); } else { _pollingThreadTerminated.Reset(); } // Terminate polling thread _terminatePollingThread.Set(); // Wait for it... if (!_pollingThreadTerminated.WaitOne(PollingThreadTerminationTimeout, false)) { _pollingThread.Abort(); } State = MirrorState.Connected; }
public void Unload() { if (State == MirrorState.Running) { Stop(); } if (State == MirrorState.Connected) { Disconnect(); } if (State != MirrorState.Loaded) { return; } var deviceMode = new DeviceMode(); deviceMode.dmSize = (short)Marshal.SizeOf(typeof(DeviceMode)); deviceMode.dmDriverExtra = 0; deviceMode.dmFields = (DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_POSITION); var device = new DisplayDevice(); device.CallBack = Marshal.SizeOf(device); deviceMode.dmDeviceName = string.Empty; uint deviceIndex = 0; while (EnumDisplayDevices(null, deviceIndex, ref device, 0)) { if (device.DeviceString.Equals(driverName)) { break; } deviceIndex++; } Debug.Assert(_registryKey != null); _registryKey.SetValue("Attach.ToDesktop", 0); _registryKey.Close(); deviceMode.dmDeviceName = driverMiniportName; if (deviceMode.dmBitsPerPel == 24) { deviceMode.dmBitsPerPel = 32; } #region This was CommitDisplayChanges SafeChangeDisplaySettingsEx(device.DeviceName, ref deviceMode, IntPtr.Zero, CDS_UPDATEREGISTRY, IntPtr.Zero); SafeChangeDisplaySettingsEx(device.DeviceName, ref deviceMode, IntPtr.Zero, 0, IntPtr.Zero); #endregion State = MirrorState.Idle; }
private void setStates() { states = new AbstractState[amountOfStates]; states[0] = new StatePlayVideo(0, VideoPlayer, "test1", 2000); states[1] = new MirrorState(1, VideoPlayer, "test2", 2000); //states[2] = new StatePlayVideo(2, VideoPlayer, "welding", 2000); amountOfStates = states.Length; }
void OnTriggerEnter2D(Collider2D other) { if(other.tag == "Player"){ state = MirrorState.flickering; foreach(GameObject player in players) player.GetComponent<PlayerController2DGeneric>().Block(); } }
public static void InitialMirrorState() { //Set up the default config of the mirror at startup //Mirror on MirrorState.SetMirrorOn(true); //Main weather display on MirrorState.SetWeatherOn(true); //Main weather set to today MirrorState.SetMainWeatherInfo(MirrorState.MAIN_WTHR_TODAY); //Weeks weather forecast off MirrorState.SetWeeksWeatherOn(false); }
public void Init() { this.Load(); bool result = mapSharedBuffers(); if (!result) { throw new Exception("初始化失败"); } State = MirrorState.Running; }
public bool Connect() { if (State != MirrorState.Loaded) throw new InvalidOperationException("You may call Connect only if the state is Loaded"); bool result = mapSharedBuffers(); // Adjusts _running if (result) { State = MirrorState.Connected; } return result; }
public void Disconnect() { //if (State == MirrorState.Running) // Stop(); if (State != MirrorState.Connected) { return; } unmapSharedBuffers(); State = MirrorState.Loaded; }
public void deplete() { Start(); state = MirrorState.deactivated; interactEnabled = false; string lvl = level.locationName.Substring(0, 6); ds.storeBoolValue(lvl + MirrorColor + "MirrorDepleted", true); deactivate(); interactIcon(); animAux.Break(); this.GetComponent <SphereCollider> ().center -= Vector3.down * 200; //this.GetComponent<SphereCollider> ().enabled = false; }
new public void Start() { if (started) { return; } started = true; if (isDark) { spawnControl = GameObject.Find("ShadowSpawnController").GetComponent <ShadowSpawnController> (); } master = GameObject.Find("MasterController").GetComponent <MasterControllerScript> (); level = GameObject.Find("LevelController").GetComponent <LevelControllerScript> (); ds = master.getStorage(); camManager = GameObject.Find("CameraLerp").GetComponent <CameraManager> (); player = GameObject.Find("Player").GetComponent <PlayerScript> (); opacity = 0.0f; state = MirrorState.deactivated; glowMat = glow.GetComponent <Renderer> ().material; light.color = new Color(color.r, color.g, color.b, 1.0f); light.intensity = 0.0f; elapsedTime = 0.0f; mat = objectWithMaterial.GetComponent <Renderer> ().material; mat.SetColor("_EmissionColor", new Color(0, 0, 0, 0)); glowMat.SetColor("_TintColor", new Color(0, 0, 0, 0)); autopilotState = PlayerAutopilotState.idle; string lvl = level.locationName.Substring(0, 6); bool depleted = ds.retrieveBoolValue(lvl + MirrorColor + "MirrorDepleted"); if (depleted) { interactEnabled = false; animAux.Broken(); state = MirrorState.deactivated; } else { bool activated = ds.retrieveBoolValue(level.locationName + MirrorColor + "MirrorActivated"); if (activated) { state = MirrorState.activated; } //activate (); } }
public bool Connect() { if (State != MirrorState.Loaded) { throw new InvalidOperationException("You may call Connect only if the state is Loaded"); } bool result = mapSharedBuffers(); // Adjusts _running if (result) { State = MirrorState.Connected; } return(result); }
public void activate() { if (state == MirrorState.activated) { return; } elapsedTime = 0.0f; state = MirrorState.activating; ds.storeBoolValue(level.locationName + MirrorColor + "MirrorActivated", true); interactEnabled = true; interactIcon(); if (activationSound) { level.playSound(activationSound); } }
public bool Connect() { if (State != MirrorState.Loaded) { throw new InvalidOperationException("You may call Connect only if the state is Loaded"); } bool result = mapSharedBuffers(); // Adjusts _running f.WriteLine("Before Connect"); if (result) { f.WriteLine("Connected"); State = MirrorState.Connected; } f.WriteLine("After Connect"); return(result); }
IEnumerator flickering() { for(int i = 0; i < NumberOfFlickering; i++){ if(players[0].transform.localScale.x == 1) players[0].transform.localScale = new Vector3(1.5f, 1, 1); else players[0].transform.localScale = new Vector3(1, 1, 1); yield return new WaitForSeconds(TimeOutFlickering); } players[0].transform.localScale = new Vector3(1.5f, 1, 1); state = MirrorState.end; yield return new WaitForSeconds(0); }
public void Release() { unmapSharedBuffers(); var deviceMode = new DeviceMode(); deviceMode.dmSize = (short)Marshal.SizeOf(typeof(DeviceMode)); deviceMode.dmDriverExtra = 0; deviceMode.dmFields = (DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_POSITION); var device = new DisplayDevice(); device.CallBack = Marshal.SizeOf(device); deviceMode.dmDeviceName = string.Empty; uint deviceIndex = 0; while (EnumDisplayDevices(null, deviceIndex, ref device, 0)) { if (device.DeviceString.Equals(driverName)) { break; } deviceIndex++; } deviceMode.dmDeviceName = driverMiniportName; if (deviceMode.dmBitsPerPel == 24) { deviceMode.dmBitsPerPel = 32; } State = MirrorState.Idle; #region This was CommitDisplayChanges SafeChangeDisplaySettingsEx(device.DeviceName, ref deviceMode, IntPtr.Zero, CDS_UPDATEREGISTRY, IntPtr.Zero); SafeChangeDisplaySettingsEx(device.DeviceName, ref deviceMode, IntPtr.Zero, 0, IntPtr.Zero); #endregion }
public bool Load() { if (State != MirrorState.Idle) { logger.Add("Invalid Operation Exception Thrown at Load"); throw new InvalidOperationException("You may call Load only if the state is Idle"); } var device = new DisplayDevice(); var deviceMode = new DeviceMode { dmDriverExtra = 0 }; device.CallBack = Marshal.SizeOf(device); deviceMode.dmSize = (short)Marshal.SizeOf(deviceMode); deviceMode.dmBitsPerPel = Screen.PrimaryScreen.BitsPerPixel; if (deviceMode.dmBitsPerPel == 24) { deviceMode.dmBitsPerPel = 32; } _bitmapBpp = deviceMode.dmBitsPerPel; deviceMode.dmDeviceName = string.Empty; deviceMode.dmFields = (DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_POSITION); _bitmapHeight = deviceMode.dmPelsHeight = Screen.PrimaryScreen.Bounds.Height; _bitmapWidth = deviceMode.dmPelsWidth = Screen.PrimaryScreen.Bounds.Width; logger.Add("driver res " + Screen.PrimaryScreen.Bounds.ToString()); bool deviceFound; uint deviceIndex = 0; while (deviceFound = EnumDisplayDevices(null, deviceIndex, ref device, 0)) { if (device.DeviceString == driverName) { break; } deviceIndex++; } if (!deviceFound) { return(false); } driverInstanceName = device.DeviceName; _registryKey = Registry.LocalMachine.OpenSubKey(driverRegistryPath, true); if (_registryKey != null) { _registryKey = _registryKey.CreateSubKey(driverMiniportName); } else { throw new Exception("Couldn't open registry key"); } if (_registryKey != null) { _registryKey = _registryKey.CreateSubKey(driverDeviceNumber); } else { throw new Exception("Couldn't open registry key"); } // _registryKey.SetValue("Cap.DfbBackingMode", 0); // _registryKey.SetValue("Order.BltCopyBits.Enabled", 1); _registryKey.SetValue("Attach.ToDesktop", 1); #region This was CommitDisplayChanges SafeChangeDisplaySettingsEx(device.DeviceName, ref deviceMode, IntPtr.Zero, CDS_UPDATEREGISTRY, IntPtr.Zero); SafeChangeDisplaySettingsEx(device.DeviceName, ref deviceMode, IntPtr.Zero, 0, IntPtr.Zero); #endregion State = MirrorState.Loaded; return(true); }
IEnumerator SetEndStateWithDelay() { yield return new WaitForSeconds(1); state = MirrorState.end; }
public void deactivate() { elapsedTime = 0.0f; state = MirrorState.deactivated; ds.storeBoolValue(level.locationName + MirrorColor + "MirrorActivated", false); }
public void Unload() { if (State == MirrorState.Running) Stop(); if (State == MirrorState.Connected) Disconnect(); if (State != MirrorState.Loaded) return; var deviceMode = new DeviceMode(); deviceMode.dmSize = (short)Marshal.SizeOf(typeof(DeviceMode)); deviceMode.dmDriverExtra = 0; deviceMode.dmFields = (DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_POSITION); var device = new DisplayDevice(); device.CallBack = Marshal.SizeOf(device); deviceMode.dmDeviceName = string.Empty; uint deviceIndex = 0; while (EnumDisplayDevices(null, deviceIndex, ref device, 0)) { if (device.DeviceString.Equals(driverName)) break; deviceIndex++; } Debug.Assert(_registryKey != null); _registryKey.SetValue("Attach.ToDesktop", 0); _registryKey.Close(); deviceMode.dmDeviceName = driverMiniportName; if (deviceMode.dmBitsPerPel == 24) deviceMode.dmBitsPerPel = 32; #region This was CommitDisplayChanges SafeChangeDisplaySettingsEx(device.DeviceName, ref deviceMode, IntPtr.Zero, CDS_UPDATEREGISTRY, IntPtr.Zero); SafeChangeDisplaySettingsEx(device.DeviceName, ref deviceMode, IntPtr.Zero, 0, IntPtr.Zero); #endregion State = MirrorState.Idle; }
public void Stop() { if (State != MirrorState.Running) return; if (_pollingThreadTerminated == null) _pollingThreadTerminated = new ManualResetEvent(false); else _pollingThreadTerminated.Reset(); // Terminate polling thread _terminatePollingThread.Set(); // Wait for it... if (!_pollingThreadTerminated.WaitOne(PollingThreadTerminationTimeout, false)) _pollingThread.Abort(); State = MirrorState.Connected; }
public void Start() { if (State != MirrorState.Connected) throw new InvalidOperationException("You may call Start only if the state is Connected"); if (_terminatePollingThread == null) _terminatePollingThread = new ManualResetEvent(false); else _terminatePollingThread.Reset(); _pollingThread = new Thread(pollingThreadProc) {IsBackground = true}; _pollingThread.Start(); State = MirrorState.Running; }
public bool Load() { if (State != MirrorState.Idle) throw new InvalidOperationException("You may call Load only if the state is Idle"); var device = new DisplayDevice(); var deviceMode = new DeviceMode { dmDriverExtra = 0 }; device.CallBack = Marshal.SizeOf(device); deviceMode.dmSize = (short)Marshal.SizeOf(deviceMode); deviceMode.dmBitsPerPel = Screen.PrimaryScreen.BitsPerPixel; if (deviceMode.dmBitsPerPel == 24) deviceMode.dmBitsPerPel = 32; _bitmapBpp = deviceMode.dmBitsPerPel; deviceMode.dmDeviceName = string.Empty; deviceMode.dmFields = (DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_POSITION); _bitmapHeight = deviceMode.dmPelsHeight = Screen.PrimaryScreen.Bounds.Height; _bitmapWidth = deviceMode.dmPelsWidth = Screen.PrimaryScreen.Bounds.Width; bool deviceFound; uint deviceIndex = 0; while (deviceFound = EnumDisplayDevices(null, deviceIndex, ref device, 0)) { if (device.DeviceString == driverName) break; deviceIndex++; } if (!deviceFound) return false; driverInstanceName = device.DeviceName; _registryKey = Registry.LocalMachine.OpenSubKey(driverRegistryPath, true); if (_registryKey != null) _registryKey = _registryKey.CreateSubKey(driverMiniportName); else throw new Exception("Couldn't open registry key"); if (_registryKey != null) _registryKey = _registryKey.CreateSubKey(driverDeviceNumber); else throw new Exception("Couldn't open registry key"); // _registryKey.SetValue("Cap.DfbBackingMode", 0); // _registryKey.SetValue("Order.BltCopyBits.Enabled", 1); _registryKey.SetValue("Attach.ToDesktop", 1); #region This was CommitDisplayChanges SafeChangeDisplaySettingsEx(device.DeviceName, ref deviceMode, IntPtr.Zero, CDS_UPDATEREGISTRY, IntPtr.Zero); SafeChangeDisplaySettingsEx(device.DeviceName, ref deviceMode, IntPtr.Zero, 0, IntPtr.Zero); #endregion State = MirrorState.Loaded; return true; }
public void Disconnect() { if (State == MirrorState.Running) Stop(); if (State != MirrorState.Connected) return; unmapSharedBuffers(); State = MirrorState.Loaded; }
new void Update() { if (autopilotState == PlayerAutopilotState.idle) { } if (autopilotState == PlayerAutopilotState.seeking1) { if (!isWaitingForActionToComplete) { //hGlow.glow (); //player._wa_autopilotTo (this, this.transform.position - new Vector3 (0, 0, 5.02f)); player.setOrientation(4); // looking back autopilotState = PlayerAutopilotState.seeking2; } } if (autopilotState == PlayerAutopilotState.seeking2) { if (!isWaitingForActionToComplete) { if (hGlow != null) { hGlow.glow(); } if (energyBurstPrefab != null) // if mirror is light mirror { HeroReflection.GetComponent <Renderer> ().material.mainTexture = HeroImage; HeroReflection.GetComponent <Renderer> ().enabled = true; HeroReflection.GetComponent <TextureFader> ().fadeIn(); //camManager.moveRelative (new Vector3(0, -0.3f, 8.0f)); player.blockControls(); autopilotState = PlayerAutopilotState.waitingForBurst; GameObject go = (GameObject)Instantiate(energyBurstPrefab, this.gameObject.transform.position, Quaternion.Euler(0, 0, 0)); energyBurst = go.GetComponent <MirrorHeroEnergyBurst> (); energyBurst.mirrorGO = this.gameObject; energyBurst.playerGO = player.gameObject; ParticleSystem s = go.GetComponent <ParticleSystem> (); s.startColor = new Color(color.r, color.g, color.b, 1.0f); energyBurst.initialize(); energyBurst._wm_go(); this.GetComponent <SphereCollider> ().center = Vector3.down * 200; this.state = MirrorState.deactivated; this.interactEnabled = false; deactivate(); substate = 0; //animAux.Break (); not yet } else // if mirror is dark mirror { player.blockControls(); spawnControl.callShadows(this.transform.position); autopilotState = PlayerAutopilotState.seeking3; elapsedTime = 0.0f; } } } if (autopilotState == PlayerAutopilotState.waitingForBurst) { if (substate == 0) { if (energyBurst != null && energyBurst.state > 2) { //player.unblockControls (); Destroy(energyBurst.gameObject); if (hGlow != null) { hGlow.glow(); } camManager.moveToOriginalPosition(); HeroReflection.GetComponent <TextureFader> ().fadeOut(); //autopilotState = PlayerAutopilotState.idle; ++substate; elapsedTime = 0.0f; } } if (substate == 1) { elapsedTime += Time.deltaTime; if (elapsedTime > 2.0f) { ++substate; //HeroReflection.GetComponent<Renderer> ().enabled = false; //this.GetComponent<SphereCollider> ().enabled = false; animAux.Break(); string lvl = level.locationName.Substring(0, 6); ds.storeBoolValue(lvl + MirrorColor + "MirrorDepleted", true); //ds.storeBoolValue ("CurrentLevelHasHero" + HeroType, true); ds.storeBoolValue("Has" + lvl + HeroType, true); ds.storeBoolValue("Has" + lvl + HeroType + (indexHero - 1), true); ds.storeIntValue("Has" + lvl + HeroType, indexHero - 1); elapsedTime = 0.0f; } } if (substate == 2) { elapsedTime += Time.deltaTime; if (elapsedTime > 2.0f) { if (NewHeroProgram != null) { NewHeroProgram.startProgram(0); } else { player.unblockControls(); } autopilotState = PlayerAutopilotState.idle; level.mcRef.saveGame(true); } } } if (autopilotState == PlayerAutopilotState.seeking3) { elapsedTime += Time.deltaTime; if (elapsedTime > 12.0f) { player.enterMirror(); elapsedTime = 0.0f; autopilotState = PlayerAutopilotState.seeking4; } } if (autopilotState == PlayerAutopilotState.seeking4) { elapsedTime += Time.deltaTime; if (elapsedTime > 1.9f && !grabbingFrame) { level.grabFrame(); grabbingFrame = true; } if (elapsedTime > 2.0f) { level.storeStringValue("ReturnLocation", level.locationName); level.storeStringValue("CurrentMirror", level.locationName + "DarkMirrorActivated"); level.storeStringValue("CurrentLevel", level.locationName); level.loadScene("WordFight"); } } if (state == MirrorState.deactivated) { interactEnabled = false; glowMat.SetColor("_TintColor", new Color(0, 0, 0, 0)); } if (state == MirrorState.activating) { elapsedTime += Time.deltaTime; if (elapsedTime > initialDelay) { state = MirrorState.activated; elapsedTime = 0.0f; } } if (state == MirrorState.activated) { elapsedTime += Time.deltaTime; glowMat.SetColor("_TintColor", new Color(color.r, color.g, color.b, opacity * (1.0f + Mathf.Cos(tremoloAngle) / 12.0f))); tremoloAngle += tremoloAngleSpeed * Time.deltaTime; if (opacity < 0.19f) { opacity += opacitySpeed * Time.deltaTime; } light.intensity = 0.5f + 0.5f * Mathf.Sin(elapsedTime * angleSpeed); mat.SetColor("_EmissionColor", color * light.intensity / 8.0f); } }