/// <summary> /// A method called when a player enters a section exit. /// </summary> /// <param name="player"> /// The player that has entered the section exit. /// </param> public void PlayerEntered(Sprite player) { state = (SourceBehavior != ExitSourceBehavior.Door) ? ExitTransitionState.ExitEffectInProgress : (IsMultiplayer) ? (Owner.PlayerList.Count > 0) ? ExitTransitionState.MultiplayerWait : ExitTransitionState.IrisIn : ExitTransitionState.IrisIn; Owner.RemoveSpriteOnNextFrame(player); PlayersInExit.Enqueue(player); Owner.CameraSystem.IsFrozen = true; if (SourceBehavior != ExitSourceBehavior.Door) { AudioPlaybackEngine.Instance.PlaySound(warpSound, (sender, e) => { }); Direction shiftDirection = GetSourceShiftDirection(); exitEffect = new ExitEffect(player, Hitbox, shiftDirection); exitEffect.EffectCompletedEvent += ExitEffect_EffectCompletedEvent; } }
private void ExitEffect_EffectCompletedEvent(object sender, Sprite e) { exitEffect = null; if (!IsMultiplayer) { StartIrisIn(); } else { if (Owner.PlayerList.Count > 0) { Owner.ExitLock = this; Owner.CameraSystem.IsFrozen = true; remainingMultiplayerWaitFrames = (int)(DefaultMultiplayerWait * 60f); state = ExitTransitionState.MultiplayerWait; } else { remainingMultiplayerWaitFrames = 0; StartIrisIn(); } } }
/// <summary> /// Queues a sequence of players to emerge from a section exit. /// </summary> /// <param name="players"></param> public void Emerge(IEnumerable<Sprite> players) { state = ExitTransitionState.ExitEffectInProgress; players.ForEach(p => PlayersInExit.Enqueue(p)); var first = PlayersInExit.Dequeue(); PlacePlayerToEmerge(first); exitEffect = new ExitEffect(first, GetEmergeHitbox(first), GetDestinationShiftDirection()); AudioPlaybackEngine.Instance.PlaySound(warpSound, (sender, e) => { }); EventHandler<Sprite> recursiveHandler = null; recursiveHandler = (sender, e) => { if (PlayersInExit.Count > 0) { Owner.AddSprite(e); e.Owner = Owner; var next = PlayersInExit.Dequeue(); exitEffect = new ExitEffect(next, GetEmergeHitbox(next), GetDestinationShiftDirection()); exitEffect.EffectCompletedEvent += recursiveHandler; AudioPlaybackEngine.Instance.PlaySound(warpSound, (s, args) => { }); } else { Owner.AddSprite(e); e.Owner = Owner; Owner.CameraSystem.IsFrozen = false; exitEffect = null; } }; exitEffect.EffectCompletedEvent += recursiveHandler; }