public static void Assign(Sprite2D btn) { Global.gMouseHelper.Register(btn); btn.ClearState(); btn.SetOverlay(new Vector4(0, 0, 0, 0)); Storyboard sb = new Storyboard(); sb.AddAnimation(new ColorAnimation(sb, btn, 0.3f, new Vector4(0, 0, 0, 0), false)); btn.AddNewState(sb); sb = new Storyboard(); sb.AddAnimation(new ColorAnimation(sb, btn, 0.3f, new Vector4(255, 255, 255, 255), false)); btn.AddNewState(sb); sb = new Storyboard(); sb.AddAnimation(new ColorAnimation(sb, btn, 0.1f, new Vector4(255, 230, 230, 230), false)); btn.AddNewState(sb); btn.OnMouseMove += btn_OnMouseMove; btn.OnMouseLeave += btn_OnMouseLeave; btn.OnMouseDown += btn_OnMouseDown; btn.OnMouseUp += btn_OnMouseUp; }
public static void Assign(Sprite2D btn) { if (btn.states.Count > 0) { btn.ChangeState(0); return; } Storyboard sb = new Storyboard(); btn.ClearState(); sb.Clear(); var toScale = new Vector2(1.07f, 1.07f); var fromScale = Vector2.Divide(Vector2.One, toScale); sb.AddAnimation(new ScaleAnimation(sb, btn, GameSettings.GemSelectedEffectDuration, toScale, true, fromScale, true, true, true)); btn.AddNewState(sb); btn.ChangeState(0); }
public static void Assign(Sprite2D btn) { Global.gMouseHelper.Register(btn); btn.ClearState(); Storyboard sb = new Storyboard(); sb.AddAnimation(new ColorAnimation(sb, btn, 0.3f, new Vector4(255, 255, 255, 255), false)); btn.AddNewState(sb); sb = new Storyboard(); sb.AddAnimation(new ColorAnimation(sb, btn, 0.3f, new Vector4(255, 0, 255, 255), false)); btn.AddNewState(sb); sb = new Storyboard(); sb.AddAnimation(new ScaleAnimation(sb, btn, 0.1f, new Vector2(0.95f, 0.95f), true, null, false, false, true)); btn.AddNewState(sb); btn.OnMouseMove += btn_OnMouseMove; btn.OnMouseLeave += btn_OnMouseLeave; btn.OnMouseDown += btn_OnMouseDown; btn.OnMouseUp += btn_OnMouseUp; }
private void TransitionToGame(Storyboard.Callback callback) { if (game.CurrentGameState == Game1.GameState.Started) return; mainStoryboard.Stop(); mainStoryboard.Clear(); mainStoryboard.OnCompleted += (Storyboard.Callback)callback; 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(); }
public void ChangeState(int i) { if (i == -1) { if (currentState != null) { currentState.Stop(); currentState = null; } return; } if (currentState == null || currentState != states[i]) { if (currentState != null) { currentState.Stop(); } currentState = states[i]; currentState.Start(); } }
public void AddNewState(Animation a) { Storyboard sb = new Storyboard(); sb.AddAnimation(a); states.Add(sb); }
public void AddNewState(Storyboard a) { states.Add(a); }
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; }
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; }
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; }