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 Scoreboard(Sprite2D Red, Sprite2D Blue, Vector2 ScreenScaleFactor) { this.RedPlayerImage = Red; this.BluePlayerImage = Blue; RedCount = TextBox.CreateTextBox(Red.Left + Red.Width + 10, 30, ScreenScaleFactor, null, 0.6f, 0, 0, true); RedCount.InitTextBox(); RedCount.SetFont("ScoreFont"); RedCount.SetColor(Color.WhiteSmoke); BlueCount = TextBox.CreateTextBox(Blue.Left + Blue.Width + 10, 110, ScreenScaleFactor, null, 0.6f, 0, 0, true); BlueCount.InitTextBox(); BlueCount.SetFont("ScoreFont"); BlueCount.SetColor(Color.WhiteSmoke); Result = TextBox.CreateTextBox(-50, 190, ScreenScaleFactor, null, 0.6f, 0, 0, true); Result.InitTextBox(); Result.SetFont("WinFont"); Result.SetColor(Color.WhiteSmoke); Notify = TextBox.CreateTextBox(-70, -60, ScreenScaleFactor, null, 0.6f, 0, 0, true); Notify.InitTextBox(); Notify.SetFont("WinFont"); Notify.SetColor(blue); AddChild(Red); AddChild(Blue); AddChild(RedCount); AddChild(BlueCount); AddChild(Result); AddChild(Notify); }
public Scoreboard(Sprite2D Red, Sprite2D Blue, Vector2 ScreenScaleFactor) { this.RedPlayerImage = Red; this.BluePlayerImage = Blue; RedCount = TextBox.CreateTextBox(Red.Left+Red.Width+10, 30, ScreenScaleFactor, null, 0.6f, 0, 0, true); RedCount.InitTextBox(); RedCount.SetFont("ScoreFont"); RedCount.SetColor(Color.WhiteSmoke); BlueCount = TextBox.CreateTextBox(Blue.Left+Blue.Width+10, 110, ScreenScaleFactor, null, 0.6f, 0, 0, true); BlueCount.InitTextBox(); BlueCount.SetFont("ScoreFont"); BlueCount.SetColor(Color.WhiteSmoke); Result = TextBox.CreateTextBox(-50, 190, ScreenScaleFactor, null, 0.6f, 0, 0, true); Result.InitTextBox(); Result.SetFont("WinFont"); Result.SetColor(Color.WhiteSmoke); Notify = TextBox.CreateTextBox(-70, -60, ScreenScaleFactor, null, 0.6f, 0, 0, true); Notify.InitTextBox(); Notify.SetFont("WinFont"); Notify.SetColor(blue); AddChild(Red); AddChild(Blue); AddChild(RedCount); AddChild(BlueCount); AddChild(Result); AddChild(Notify); }
private Sprite2D LoadFragment(string strTexturePrefix, int i, int j) { Sprite2D result; result = new Sprite2D(LoadTexture(strTexturePrefix + i.ToString("00") + "_" + j.ToString("00")), j * FragmentWidth, i * FragmentHeight, FragmentWidth, FragmentHeight); return(result); }
public Tile(Sprite2D sprite, int i, int j) { State = CellState.None; sprite.OnMouseUp += OnMouseUp; this.AddChild(sprite); this.i = i; this.j = j; this.sprite = sprite; Global.gMouseHelper.Register(sprite); }
private void LoadTile(string[] strTextures) { int nTextures = strTextures.Length; Tiles = new Sprite2D[nTextures]; for (int i = 0; i < nTextures; i++) { Tiles[i] = new Sprite2D(LoadTextures(strTextures[i]), 0, 0, TileWidth, TileHeight); } }
public Tile(Sprite2D sprite, int i, int j) { State = CellState.None; sprite.OnMouseUp += OnMouseUp; this.AddChild(sprite); this.i = i; this.j = j; this.sprite = sprite; Global.gMouseHelper.Register(sprite); }
private void AddHexagonCollider(Sprite2D sprite) { PolygonCollider collider = new PolygonCollider(); collider.AddVertex(new Vector2(0, sprite.Height / 2.0f)); collider.AddVertex(new Vector2(sprite.Width / 4.0f, 0)); collider.AddVertex(new Vector2(0.75f * sprite.Width, 0)); collider.AddVertex(new Vector2(sprite.Width, sprite.Height / 2.0f)); collider.AddVertex(new Vector2(0.75f * sprite.Width, sprite.Height)); collider.AddVertex(new Vector2(sprite.Width / 4.0f, sprite.Height)); sprite.SetCollider(collider); }
public ScaleAnimation(Storyboard storyboard, Sprite2D sprite, float duration, Vector2 toScale, bool isReserveProperty = true, Vector2? fromScale = null, bool isAnimatedFromOrigin = false, bool isLoop = false, bool isInfinite = false) { this.isInfinite = isInfinite; this.isLoop = isLoop; this.storyboard = storyboard; this.sprite = sprite; this.duration = duration; this.isReserveProperty = isReserveProperty; this.toScale = toScale; isFromNull = fromScale == null; if (!isFromNull) { this.fromScale = fromScale.Value; } }
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 RotationAnimation(Storyboard storyboard, Sprite2D sprite, float duration, float toDegree, bool isReserveProperty = true, float? fromDegree = null, bool isAnimatedFromOrigin = false, bool isLoop = false, bool isInfinite = false) { this.isInfinite = isInfinite; this.isLoop = isLoop; this.storyboard = storyboard; this.sprite = sprite; this.duration = duration; this.isReserveProperty = isReserveProperty; this.toDegree = toDegree; isFromNull = fromDegree == null; if (!isFromNull) { this.fromDegree = fromDegree.Value; } }
public Gem(Gem gem2) { this.team = gem2.team; this.i = gem2.i; this.j = gem2.j; var visualPosition = Gem.map.GetGemVisualPosition(i, j); int width = (int)(Gem.Size.X * Global.thisGame.ScreenScaleFactor.X); int height = (int)(Gem.Size.Y * Global.thisGame.ScreenScaleFactor.Y); if (team == Team.Red) { sprite = StaticSprite.CreateSprite(visualPosition.X, visualPosition.Y, new Vector2(1, 1), SpritePath[0], 0.1f, width, height); } else { sprite = StaticSprite.CreateSprite(visualPosition.X, visualPosition.Y, new Vector2(1, 1), SpritePath[1], 0.1f, width, height); } this.AddChild(sprite); }
public ColorAnimation(Storyboard storyboard, Sprite2D sprite, float duration, Vector4 toColor, bool isReserveProperty = true, Vector4? fromColor = null, bool isAnimatedFromOrigin = false, bool isLoop = false, bool isInfinite = false) { this.isInfinite = isInfinite; this.isAnimatedFromOrigin = isAnimatedFromOrigin; this.isLoop = isLoop; this.storyboard = storyboard; this.sprite = sprite; this.duration = duration; this.isReserveProperty = isReserveProperty; this.toColor = toColor; if (!isFromNull) { this.fromColor = fromColor.Value; } isFromNull = fromColor == null; }
public Gem(Gem gem2) { this.team = gem2.team; this.i = gem2.i; this.j = gem2.j; var visualPosition = Gem.map.GetGemVisualPosition(i, j); int width = (int)(Gem.Size.X * Global.thisGame.ScreenScaleFactor.X); int height = (int)(Gem.Size.Y * Global.thisGame.ScreenScaleFactor.Y); if (team == Team.Red) { sprite = StaticSprite.CreateSprite(visualPosition.X, visualPosition.Y, new Vector2(1, 1), SpritePath[0], 0.1f, width, height); } else { sprite = StaticSprite.CreateSprite(visualPosition.X, visualPosition.Y, new Vector2(1, 1), SpritePath[1], 0.1f, width, height); } this.AddChild(sprite); }
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 static void Unassign(Sprite2D btn) { btn.ChangeState(-1); }
private void AddHexagonCollider(Sprite2D sprite) { PolygonCollider collider = new PolygonCollider(); collider.AddVertex(new Vector2(0, sprite.Height / 2.0f)); collider.AddVertex(new Vector2(sprite.Width/4.0f, 0)); collider.AddVertex(new Vector2(0.75f*sprite.Width, 0)); collider.AddVertex(new Vector2(sprite.Width, sprite.Height / 2.0f)); collider.AddVertex(new Vector2(0.75f * sprite.Width, sprite.Height)); collider.AddVertex(new Vector2(sprite.Width / 4.0f, sprite.Height)); sprite.SetCollider(collider); }
private void LoadTile(string[] strTextures) { int nTextures = strTextures.Length; Tiles = new Sprite2D[nTextures]; for (int i = 0; i < nTextures; i++) { Tiles[i] = new Sprite2D(LoadTextures(strTextures[i]), 0, 0, TileWidth, TileHeight); } }
public void AddChildAtMid(Sprite2D sprite) { AddChild(sprite); sprite.Left = (Width - sprite.Width) / 2; sprite.Top = (Height - sprite.Height) / 2; }
public void AddChildAtMid(Sprite2D sprite) { AddChild(sprite); sprite.Left = (Width - sprite.Width) / 2; sprite.Top = (Height - sprite.Height) / 2; }