private void NewSwitcheDistribution(TouchSwitch last) { TouchSwitch newSwitch; // Make sure not to get the same switch twice in a row while ((newSwitch = switches[rand.Next(switches.Count)]) == last) { ; } ActivateSwitch(newSwitch); // After 10 seconds, have a 50% chance to spawn a second switch if (level.RawTimeActive - startTime >= 10 && rand.NextFloat() > 0.5f) { TouchSwitch newSwitch2; // Make sure not to get the same switch twice in a row and not to get two switches in the same spot while ((newSwitch2 = switches[rand.Next(switches.Count)]) == last || newSwitch2 == newSwitch) { ; } ActivateSwitch(newSwitch2); } foreach (Vector2 switchPos in switchesOn) { MultiplayerSingleton.Instance.Send(new MinigameVector2 { vec = switchPos, extra = 1 }); } }
protected void DeactivateSwitch(TouchSwitch ts) { switchesOn.Remove(ts.Position); ts.Visible = false; ts.Active = false; ts.Collidable = false; }
public static Entity Load(Level level, LevelData levelData, Vector2 offset, EntityData entityData) { string flag = entityData.Attr("flag"); if (level.Session.GetFlag(flag) || level.Session.GetFlag(flag + "_switch" + entityData.ID)) { // moving touch switches can't be persistent, but we can very much spawn a flag touch switch instead! Vector2[] nodes = entityData.Nodes; Vector2 origPosition = entityData.Position; entityData.Position = nodes[nodes.Length - 1]; FlagTouchSwitch flagTouchSwitch = new FlagTouchSwitch(entityData, offset); entityData.Position = origPosition; return(flagTouchSwitch); } else { // build the moving touch switch TouchSwitch movingTouchSwitch = (TouchSwitch)Activator.CreateInstance(movingTouchSwitchType, new object[] { entityData.NodesOffset(offset), entityData, offset }); // save its attributes as DynData DynData <TouchSwitch> switchData = new DynData <TouchSwitch>(movingTouchSwitch); switchData["flag"] = entityData.Attr("flag"); switchData["id"] = entityData.ID; switchData["persistent"] = entityData.Bool("persistent", false); switchData["movingColor"] = Calc.HexToColor(entityData.Attr("movingColor", "FF8080")); // these attributes actually exist in TouchSwitch and as such, they work! switchData["inactiveColor"] = Calc.HexToColor(entityData.Attr("inactiveColor", "5FCDE4")); switchData["activeColor"] = Calc.HexToColor(entityData.Attr("activeColor", "FFFFFF")); switchData["finishColor"] = Calc.HexToColor(entityData.Attr("finishColor", "F141DF")); switchData["P_RecoloredFire"] = new ParticleType(TouchSwitch.P_Fire) { Color = switchData.Get <Color>("finishColor") }; // set up the icon string iconAttribute = entityData.Attr("icon", "vanilla"); Sprite icon = new Sprite(GFX.Game, iconAttribute == "vanilla" ? "objects/touchswitch/icon" : $"objects/MaxHelpingHand/flagTouchSwitch/{iconAttribute}/icon"); icon.Add("idle", "", 0f, default(int)); icon.Add("spin", "", 0.1f, new Chooser <string>("spin", 1f), 0, 1, 2, 3, 4, 5); icon.Play("spin"); icon.Color = switchData.Get <Color>("inactiveColor"); icon.CenterOrigin(); movingTouchSwitch.Remove(movingTouchSwitch.Get <Sprite>()); movingTouchSwitch.Add(icon); movingTouchSwitchIcon.SetValue(movingTouchSwitch, icon); switchData["icon"] = icon; // collect the list of flag touch switches in the room as soon as the entity is awake, like regular flag touch switches. movingTouchSwitch.Add(new TouchSwitchListAttacher(entityData.Attr("flag"))); return(movingTouchSwitch); } }
protected void ActivateSwitch(TouchSwitch ts) { switchesOn.Add(ts.Position); ts.Visible = true; ts.Active = true; ts.Collidable = true; Add(new Coroutine(ActivateSwitchCoroutine(ts))); MultiplayerSingleton.Instance.Send(new MinigameVector2 { vec = ts.Position, extra = 1 }); }
protected IEnumerator ActivateSwitchCoroutine(TouchSwitch ts) { DynamicData switchData = new DynamicData(ts); switchData.Get <SoundSource>("touchSfx").Play("event:/game/general/touchswitch_any"); switchData.Get <Sprite>("icon").Rate = 4; float ease = 1; while (ease > 0) { yield return(null); switchData.Get <Sprite>("icon").Rate = 1 + 3 * ease; ease -= Engine.DeltaTime; } switchData.Get <Sprite>("icon").Rate = 1; }
public void CollectSwitch(Vector2 pos) { switchCount++; GameData.Instance.minigameStatus[GameData.Instance.realPlayerID] = switchCount; TouchSwitch ts = switches.Find((s) => s.Position == pos); DeactivateSwitch(ts); for (int i = 0; i < 32; i++) { float num = Calc.Random.NextFloat((float)Math.PI * 2f); level.Particles.Emit(TouchSwitch.P_FireWhite, ts.Position + Calc.AngleToVector(num, 6f), num); } MultiplayerSingleton.Instance.Send(new MinigameStatus { results = switchCount }); MultiplayerSingleton.Instance.Send(new MinigameVector2 { vec = pos, extra = -1 }); if (GameData.Instance.gnetHost && switchesOn.Count == 0) { NewSwitcheDistribution(ts); } }
private static void onTouchSwitchUpdate(On.Celeste.TouchSwitch.orig_Update orig, TouchSwitch self) { if (self.GetType().ToString() == "Celeste.Mod.OutbackHelper.MovingTouchSwitch") { DynData <TouchSwitch> selfData = new DynData <TouchSwitch>(self); if (selfData.Data.ContainsKey("P_RecoloredFire")) { ParticleType oldParticle = TouchSwitch.P_Fire; TouchSwitch.P_Fire = selfData.Get <ParticleType>("P_RecoloredFire"); orig(self); TouchSwitch.P_Fire = oldParticle; return; } } orig(self); }
private void OverlayEntities(MapElement entities, Bitmap map, VirtualMap <char> solids, bool background) { CassetteBlock.Blocks.Clear(); using (Graphics g = Graphics.FromImage(map)) { List <Entity> ents = new List <Entity>(); for (int i = entities.Children.Count - 1; i >= 0; i--) { MapElement child = entities.Children[i]; Entity entity = null; if (child.Name.IndexOf("spikes", StringComparison.OrdinalIgnoreCase) == 0) { entity = background ? Spikes.FromElement(child) : null; } else if (child.Name.IndexOf("triggerSpikes", StringComparison.OrdinalIgnoreCase) == 0) { entity = background ? TriggerSpikes.FromElement(child) : null; } else if (child.Name.IndexOf("strawberry", StringComparison.OrdinalIgnoreCase) == 0) { entity = background ? Strawberry.FromElement(child) : null; } else if (child.Name.Equals("goldenBerry", StringComparison.OrdinalIgnoreCase)) { entity = background ? Strawberry.FromElement(child) : null; } else if (child.Name.Equals("redBlocks", StringComparison.OrdinalIgnoreCase)) { entity = background ? ClutterBlock.FromElement(child) : null; } else if (child.Name.Equals("greenBlocks", StringComparison.OrdinalIgnoreCase)) { entity = background ? ClutterBlock.FromElement(child) : null; } else if (child.Name.Equals("yellowBlocks", StringComparison.OrdinalIgnoreCase)) { entity = background ? ClutterBlock.FromElement(child) : null; } else if (child.Name.Equals("clutterCabinet", StringComparison.OrdinalIgnoreCase)) { entity = background ? ClutterCabinet.FromElement(child) : null; } else if (child.Name.Equals("introCar", StringComparison.OrdinalIgnoreCase)) { entity = background ? IntroCar.FromElement(child) : null; } else if (child.Name.Equals("clothesLine", StringComparison.OrdinalIgnoreCase)) { entity = background ? ClothesLine.FromElement(child) : null; } else if (child.Name.Equals("colorSwitch", StringComparison.OrdinalIgnoreCase)) { entity = background ? ColorSwitch.FromElement(child) : null; } else if (child.Name.Equals("memorialTextController", StringComparison.OrdinalIgnoreCase)) { entity = background ? Strawberry.FromElement(child) : null; } else if (child.Name.Equals("bonfire", StringComparison.OrdinalIgnoreCase)) { entity = background ? Bonfire.FromElement(child) : null; } else if (child.Name.Equals("trapDoor", StringComparison.OrdinalIgnoreCase)) { entity = background ? TrapDoor.FromElement(child) : null; } else if (child.Name.Equals("movingPlatform", StringComparison.OrdinalIgnoreCase)) { entity = background ? MovingPlatform.FromElement(child) : null; } else if (child.Name.Equals("sinkingPlatform", StringComparison.OrdinalIgnoreCase)) { entity = background ? SinkingPlatform.FromElement(child) : null; } else if (child.Name.Equals("clutterDoor", StringComparison.OrdinalIgnoreCase)) { entity = background ? ClutterDoor.FromElement(child) : null; } else if (child.Name.Equals("bridge", StringComparison.OrdinalIgnoreCase)) { entity = background ? Bridge.FromElement(child) : null; } else if (child.Name.Equals("bridgeFixed", StringComparison.OrdinalIgnoreCase)) { entity = background ? BridgeFixed.FromElement(child) : null; } else if (child.Name.Equals("jumpThru", StringComparison.OrdinalIgnoreCase)) { entity = background ? JumpThru.FromElement(child) : null; } else if (child.Name.Equals("door", StringComparison.OrdinalIgnoreCase)) { entity = background ? Door.FromElement(child) : null; } else if (child.Name.Equals("blockField", StringComparison.OrdinalIgnoreCase)) { entity = background ? BlockField.FromElement(child) : null; } else if (child.Name.Equals("lamp", StringComparison.OrdinalIgnoreCase)) { entity = background ? Lamp.FromElement(child) : null; } else if (child.Name.Equals("hahaha", StringComparison.OrdinalIgnoreCase)) { entity = background ? Haha.FromElement(child) : null; } else if (child.Name.Equals("waterFall", StringComparison.OrdinalIgnoreCase)) { entity = background ? WaterFall.FromElement(child) : null; } else if (child.Name.Equals("water", StringComparison.OrdinalIgnoreCase)) { entity = background ? Water.FromElement(child) : null; } else if (child.Name.Equals("key", StringComparison.OrdinalIgnoreCase)) { entity = background ? Key.FromElement(child) : null; } else if (child.Name.Equals("resortLantern", StringComparison.OrdinalIgnoreCase)) { entity = background ? ResortLantern.FromElement(child) : null; } else if (child.Name.Equals("bird", StringComparison.OrdinalIgnoreCase)) { entity = background ? Bird.FromElement(child) : null; } else if (child.Name.Equals("memorial", StringComparison.OrdinalIgnoreCase)) { entity = background ? Memorial.FromElement(child) : null; } else if (child.Name.Equals("player", StringComparison.OrdinalIgnoreCase)) { entity = background ? PlayerSpawn.FromElement(child) : null; } else if (child.Name.Equals("zipMover", StringComparison.OrdinalIgnoreCase)) { entity = background ? ZipMover.FromElement(child) : null; } else if (child.Name.Equals("wire", StringComparison.OrdinalIgnoreCase)) { entity = background ? Wire.FromElement(child) : null; } else if (child.Name.Equals("crumbleBlock", StringComparison.OrdinalIgnoreCase)) { entity = background ? CrumbleBlock.FromElement(child) : null; } else if (child.Name.Equals("refill", StringComparison.OrdinalIgnoreCase)) { entity = background ? Refill.FromElement(child) : null; } else if (child.Name.Equals("spring", StringComparison.OrdinalIgnoreCase)) { entity = background ? Spring.FromElement(child) : null; } else if (child.Name.Equals("fakeWall", StringComparison.OrdinalIgnoreCase)) { entity = background ? FakeWall.FromElement(child) : null; } else if (child.Name.Equals("exitBlock", StringComparison.OrdinalIgnoreCase)) { entity = background ? FakeWall.FromElement(child) : null; } else if (child.Name.Equals("lightBeam", StringComparison.OrdinalIgnoreCase)) { entity = background ? LightBeam.FromElement(child) : null; } else if (child.Name.Equals("cobweb", StringComparison.OrdinalIgnoreCase)) { entity = background ? Cobweb.FromElement(child) : null; } else if (child.Name.Equals("cassette", StringComparison.OrdinalIgnoreCase)) { entity = background ? Cassette.FromElement(child) : null; } else if (child.Name.Equals("flutterBird", StringComparison.OrdinalIgnoreCase)) { entity = background ? FlutterBird.FromElement(child) : null; } else if (child.Name.Equals("checkpoint", StringComparison.OrdinalIgnoreCase)) { entity = background ? Checkpoint.FromElement(child) : null; } else if (child.Name.Equals("fallingBlock", StringComparison.OrdinalIgnoreCase)) { entity = background ? FallingBlock.FromElement(child) : null; } else if (child.Name.Equals("introCrusher", StringComparison.OrdinalIgnoreCase)) { entity = background ? FallingBlock.FromElement(child) : null; } else if (child.Name.Equals("cassetteBlock", StringComparison.OrdinalIgnoreCase)) { entity = background ? CassetteBlock.FromElement(child) : null; } else if (child.Name.Equals("dashBlock", StringComparison.OrdinalIgnoreCase)) { entity = background ? DashBlock.FromElement(child) : null; } else if (child.Name.Equals("coverupWall", StringComparison.OrdinalIgnoreCase)) { entity = background ? CoverupWall.FromElement(child) : null; } else if (child.Name.Equals("npc", StringComparison.OrdinalIgnoreCase)) { entity = background ? NPC.FromElement(child) : null; } else if (child.Name.Equals("birdForsakenCityGem", StringComparison.OrdinalIgnoreCase)) { entity = background ? ForsakenCityGem.FromElement(child) : null; } else if (child.Name.Equals("soundSource", StringComparison.OrdinalIgnoreCase)) { entity = background ? SoundSource.FromElement(child) : null; } else if (child.Name.Equals("friendlyGhost", StringComparison.OrdinalIgnoreCase)) { entity = background ? FriendlyGhost.FromElement(child) : null; } else if (child.Name.Equals("floatingDebris", StringComparison.OrdinalIgnoreCase)) { entity = background ? FloatingDebris.FromElement(child) : null; } else if (child.Name.Equals("hangingLamp", StringComparison.OrdinalIgnoreCase)) { entity = background ? HangingLamp.FromElement(child) : null; } else if (child.Name.Equals("lockBlock", StringComparison.OrdinalIgnoreCase)) { entity = background ? LockBlock.FromElement(child) : null; } else if (child.Name.Equals("heartGem", StringComparison.OrdinalIgnoreCase)) { entity = background ? HeartGem.FromElement(child) : null; } else if (child.Name.Equals("blackGem", StringComparison.OrdinalIgnoreCase)) { entity = background ? HeartGem.FromElement(child) : null; } else if (child.Name.Equals("dreamMirror", StringComparison.OrdinalIgnoreCase)) { entity = background ? DreamMirror.FromElement(child) : null; } else if (child.Name.Equals("darkChaser", StringComparison.OrdinalIgnoreCase)) { entity = background ? DarkChaser.FromElement(child) : null; } else if (child.Name.Equals("dreamBlock", StringComparison.OrdinalIgnoreCase)) { entity = background ? DreamBlock.FromElement(child) : null; } else if (child.Name.Equals("touchSwitch", StringComparison.OrdinalIgnoreCase)) { entity = background ? TouchSwitch.FromElement(child) : null; } else if (child.Name.Equals("switchGate", StringComparison.OrdinalIgnoreCase)) { entity = background ? SwitchGate.FromElement(child) : null; } else if (child.Name.Equals("invisibleBarrier", StringComparison.OrdinalIgnoreCase)) { entity = background ? InvisibleBarrier.FromElement(child) : null; } else if (child.Name.Equals("payphone", StringComparison.OrdinalIgnoreCase)) { entity = background ? Payphone.FromElement(child) : null; } else if (child.Name.Equals("spinner", StringComparison.OrdinalIgnoreCase)) { entity = background ? Spinner.FromElement(child) : null; } else if (child.Name.Equals("rotateSpinner", StringComparison.OrdinalIgnoreCase)) { entity = background ? RotateSpinner.FromElement(child) : null; } else if (child.Name.Equals("trackSpinner", StringComparison.OrdinalIgnoreCase)) { entity = background ? TrackSpinner.FromElement(child) : null; } else if (child.Name.Equals("towerViewer", StringComparison.OrdinalIgnoreCase)) { entity = background ? TowerViewer.FromElement(child) : null; } else if (child.Name.Equals("foregroundDebris", StringComparison.OrdinalIgnoreCase)) { entity = !background?ForegroundDebris.FromElement(child) : null; } else if (background) { Console.WriteLine(child.Name); } if (entity != null) { ents.Add(entity); } } ents.Sort(delegate(Entity one, Entity two) { int comp = two.Depth.CompareTo(one.Depth); return(comp == 0 ? one.ID.CompareTo(two.ID) : comp); }); for (int i = 0; i < ents.Count; i++) { Entity entity = ents[i]; entity.Render(g, solids); } } }
private static void TouchSwitch_TurnOn(On.Celeste.TouchSwitch.orig_TurnOn orig, TouchSwitch self) { if (MadelinePartyModule.IsSIDMadelineParty(self.SceneAs <Level>().Session.Area.SID)) { MinigameSwitchGatherer gatherer; if ((gatherer = self.Scene.Tracker.GetEntity <MinigameSwitchGatherer>()) != null) { if (switchesOn.Contains(self.Position)) { gatherer.CollectSwitch(self.Position); } else { throw new Exception("Hit switch that shouldn't be on"); } return; } } orig(self); }