Beispiel #1
0
        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;
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        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);
            }
        }
Beispiel #7
0
        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);
        }
Beispiel #8
0
        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);
        }
Beispiel #9
0
        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);
 }
Beispiel #11
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;
            }
        }
Beispiel #12
0
 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);
 }
Beispiel #13
0
        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;
        }
Beispiel #14
0
        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);
        }
Beispiel #15
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 static void Unassign(Sprite2D btn)
 {
     btn.ChangeState(-1);
 }
Beispiel #17
0
        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);
        }
Beispiel #18
0
        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);
            }
        }
Beispiel #19
0
 public void AddChildAtMid(Sprite2D sprite)
 {
     AddChild(sprite);
     sprite.Left = (Width - sprite.Width) / 2;
     sprite.Top  = (Height - sprite.Height) / 2;
 }
Beispiel #20
0
 public void AddChildAtMid(Sprite2D sprite)
 {
     AddChild(sprite);
     sprite.Left = (Width - sprite.Width) / 2;
     sprite.Top = (Height - sprite.Height) / 2;
 }