public void AddTeleport(TeleportInfo info)
 {
     Teleports.Add(info);
 }
Exemple #2
0
 private void OnTeleport(TeleportInfo info)
 {
     if (teleporting) return;
     teleporting = true;
     Action<string> setpos = (s) => { };
     if (info.TargetScreen == _currentScreen.Screen.Name)
     {
         setpos = (state) =>
         {
             PlayerPos.SetPosition(new Point(info.To.X, info.To.Y));
             (Player.GetComponent<StateComponent>()).StateChanged -= setpos;
             Player.SendMessage(new StateMessage(null, "TeleportEnd"));
             teleporting = false;
             (Player.GetComponent<MovementComponent>()).CanMove = true;
         };
     }
     else
     {
         setpos = state =>
         {
             (Player.GetComponent<SpriteComponent>()).Visible = false;
             (Player.GetComponent<StateComponent>()).StateChanged -= setpos;
             Engine.Instance.FadeTransition(
                 () =>
             {
                 StopScreen();
                 ChangeScreen(screens[info.TargetScreen]);
                 PlayerPos.SetPosition(new Point(info.To.X, info.To.Y)); // do it here so drawing is correct for fade-in
             }, () =>
             {
                 (Player.GetComponent<SpriteComponent>()).Visible = true;
                 Player.SendMessage(new StateMessage(null, "TeleportEnd"));
                 (Player.GetComponent<MovementComponent>()).CanMove = true;
                 teleporting = false;
             });
         };
     }
     (Player.GetComponent<MovementComponent>()).CanMove = false;
     Player.SendMessage(new StateMessage(null, "TeleportBlink"));
     (Player.GetComponent<StateComponent>()).StateChanged += setpos;
 }