public ScreenFlash(Color color, float fadeInTime, float fadeOutTime, float peakOpacity) { _color = color; _maxTime = fadeInTime + fadeOutTime; _opacity = new EaseBuilder(); _opacity.AddPoint(0f, 0f, EaseFunction.Linear); _opacity.AddPoint(fadeInTime, peakOpacity, EaseFunction.EaseQuadIn); _opacity.AddPoint(_maxTime, 0, EaseFunction.EaseQuadIn); }
public StarplateBeaconIntroEvent(Vector2 center) { _center = center; // set up the screen shaders _ripContrastData = new BeaconShaderData(new Ref <Effect>(SpiritMod.Instance.GetEffect("Effects/EventShaders")), "BeaconStartScreen"); _burstData = new BeaconShaderData(new Ref <Effect>(SpiritMod.Instance.GetEffect("Effects/EventShaders")), "BeaconBurstScreen"); Filters.Scene["SpiritMod:Event-BeaconDistortion"] = new Filter(_ripContrastData, (EffectPriority)20); Filters.Scene["SpiritMod:Event-BeaconBurst"] = new Filter(_burstData, (EffectPriority)35); const float BURST_START = BUILDUP_LENGTH + PAUSE_TIME; // screen rip animation _screenRipStrength = new EaseBuilder(); _screenRipStrength.AddPoint(0f, 0f, EaseFunction.Linear); _screenRipStrength.AddPoint(BUILDUP_LENGTH * 0.9f, 1f, EaseFunction.EaseCubicIn); _screenRipStrength.AddPoint(BURST_START, 1f, EaseFunction.EaseCubicIn); _screenRipStrength.AddPoint(BURST_START + BURST_LENGTH, 0f, EaseFunction.EaseCubicOut); // contrast animation _contrastBubbleStrength = new EaseBuilder(); _contrastBubbleStrength.AddPoint(0f, 0f, EaseFunction.Linear); _contrastBubbleStrength.AddPoint(BUILDUP_LENGTH, 1f, new PolynomialEase(x => x * x * x * x * x * x * x)); _contrastBubbleStrength.AddPoint(BURST_START, 1f, EaseFunction.Linear); _contrastBubbleStrength.AddPoint(BURST_START + BURST_LENGTH, 0f, EaseFunction.EaseQuadOut); // burst radius animation _burstRadius = new EaseBuilder(); _burstRadius.AddPoint(0f, 0f, EaseFunction.Linear); _burstRadius.AddPoint(BURST_START, 0f, EaseFunction.Linear); _burstRadius.AddPoint(BURST_START + BURST_LENGTH, BURST_RADIUS, EaseFunction.EaseQuadOut); // burst strength animation _burstStrength = new EaseBuilder(); _burstStrength.AddPoint(0f, 0f, EaseFunction.Linear); _burstStrength.AddPoint(BURST_START - 0.01f, 0f, EaseFunction.Linear); _burstStrength.AddPoint(BURST_START, 1f, EaseFunction.Linear); _burstStrength.AddPoint(BURST_START + BURST_LENGTH, 0f, EaseFunction.EaseQuadOut); // overlay opacity animation _overlayOpacity = new EaseBuilder(); _overlayOpacity.AddPoint(0f, 0f, EaseFunction.Linear); _overlayOpacity.AddPoint(BURST_START, 1f, EaseFunction.EaseCubicIn); _overlayOpacity.AddPoint(BURST_START + 0.2f, 0f, EaseFunction.Linear); // particle mass animation _particleMass = new EaseBuilder(); _particleMass.AddPoint(0f, 1f, EaseFunction.Linear); _particleMass.AddPoint(BUILDUP_LENGTH, 5000000000000000f, EaseFunction.EaseQuadIn); // particle spawn count animation _particleSpawnCount = new EaseBuilder(); _particleSpawnCount.AddPoint(0f, 7.5f, EaseFunction.Linear); _particleSpawnCount.AddPoint(BUILDUP_LENGTH, 6f, EaseFunction.EaseQuarticIn); // flash opacity animation _flashOpacity = new EaseBuilder(); _flashOpacity.AddPoint(0f, 0f, EaseFunction.Linear); _flashOpacity.AddPoint(BURST_START - 0.01f, 0f, EaseFunction.Linear); _flashOpacity.AddPoint(BURST_START + 0.04f, 1f, EaseFunction.Linear); _flashOpacity.AddPoint(BURST_START + 0.2f, 0f, EaseFunction.EaseQuadOut); _particles = new List <Particle>(); // add a sound to the queue AddToQueue(new ExpressionController(0, (int frame) => { if (Main.netMode != NetmodeID.Server) { Main.PlaySound(SpiritMod.Instance.GetLegacySoundSlot(SoundType.Custom, "Sounds/StarplateBlast"), center); } })); // add a screen shake event to the queue AddToQueue(new ExpressionController(BUILDUP_LENGTH + PAUSE_TIME, (int frame) => { EventManager.PlayEvent(new ScreenShake(20f, 0.6f)); })); // add the summoning to the queue AddToQueue(new ExpressionController(BUILDUP_LENGTH + PAUSE_TIME + BURST_LENGTH - 0.5f, (int frame) => { Player player = Main.LocalPlayer; if (Main.netMode != NetmodeID.MultiplayerClient) { Main.NewText("The Starplate Voyager has awoken!", 175, 75, 255, true); int npcID = NPC.NewNPC((int)player.Center.X, (int)player.Center.Y, ModContent.NPCType <SteamRaiderHead>()); Main.npc[npcID].Center = player.Center - new Vector2(600, 600); Main.npc[npcID].netUpdate2 = true; } else { SpiritMod.WriteToPacket(SpiritMod.Instance.GetPacket(), (byte)MessageType.BossSpawnFromClient, (byte)player.whoAmI, (int)ModContent.NPCType <SteamRaiderHead>(), "The Starplate Voyager has awoken!", (int)player.Center.X - 600, (int)player.Center.Y - 600).Send(-1); } })); }