public void ChangeState(GameState next, TransitionPlayer transitionPlayer) { if (next == null) { throw new ArgumentNullException("next"); } this.next = next; // Aloitetaan transition ja hypätään pois. if (transitionPlayer != null) { this.transitionPlayer = transitionPlayer; transitionPlayer.Next = next; transitionPlayer.Current = current; transitionPlayer.Start(); return; } // Swapatana statet suoraan. SwapStates(); }
private void start_ButtonPressed(GuiButtonEventArgs e, object sender) { BeatEmUpGame game = this.game as BeatEmUpGame; GameStateManager gameStateManager = game.StateManager; // Alustetaan transition. Texture2D blank = game.Content.Load <Texture2D>("blank"); Fade fadeIn = new Fade(Color.Black, blank, new Rectangle(0, 0, 1280, 720), FadeType.In, 10, 10, 255); Fade fadeOut = new Fade(Color.Black, blank, new Rectangle(0, 0, 1280, 720), FadeType.Out, 10, 10, 0); fadeOut.StateFininshed += (s, a) => { gameStateManager.SwapStates(); }; // Alustetaan player. TransitionPlayer player = new TransitionPlayer(); player.AddTransition(fadeOut); player.AddTransition(fadeIn); gameStateManager.ChangeState(new HowManyPlayersState(), player); }
public override void Update(GameTime gameTime) { UpdateAlpha(); if (alpha < 0) { fading = true; } if (alpha >= 255 && fading) { // Reset alpha ja fadetaan pois. alpha = 255; fading = false; current = textures.FirstOrDefault(); textures.Remove(current); if (current == null || skip) { GameStateManager gameStateManager = Game.StateManager; // Alustetaan transition. Texture2D blank = Game.Content.Load <Texture2D>("blank"); Fade fadeIn = new Fade(Color.Black, blank, new Rectangle(0, 0, 1280, 720), FadeType.In, 10, 10, alpha); Fade fadeOut = new Fade(Color.Black, blank, new Rectangle(0, 0, 1280, 720), FadeType.Out, 10, 10, 255); fadeOut.StateFininshed += (s, a) => { gameStateManager.SwapStates(); }; // Alustetaan player. TransitionPlayer player = new TransitionPlayer(); player.AddTransition(fadeOut); player.AddTransition(fadeIn); GameStateManager.ChangeState(new MainMenuState(), player); keyboardListener.RemoveMapping("Skip"); if (gamepadListenenr != null) { gamepadListenenr.RemoveMapping("Skip"); } } } }
protected override void OnInitialize() { List <GameObject> players = Game.FindGameObjects(p => p.Name.Contains("Player")); GameObject map = Game.CreateGameObjectFromName("Shop1"); map.Enable(); map.StartBehaviours(); map.InitializeComponents(); foreach (var player in players) { player.Game.View.Position = Vector2.Zero; player.Position = new Vector2(500, 600f); playerScale = player.FirstComponentOfType <SpriterComponent <Texture2D> >().Scale; player.FirstComponentOfType <SpriterComponent <Texture2D> >().Scale = playerScale + 0.2f; player.Enable(); player.Show(); } Game.EnableSortedDraw(); Game.KeyboardListener.Map("Go Back", args => { if (args.InputState != InputState.Released) { return; } // Alustetaan transition. Texture2D blank = Game.Content.Load <Texture2D>("blank"); Fade fadeIn = new Fade(Color.Black, blank, new Rectangle(0, 0, 1280, 720), FadeType.In, 1, 10, 255); Fade fadeOut = new Fade(Color.Black, blank, new Rectangle(0, 0, 1280, 720), FadeType.Out, 10, 10, 0); TransitionPlayer p = new TransitionPlayer(); p.AddTransition(fadeOut); p.AddTransition(fadeIn); fadeOut.StateFininshed += (sender, eventArgs) => Game.StateManager.PopStates(); Game.StateManager.PopState(p); Game.KeyboardListener.RemoveMapping("Go Back"); }, Keys.X); }
public void DebugEnterShop(InputEventArgs args) { // Alustetaan transition. Texture2D blank = Owner.Game.Content.Load <Texture2D>("blank"); Fade fadeIn = new Fade(Color.Black, blank, new Rectangle(0, 0, 1280, 720), FadeType.In, 1, 10, 255); Fade fadeOut = new Fade(Color.Black, blank, new Rectangle(0, 0, 1280, 720), FadeType.Out, 10, 10, 0); TransitionPlayer p = new TransitionPlayer(); p.AddTransition(fadeOut); p.AddTransition(fadeIn); fadeOut.StateFininshed += (sender, eventArgs) => Owner.Game.StateManager.PushStates(); Owner.Game.StateManager.PushState(new ShopState(Owner.Game.StateManager.Current), p); }
public override void Update(GameTime gameTime) { if (current != null) { current.Update(gameTime); } if (transitionPlayer != null) { transitionPlayer.Update(gameTime); if (transitionPlayer.IsFininshed) { transitionPlayer = null; } } }
public void PushState(GameState next, TransitionPlayer tp) { if (next == null) { throw new ArgumentNullException("next"); } this.next = next; if (tp != null) { this.transitionPlayer = tp; transitionPlayer.Next = next; transitionPlayer.Current = current; transitionPlayer.Start(); return; } PushStates(); }
void Apply(TransformSnap snap, float duration) { if (!Definition.RootBone) { return; } if (snap == Current) { return; } Current = snap; Transition = new TransitionPlayer <TransformSnap>( new Transition <TransformSnap>(TransformSnap.Lerp).AddKey(snap, duration), TransformSnap.Snap(Definition.RootBone) ); }
private void Select(InputEventArgs args) { if (currentNode != null) { if (!(currentNode.FirstBehaviourOfType <MapNode>().MapName == "City1.xml")) { return; } } if (args.InputState == InputState.Pressed) { RemoveMappings(); GameStateManager gameStateManager = Game.StateManager; // Alustetaan transition. Texture2D blank = Game.Content.Load <Texture2D>("blank"); Fade fadeIn = new Fade(Color.Black, blank, new Rectangle(0, 0, 1280, 720), FadeType.In, 1, 10, 255); Fade fadeOut = new Fade(Color.Black, blank, new Rectangle(0, 0, 1280, 720), FadeType.Out, 10, 10, 0); fadeOut.StateFininshed += (s, a) => { gameStateManager.SwapStates(); }; fadeIn.StateFininshed += (s, a) => { Game.EnableSortedDraw(); }; // Alustetaan player. TransitionPlayer player = new TransitionPlayer(); player.AddTransition(fadeOut); player.AddTransition(fadeIn); GameplayState gameplayState = new GameplayState(currentNode.FirstBehaviourOfType <MapNode>().MapName); GameStateManager.ChangeState(gameplayState, player); selector = null; } }
public void PopState(TransitionPlayer player) { // TODO eventit jne if (previous == null) { return; } if (player != null) { transitionPlayer = player; transitionPlayer.Current = current; transitionPlayer.Next = previous; transitionPlayer.Start(); return; } PopStates(); }
private void Blink() { player = new TransitionPlayer(CreateBlinkTransition(), VRM.GetValue(BlendShapePreset.Blink)); }