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; }
public void AddNewState(Animation a) { Storyboard sb = new Storyboard(); sb.AddAnimation(a); states.Add(sb); }
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; }