public void TestScreenEffect() { var type = ScreenEffectType.FadeOut; var data = new ScreenEffect(type).Compile(); Span <byte> expectedData = stackalloc byte[28]; var pos = 0; expectedData.Write(ref pos, (byte)0x70); // Packet ID expectedData.Write(ref pos, (byte)0x04); // Effect #if NO_LOCAL_INIT expectedData.Write(ref pos, 0); expectedData.Write(ref pos, 0); #else pos += 8; #endif expectedData.Write(ref pos, (ushort)type); // Screen Effect Type #if NO_LOCAL_INIT expectedData.Write(ref pos, 0); expectedData.Write(ref pos, 0); expectedData.Write(ref pos, 0); expectedData.Write(ref pos, 0); #endif AssertThat.Equal(data, expectedData); }
public static void UnRegisterScreenEffect(ScreenEffect effect) { if (m_ActiveScreenEffects != null) { m_ActiveScreenEffects.Remove(effect); } }
private static string ScreenEffectToString(ScreenEffect screenEffect) { if (screenEffect >= 0 && (int)screenEffect <= Eff.Length) { return(Eff[(int)screenEffect]); } return("INVALID"); }
private static ScreenEffectItem CreateScreenEffectItem(string name, ScreenEffect type) { var manager = new ResourceManager("_2027.Properties.Resources", Assembly.GetExecutingAssembly()); return(new ScreenEffectItem { Name = manager.GetString("Effects_" + name), Effect = type }); }
private static string EffectToString(ScreenEffect screenEffect) { if ((int)screenEffect >= 0 && (int)screenEffect <= _effects.Length) { return(_effects[(int)screenEffect]); } return("INVALID"); }
public void StopEffect(string name) { ScreenEffect effect = currentEffects.FirstOrDefault(e => e.name == name); if (effect != null) { effect.Stop(); } }
public void PlayEffect(string name) { ScreenEffect effect = Effects.First(e => e.name == name); ScreenEffect copy = Instantiate(effect); copy.name = name; currentEffects.Add(copy); copy.Play(); }
private void ScreenEffect_Finished(ScreenEffect screenEffect) { Assert.IsTrue(_screenEffects.Contains(screenEffect)); if (_screenEffects.Contains(screenEffect)) { _screenEffects.Remove(screenEffect); Destroy(screenEffect); } }
public static void RegisterScreenEffect(ScreenEffect effect) { if (m_ActiveScreenEffects == null) { m_ActiveScreenEffects = new List <ScreenEffect>(); } if (!m_ActiveScreenEffects.Contains(effect)) { m_ActiveScreenEffects.Add(effect); } }
public void TestScreenEffect(ScreenEffectType screenType) { var expected = new ScreenEffect(screenType).Compile(); using var ns = PacketTestUtilities.CreateTestNetState(); ns.SendScreenEffect(screenType); var result = ns.SendPipe.Reader.TryRead(); AssertThat.Equal(result.Buffer[0].AsSpan(0), expected); }
public Rufus(int x) { position.X = x; position.Y = limitBaseY; special = 0; maxSpecial = 1000; pointAcress = 1; screenFX = new ScreenEffect(); emitter = new Emitter(".\\Sprites\\effects\\particles\\miniStar", position, 3, 3); }
private void Awake() { // wordAudio = GetComponent<AudioSource>(); if (defaultWordEffect != null) { wordAudio.clip = defaultWordEffect; } _screenEffect = GameObject.Find("Main Camera").GetComponent <ScreenEffect>(); _shake = GameObject.Find("Main Camera").GetComponent <Shake>(); _shaderChange = GameObject.Find("WhiteImage").GetComponent <ShaderChange>(); _screenEffect.enabled = false; _shake.enabled = false; //_shaderChange = GameObject.Find("WhiteImage").GetComponent<ShaderChange>(); }
void Awake() { // pauseMenu = GameObject.Find("PauseCanvas"); GetComponent <CanvasGroup> ().alpha = 0; fadeIn = true; // cam = GameObject.Find("Cam").GetComponent <ScreenEffect> (); blueLightSlider = transform.Find("BlueLightSlider").GetComponent <Slider> (); blueLightSlider.value = gameSettings.blueLightControl; blueLightSlider.onValueChanged.AddListener(delegate { ValueChangeCheck(); }); }
void OnTriggerStay2D(Collider2D col) { //If triggered object's name is same as our quad name if (col.gameObject.name == gameObject.name) { ScreenEffect.ShowEffect(thisImg.color, 1); //Draw screen effect; GameManager.PlaySFX(GameManager.audioSource, winSFX[Random.Range(0, winSFX.Length)]); //Play win sound effect; GameManager.score++; //Add score; gameObject.SetActive(false); //Disable object; } else { if (!GameManager.isGameOver) { GameManager.PlaySFX(GameManager.audioSource, loseSFX[Random.Range(0, loseSFX.Length)]); //Play lose sound effect; } GameManager.isGameOver = true; //Set gameover to true; } }
public override bool InteractWith(Actor source, Controller instigator = null) { ScreenEffect sc = source.GetComponentInChildren <ScreenEffect>(); if (!sc) { return(false); } sc.imageEffectMat = effects[_effectIndex]; _effectIndex++; if (_effectIndex >= effects.Length) { _effectIndex = 0; } return(true); }
public void KillPlayer(string deathMessage) { if (netClient.Status != NetConnectionStatus.Connected) { return; } PlaySound(InfiniminerSound.Death); playerPosition = new Vector3(randGen.Next(2, 62), 66, randGen.Next(2, 62)); playerVelocity = Vector3.Zero; playerDead = true; screenEffect = ScreenEffect.Death; screenEffectCounter = 0; NetBuffer msgBuffer = netClient.CreateBuffer(); msgBuffer.Write((byte)InfiniminerMessage.PlayerDead); msgBuffer.Write(deathMessage); netClient.SendMessage(msgBuffer, NetChannel.ReliableUnordered); }
//public void Teleport() //{ // float x = (float)randGen.NextDouble() * 74 - 5; // float z = (float)randGen.NextDouble() * 74 - 5; // //playerPosition = playerHomeBlock + new Vector3(0.5f, 3, 0.5f); // playerPosition = new Vector3(x, 74, z); // screenEffect = ScreenEffect.Teleport; // screenEffectCounter = 0; // UpdateCamera(); //} // Version used during updates. public void UpdateCamera(GameTime gameTime) { // If we have a gameTime object, apply screen jitter. if (screenEffect == ScreenEffect.Explosion) { if (gameTime != null) { screenEffectCounter += gameTime.ElapsedGameTime.TotalSeconds; // For 0 to 2, shake the camera. if (screenEffectCounter < 2) { Vector3 newPosition = playerCamera.Position; newPosition.X += (float)(2 - screenEffectCounter) * (float)(randGen.NextDouble() - 0.5) * 0.5f; newPosition.Y += (float)(2 - screenEffectCounter) * (float)(randGen.NextDouble() - 0.5) * 0.5f; newPosition.Z += (float)(2 - screenEffectCounter) * (float)(randGen.NextDouble() - 0.5) * 0.5f; if (!blockEngine.SolidAtPointForPlayer(newPosition) && (newPosition - playerPosition).Length() < 0.7f) { playerCamera.Position = newPosition; } } // For 2 to 3, move the camera back. else if (screenEffectCounter < 3) { Vector3 lerpVector = playerPosition - playerCamera.Position; playerCamera.Position += 0.5f * lerpVector; } else { screenEffect = ScreenEffect.None; screenEffectCounter = 0; playerCamera.Position = playerPosition; } } } else { playerCamera.Position = playerPosition; } playerCamera.Update(); }
public static void Start(ScreenEffect effectName, int duration = 0, bool looped = false) { API.StartScreenEffect(EffectToString(effectName), duration, looped); }
public void RespawnPlayer() { if (netClient.Status != NetConnectionStatus.Connected) return; playerDead = false; // Respawn a few blocks above a safe position above altitude 0. bool positionFound = false; // Try 20 times; use a potentially invalid position if we fail. for (int i = 0; i < 20; i++) { // Pick a random starting point. Vector3 startPos = new Vector3(randGen.Next(2, 62), 63, randGen.Next(2, 62)); // See if this is a safe place to drop. for (startPos.Y = 63; startPos.Y >= 54; startPos.Y--) { BlockType blockType = blockEngine.BlockAtPoint(startPos); if (blockType == BlockType.Lava) break; else if (blockType != BlockType.None) { // We have found a valid place to spawn, so spawn a few above it. playerPosition = startPos + Vector3.UnitY * 5; positionFound = true; break; } } // If we found a position, no need to try anymore! if (positionFound) break; } // If we failed to find a spawn point, drop randomly. if (!positionFound) playerPosition = new Vector3(randGen.Next(2, 62), 66, randGen.Next(2, 62)); // Drop the player on the middle of the block, not at the corner. playerPosition += new Vector3(0.5f, 0, 0.5f); // Zero out velocity and reset camera and screen effects. playerVelocity = Vector3.Zero; screenEffect = ScreenEffect.None; screenEffectCounter = 0; UpdateCamera(); // Tell the server we have respawned. NetBuffer msgBuffer = netClient.CreateBuffer(); msgBuffer.Write((byte)InfiniminerMessage.PlayerAlive); netClient.SendMessage(msgBuffer, NetChannel.ReliableUnordered); }
public static bool IsActive(ScreenEffect screenEffect) { return(Function.Call <bool>(Hash._GET_SCREEN_EFFECT_IS_ACTIVE, EffectToString(screenEffect))); }
public static void Stop(ScreenEffect screenEffect) { Function.Call(Hash._STOP_SCREEN_EFFECT, EffectToString(screenEffect)); }
public void KillPlayer(string deathMessage) { if (netClient.Status != NetConnectionStatus.Connected) return; PlaySound(InfiniminerSound.Death); // playerPosition = new Vector3(randGen.Next(2, 62), 66, randGen.Next(2, 62)); playerVelocity = Vector3.Zero; playerDead = true; allowRespawn = false; screenEffect = ScreenEffect.Death; screenEffectCounter = 0; Content[5] = 0; NetBuffer msgBuffer = netClient.CreateBuffer(); msgBuffer.Write((byte)InfiniminerMessage.PlayerDead); msgBuffer.Write(deathMessage); netClient.SendMessage(msgBuffer, NetChannel.ReliableUnordered); // msgBuffer = netClient.CreateBuffer(); // msgBuffer.Write((byte)InfiniminerMessage.PlayerRespawn); // netClient.SendMessage(msgBuffer, NetChannel.ReliableUnordered); }
private static ScreenEffectItem CreateScreenEffectItem(string name, ScreenEffect type) { var manager = new ResourceManager("_2027.Properties.Resources", Assembly.GetExecutingAssembly()); return new ScreenEffectItem { Name = manager.GetString("Effects_" + name), Effect = type }; }
/// <summary> /// Starts applying the specified effect to the screen. /// </summary> /// <param name="effectName">The <see cref="ScreenEffect"/> to start playing.</param> /// <param name="duration">The duration of the effect in milliseconds or zero to use the default length.</param> /// <param name="looped">If <c>true</c> the effect won't stop until <see cref="Screen.StopEffect(ScreenEffect)"/> is called.</param> public static void StartEffect(ScreenEffect effectName, int duration = 0, bool looped = false) { Function.Call(Hash.ANIMPOSTFX_PLAY, _effects[(int)effectName], duration, looped); }
/// <summary> /// Stop a screen effect. /// </summary> /// <param name="effect"></param> public static void StopScreenEffect(ScreenEffect effect) { Function.Call(Hash._STOP_SCREEN_EFFECT, effect.ToString()); }
/// <summary> /// Start a screen effect. /// </summary> /// <param name="effect"></param> public static void StartScreenEffect(ScreenEffect effect) { Function.Call(Hash._START_SCREEN_EFFECT, effect.ToString(), 0, true); }
/// <summary> /// Stops applying the specified effect to the screen. /// </summary> /// <param name="effectName">The <see cref="ScreenEffect"/> to stop playing.</param> public static void StopEffect(ScreenEffect effectName) { Function.Call(Hash._STOP_SCREEN_EFFECT, _effects[(int)effectName]); }
//public void Teleport() //{ // float x = (float)randGen.NextDouble() * 74 - 5; // float z = (float)randGen.NextDouble() * 74 - 5; // //playerPosition = playerHomeBlock + new Vector3(0.5f, 3, 0.5f); // playerPosition = new Vector3(x, 74, z); // screenEffect = ScreenEffect.Teleport; // screenEffectCounter = 0; // UpdateCamera(); //} // Version used during updates. public void UpdateCamera(GameTime gameTime) { // If we have a gameTime object, apply screen jitter. if (screenEffect == ScreenEffect.Explosion) { if (gameTime != null) { screenEffectCounter += gameTime.ElapsedGameTime.TotalSeconds; // For 0 to 2, shake the camera. if (screenEffectCounter < 2) { Vector3 newPosition = playerCamera.Position; newPosition.X += (float)(2 - screenEffectCounter) * (float)(randGen.NextDouble() - 0.5) * 0.5f; newPosition.Y += (float)(2 - screenEffectCounter) * (float)(randGen.NextDouble() - 0.5) * 0.5f; newPosition.Z += (float)(2 - screenEffectCounter) * (float)(randGen.NextDouble() - 0.5) * 0.5f; if (!blockEngine.SolidAtPointForPlayer(newPosition) && (newPosition - playerPosition).Length() < 0.7f) playerCamera.Position = newPosition; } // For 2 to 3, move the camera back. else if (screenEffectCounter < 3) { Vector3 lerpVector = playerPosition - playerCamera.Position; playerCamera.Position += 0.5f * lerpVector; } else { screenEffect = ScreenEffect.None; screenEffectCounter = 0; playerCamera.Position = playerPosition; } } } else { playerCamera.Position = playerPosition; } playerCamera.Update(); }
//public void Teleport() //{ // float x = (float)randGen.NextDouble() * 74 - 5; // float z = (float)randGen.NextDouble() * 74 - 5; // //playerPosition = playerHomeBlock + new Vector3(0.5f, 3, 0.5f); // playerPosition = new Vector3(x, 74, z); // screenEffect = ScreenEffect.Teleport; // screenEffectCounter = 0; // UpdateCamera(); //} // Version used during updates. public void UpdateCamera(GameTime gameTime) { if (gameTime != null) if (colorDirection) { colorPulse += (float)gameTime.ElapsedGameTime.TotalSeconds; if (colorPulse > 1.5f) colorDirection = !colorDirection; } else { colorPulse -= (float)gameTime.ElapsedGameTime.TotalSeconds; if (colorPulse < 0.5f) colorDirection = !colorDirection; } // If we have a gameTime object, apply screen jitter. if (screenEffect == ScreenEffect.Explosion) { if (gameTime != null) { screenEffectCounter += gameTime.ElapsedGameTime.TotalSeconds; // For 0 to 2, shake the camera. if (screenEffectCounter < 2) { Vector3 newPosition = playerPosition; newPosition.X += (float)(2 - screenEffectCounter) * (float)(randGen.NextDouble() - 0.5) * 0.5f; newPosition.Y += (float)(2 - screenEffectCounter) * (float)(randGen.NextDouble() - 0.5) * 0.5f; newPosition.Z += (float)(2 - screenEffectCounter) * (float)(randGen.NextDouble() - 0.5) * 0.5f; if (!blockEngine.SolidAtPointForPlayer(newPosition) && (newPosition - playerPosition).Length() < 0.7f) playerCamera.Position = newPosition; } // For 2 to 3, move the camera back. else if (screenEffectCounter < 3) { Vector3 lerpVector = playerPosition - playerCamera.Position; playerCamera.Position += 0.5f * lerpVector; } else { screenEffect = ScreenEffect.None; screenEffectCounter = 0; playerCamera.Position = playerPosition; } } } if (screenEffect == ScreenEffect.Earthquake) { if (gameTime != null) { screenEffectCounter += gameTime.ElapsedGameTime.TotalSeconds; // For 0 to 2, shake the camera. if (screenEffectCounter < 2) { Vector3 newPosition = playerPosition; newPosition.X += (float)(2 - screenEffectCounter) * (float)(randGen.NextDouble() - 0.5) * 0.5f; newPosition.Y += (float)(2 - screenEffectCounter) * (float)(randGen.NextDouble() - 0.5) * 0.5f; newPosition.Z += (float)(2 - screenEffectCounter) * (float)(randGen.NextDouble() - 0.5) * 0.5f; if (!blockEngine.SolidAtPointForPlayer(newPosition) && (newPosition - playerPosition).Length() < 0.7f) playerCamera.Position = newPosition; } // For 2 to 3, move the camera back. else if (screenEffectCounter < 3) { Vector3 lerpVector = playerPosition - playerCamera.Position; playerCamera.Position += 0.5f * lerpVector; } else { screenEffect = ScreenEffect.None; screenEffectCounter = 0; playerCamera.Position = playerPosition; } } } else { playerCamera.Position = playerPosition; listenPos.Position = playerPosition; listenPos.Up = playerCamera.GetUpVector(); listenPos.Forward = playerCamera.GetLookVector(); //go through all sounds and sort positionally foreach (KeyValuePair<int, SoundEffectInstance> bPair in soundListInstance) { if (soundListEmitter.ContainsKey(bPair.Key)) { soundListInstance[bPair.Key].Apply3D(listenPos, soundListEmitter[bPair.Key]); } } // } playerCamera.Update(); }
public static void Stop(ScreenEffect screenEffect) { API.StopScreenEffect(EffectToString(screenEffect)); }
public static bool IsActive(ScreenEffect screenEffect) { return(API.GetScreenEffectIsActive(EffectToString(screenEffect))); }
public void RespawnPlayer() { if (netClient.Status != NetConnectionStatus.Connected) { return; } playerDead = false; // Respawn a few blocks above a safe position above altitude 0. bool positionFound = false; // Try 20 times; use a potentially invalid position if we fail. for (int i = 0; i < 20; i++) { // Pick a random starting point. Vector3 startPos = new Vector3(randGen.Next(2, 62), 63, randGen.Next(2, 62)); // See if this is a safe place to drop. for (startPos.Y = 63; startPos.Y >= 54; startPos.Y--) { BlockType blockType = blockEngine.BlockAtPoint(startPos); if (blockType == BlockType.Lava) { break; } else if (blockType != BlockType.None) { // We have found a valid place to spawn, so spawn a few above it. playerPosition = startPos + Vector3.UnitY * 5; positionFound = true; break; } } // If we found a position, no need to try anymore! if (positionFound) { break; } } // If we failed to find a spawn point, drop randomly. if (!positionFound) { playerPosition = new Vector3(randGen.Next(2, 62), 66, randGen.Next(2, 62)); } // Drop the player on the middle of the block, not at the corner. playerPosition += new Vector3(0.5f, 0, 0.5f); // Zero out velocity and reset camera and screen effects. playerVelocity = Vector3.Zero; screenEffect = ScreenEffect.None; screenEffectCounter = 0; UpdateCamera(); // Tell the server we have respawned. NetBuffer msgBuffer = netClient.CreateBuffer(); msgBuffer.Write((byte)InfiniminerMessage.PlayerAlive); netClient.SendMessage(msgBuffer, NetChannel.ReliableUnordered); }
/// <summary> /// Stops applying the specified effect to the screen. /// </summary> /// <param name="effectName">The <see cref="ScreenEffect"/> to stop playing.</param> public static void StopEffect(ScreenEffect effectName) { Function.Call(Hash.ANIMPOSTFX_STOP, _effects[(int)effectName]); }
public static void Start(ScreenEffect effectName, int duration = 0, bool looped = false) { Function.Call(Hash._START_SCREEN_EFFECT, EffectToString(effectName), duration, looped); }
// Screen Effects /// <summary> /// Gets a value indicating whether the specific screen effect is running. /// </summary> /// <param name="effectName">The <see cref="ScreenEffect"/> to check.</param> /// <returns><c>true</c> if the screen effect is active; otherwise, <c>false</c>.</returns> public static bool IsEffectActive(ScreenEffect effectName) { return(Function.Call <bool>(Hash.ANIMPOSTFX_IS_RUNNING, _effects[(int)effectName])); }
public void RespawnPlayer() { if (netClient.Status != NetConnectionStatus.Connected) return; if (allowRespawn == false) { NetBuffer msgBuffer = netClient.CreateBuffer(); msgBuffer.Write((byte)InfiniminerMessage.PlayerRespawn); netClient.SendMessage(msgBuffer, NetChannel.ReliableUnordered); return; } playerDead = false; // Zero out velocity and reset camera and screen effects. playerVelocity = Vector3.Zero; screenEffect = ScreenEffect.None; screenEffectCounter = 0; UpdateCamera(); forceStrength = 0.0f; allowRespawn = false; // Tell the server we have respawned. NetBuffer msgBufferb = netClient.CreateBuffer(); msgBufferb.Write((byte)InfiniminerMessage.PlayerAlive); netClient.SendMessage(msgBufferb, NetChannel.ReliableUnordered); }