private void CreateIntroAnimations() { // This is a teleport icon that comes in from the top. var menuSelectorIntroFrameAnimation = new Frame2DAnimation(MenuConstants.MenuSelectorIntroImages, new Tuple <float, int>[] { new Tuple <float, int>(0.0f, 0), new Tuple <float, int>(MenuConstants.IntroTeleportDuration, 1), new Tuple <float, int>(MenuConstants.IntroTeleportDuration + 0.05f, 2), new Tuple <float, int>(MenuConstants.IntroTeleportDuration + 0.07f, 3), new Tuple <float, int>(MenuConstants.IntroTeleportDuration + 0.09f, 4), new Tuple <float, int>(MenuConstants.IntroTeleportDuration + 0.11f, 5), new Tuple <float, int>(MenuConstants.IntroTeleportDuration + 0.13f, 6), new Tuple <float, int>(MenuConstants.IntroTeleportDuration + 0.15f, 7), }); menuSelectorIntroFrameAnimation.OnComplete = () => { // Go back to the Blinking animation. UseSelectorEnterAnimation = false; this.menuSelectorFrameAnimation.TrueAnimation.Reset(); this.menuSelectorIntroAnimation = null; }; menuSelectorIntroFrameAnimation.LogName = "Selector Intro Frame Animation"; // Teleporting in, translating down to the first menu option (the default selected one). The total duration should match the Frame Animation, which has no easing specified, // up to the point of the first image (the teleport image). // Note that we offset the Y value so that the translation ends where our first Idle image needs to appear. This is done by simply subtracting the difference of the two frames and // centering, where the Intro Image is taller than the Idle Image. var menuStart = GetMenuSelectorPosition(this.selectedMenuOption, menuSelectorIntroFrameAnimation); var menuSelectorIntroTranslationAnimation = new TranslationAnimation(menuStart.X, -100, menuStart.X, menuStart.Y - (MenuConstants.MenuSelectorIntroImages[0].Height - MenuConstants.MenuSelectorIdleImages[0].Height) / 2, MenuConstants.IntroTeleportDuration); menuSelectorIntroTranslationAnimation.LogName = "Selector Intro Translation Animation"; menuSelectorIntroAnimation = new Frame2DTranslationAnimation(menuSelectorIntroFrameAnimation, menuSelectorIntroTranslationAnimation); }
private void TransitionToGame(object sender) { if (game.CurrentGameState == Game1.GameState.Started) { return; } float distance = 700; float time = 1.0f; mainStoryboard.Stop(); mainStoryboard.Clear(); mainStoryboard.OnCompleted += StartGame; mainStoryboard.AddAnimation(new TranslationAnimation(mainStoryboard, game.GameTitle, time, new Vector2(game.GameTitle.Left, game.GameTitle.Top - distance), false)); mainStoryboard.AddAnimation(new TranslationAnimation(mainStoryboard, game.Panel, time, new Vector2(game.Panel.Left, game.Panel.Top - distance), false)); mainStoryboard.AddAnimation(new TranslationAnimation(mainStoryboard, game.TextPlayerName, time, new Vector2(game.TextPlayerName.Left, game.TextPlayerName.Top - distance), false)); mainStoryboard.AddAnimation(new TranslationAnimation(mainStoryboard, game.TextRoomID, time, new Vector2(game.TextRoomID.Left, game.TextRoomID.Top - distance), false)); mainStoryboard.AddAnimation(new TranslationAnimation(mainStoryboard, game.TextBoxRoom, time, new Vector2(game.TextBoxRoom.Left, game.TextBoxRoom.Top - distance), false)); mainStoryboard.AddAnimation(new TranslationAnimation(mainStoryboard, game.TextBoxName, time, new Vector2(game.TextBoxName.Left, game.TextBoxName.Top - distance), false)); Animation anim = new TranslationAnimation(mainStoryboard, game.btnPlaySingle, time, new Vector2(game.btnPlaySingle.Left, game.btnPlaySingle.Top + distance), false); anim.SetGraphFunction(new LinearGraphFunction()); mainStoryboard.AddAnimation(anim); mainStoryboard.Start(); }
private void SelectDown(GameTime gameTime) { var newMenuItem = (MenuConstants.MenuOption) Math.Min((int)this.selectedMenuOption + 1, MenuConstants.MenuOptions.Count - 1); // If the menu isn't going to change, then do nothing. if (newMenuItem == this.selectedMenuOption) { return; } var menuStart = GetMenuSelectorPosition(this.selectedMenuOption); var menuEnd = GetMenuSelectorPosition(newMenuItem); menuSelectorUpDownTranslationAnimation = new TranslationAnimation(menuStart.X, menuStart.Y, menuEnd.X, menuEnd.Y, 0.0f, MenuConstants.MenuTranslationTotalDuration) { OnComplete = () => { this.selectedMenuOption = newMenuItem; this.menuSelectorUpDownTranslationAnimation = null; } }; menuSelectorUpDownTranslationAnimation.LogName = "Selector Down Translation"; menuSelectorUpDownTranslationAnimation.AddVerticalEasing(0.0f, 0.5f, 0.1f, 1.0f); menuSelectorUpDownTranslationAnimation.AddVerticalEasing(0.5f, 1.0f, 1.0f, 0.1f); }
private void SetAnimationsForAppTiles() { int Counter = 1; foreach (AppTile Tile in AppGrid.Children.OfType <AppTile>()) { int Duration = Counter * 80; AnimationCollection Col = new AnimationCollection(); OpacityAnimation O = new OpacityAnimation { Duration = new TimeSpan(0, 0, 0, 0, Duration), From = 0, To = 1.0 }; TranslationAnimation T = new TranslationAnimation { Duration = new TimeSpan(0, 0, 0, 0, Duration), From = "0, 80, 0", To = "0" }; Col.Add(O); Col.Add(T); Implicit.SetShowAnimations(Tile, Col); Counter++; } }
private void DuplicateCell(int i, int j, int x, int y) { visualState = VisualState.Transitioning; Gems[x, y] = new Gem(Gems[i, j]); Gems[x, y].i = x; Gems[x, y].j = y; this.gems.AddChild(Gems[x, y]); if (Gems[x, y].team == Gem.Team.Blue) { ScoreBlue++; } else { ScoreRed++; } Storyboard sb = new Storyboard(); Animation anim = new TranslationAnimation(sb, Gems[x, y].sprite, GameSettings.GemTranslationDuration, GetGemVisualPosition(x, y), false); sb.AddAnimation(anim); sb.argument = Gems[x, y]; sb.Start(); sb.OnCompleted += OnMoveCellCompleted; }
private void button1_Click(object sender, EventArgs e) { simpleAnimationControl1.animation.StartAnimalion(); simpleAnimationControl2.animation.StartAnimalion(); simpleAnimationControl3.animation.StartAnimalion(); animation = new TranslationAnimation(); animation.TranslateStart(simpleAnimationControl1, new Point(Width, Height)); }
private void TransitionToMenu(object sender) { if (game.CurrentGameState == Game1.GameState.NotStarted) { return; } game.ResetGame(); mainStoryboard.Stop(); mainStoryboard.Clear(); mainStoryboard.OnCompleted = null; float distance = -700; Vector2 scale = new Vector2(0.9f, 0.9f); Vector2 logoDistance = new Vector2(200, 10); Vector2 fromLogo = new Vector2(game.GameTitle.Left, game.GameTitle.Top); Vector2 toLogo = Vector2.Add(fromLogo, logoDistance); float time = 1.0f; Animation anim; anim = new TranslationAnimation(mainStoryboard, game.GameTitle, time, toLogo, false); anim.SetGraphFunction(new LinearGraphFunction()); mainStoryboard.AddAnimation(anim); mainStoryboard.AddAnimation(new TranslationAnimation(mainStoryboard, game.Panel, time, new Vector2(game.Panel.Left, game.Panel.Top - distance), false)); mainStoryboard.AddAnimation(new TranslationAnimation(mainStoryboard, game.TextPlayerName, time, new Vector2(game.TextPlayerName.Left, game.TextPlayerName.Top - distance), false)); mainStoryboard.AddAnimation(new TranslationAnimation(mainStoryboard, game.TextRoomID, time, new Vector2(game.TextRoomID.Left, game.TextRoomID.Top - distance), false)); mainStoryboard.AddAnimation(new TranslationAnimation(mainStoryboard, game.TextBoxRoom, time, new Vector2(game.TextBoxRoom.Left, game.TextBoxRoom.Top - distance), false)); mainStoryboard.AddAnimation(new TranslationAnimation(mainStoryboard, game.TextBoxName, time, new Vector2(game.TextBoxName.Left, game.TextBoxName.Top - distance), false)); anim = new TranslationAnimation(mainStoryboard, game.btnPlaySingle, time, new Vector2(game.btnPlaySingle.Left, game.btnPlaySingle.Top + distance), false); anim.SetGraphFunction(new LinearGraphFunction()); mainStoryboard.AddAnimation(anim); anim = new TranslationAnimation(mainStoryboard, game.btnPlayMulti, time, new Vector2(game.btnPlayMulti.Left, game.btnPlayMulti.Top + distance), false); anim.SetGraphFunction(new LinearGraphFunction()); mainStoryboard.AddAnimation(anim); anim = new TranslationAnimation(mainStoryboard, game.btnSetting, time, new Vector2(game.btnSetting.Left, game.btnSetting.Top + distance), false); anim.SetGraphFunction(new LinearGraphFunction()); mainStoryboard.AddAnimation(anim); anim = new TranslationAnimation(mainStoryboard, game.btnExit, time, new Vector2(game.btnExit.Left, game.btnExit.Top + 230), false); anim.SetGraphFunction(new LinearGraphFunction()); mainStoryboard.AddAnimation(anim); mainStoryboard.Start(); }
private void MoveCell(int i, int j, int x, int y) { visualState = VisualState.Transitioning; var toMove = Gems[i, j]; toMove.i = x; toMove.j = y; Gems[i, j] = null; Gems[x, y] = toMove; Storyboard sb = new Storyboard(); Animation anim = new TranslationAnimation(sb, toMove.sprite, GameSettings.GemTranslationDuration, GetGemVisualPosition(x, y), false); sb.AddAnimation(anim); sb.argument = Gems[x, y]; sb.Start(); sb.OnCompleted += OnMoveCellCompleted; }
public void OvertakeEnemies(Gem gem) { visualState = VisualState.Transitioning; List <Tile> adjacents = GetAdjacentCell(gem); if (adjacents.Count == 0) { OnOvertakeCompleted(this, null); return; } Storyboard sb = new Storyboard(); List <Gem> toFades = new List <Gem>(); foreach (Tile adjacent in adjacents) { Gem toOvertake = new Gem(gem); toOvertake.i = adjacent.i; toOvertake.j = adjacent.j; gems.AddChild(toOvertake); Gem toFade = Gems[adjacent.i, adjacent.j]; toFades.Add(toFade); Gems[toOvertake.i, toOvertake.j] = toOvertake; Animation anim = new TranslationAnimation(sb, toOvertake.sprite, GameSettings.GemTranslationDuration, GetGemVisualPosition(toOvertake.i, toOvertake.j), false); sb.AddAnimation(anim); anim = new ColorAnimation(sb, toFade.sprite, GameSettings.GemTranslationDuration, new Vector4(0, 0, 0, 0), false); sb.AddAnimation(anim); } sb.argument = toFades; sb.Start(); sb.OnCompleted += OnOvertakeCompleted; }
public static void PushTranslation(GameObject go, Vector2 targetPos, float time, float delay = 0) { TranslationAnimation anim = new TranslationAnimation(go, targetPos, time, delay); sSingleton._PushAnimation(anim); }