Example #1
0
    public void UpdateCircle(CircleUpdate update)
    {
        if (update.NewCard != null)
        {
            Card newCard = CardCache.GetCardById(update.NewCard.CardId);
            SetCard(newCard);
        }

        if (update.RightColor != null)
        {
            Circle.RightColor = update.RightColor.Value;
        }
        if (update.LeftColor != null)
        {
            Circle.LeftColor = update.LeftColor.Value;
        }
        if (update.CardPowerChange != null)
        {
            CardState.Power = (byte)((int)CardState.Power + (int)update.CardPowerChange);
        }

        RefreshTextComponents();
        RefreshColors();
        RefreshBackgroundSprite();
    }
Example #2
0
    public void ApplyCircleUpdate(CircleUpdate update)
    {
        if (update.CircleIndex < 0 || update.CircleIndex > EnabledCircles.Items.Count)
        {
            return;
        }

        CircleItem item = EnabledCircles.Items[update.CircleIndex];

        item.UpdateCircle(update);
    }
    public static CircleUpdate CreateEmptyCircleUpdate(int index, CircleColor rightColor, CircleColor leftColor)
    {
        CircleUpdate update = new CircleUpdate();

        update.RightColor      = (byte)rightColor;
        update.LeftColor       = (byte)leftColor;
        update.CircleIndex     = (byte)index;
        update.NewCard         = null;
        update.CardPowerChange = null;

        return(update);
    }
    private Turn CreateInitTurn(PlayerInfo playerInfo, PlayerOrdinal playerNumber)
    {
        Turn initTurn = new Turn()
        {
            PlayerNumber  = playerNumber,
            DragonUpdate  = new DragonStateUpdate(),
            CirclesUpdate = new CirclesStateUpdate(),
            CardsUpdate   = new CardsStateUpdate()
        };

        // create empty circles

        Array values = Enum.GetValues(typeof(CircleColor));

        System.Random random = new System.Random();

        CircleUpdate[] circles = new CircleUpdate[6];
        for (int i = 0; i < 6; i++)
        {
            circles[i] = CreateEmptyCircleUpdate(i,
                                                 (CircleColor)values.GetValue(random.Next(values.Length)),
                                                 (CircleColor)values.GetValue(random.Next(values.Length)));
        }

        // draw initial cards
        string[] drawnCards = new string[5];
        for (int i = 0; i < 5; i++)
        {
            drawnCards[i] = Deck.DrawCard().id;
        }

        initTurn.DragonUpdate.NewDragonEquip = playerInfo.EquippedDragonId;
        initTurn.CirclesUpdate.CircleChanges = circles;
        initTurn.CardsUpdate.DrawnCards      = drawnCards;

        return(initTurn);
    }
Example #5
0
        private void DrawCircle(int x, int y, int width, int height, bool Fill,
                CircleUpdate listener)
        {
            int a = width / 2;
            int b = height / 2;
            long squareA = width * width / 4;
            long squareB = height * height / 4;
            long squareAB = Round((long)width * width * height * height, 16L);

            x += translateX;
            y += translateY;
            int centerX = x + a;
            int centerY = y + b;

            int deltaX = (width % 2 == 0) ? 0 : 1;
            int deltaY = (height % 2 == 0) ? 0 : 1;

            int currentY = b;
            int currentX = 0;

            int lastx1 = centerX - currentX;
            int lastx2 = centerX + currentX + deltaX;
            int lasty1 = centerY - currentY;
            int lasty2 = centerY + currentY + deltaY;
            while (currentX <= a && currentY >= 0)
            {
                long deltaA = (currentX + 1) * (currentX + 1) * squareB + currentY
                        * currentY * squareA - squareAB;
                long deltaB = (currentX + 1) * (currentX + 1) * squareB
                        + (currentY - 1) * (currentY - 1) * squareA - squareAB;
                long deltaC = currentX * currentX * squareB + (currentY - 1)
                        * (currentY - 1) * squareA - squareAB;
                if (deltaA <= 0)
                {
                    currentX++;
                }
                else if (deltaC >= 0)
                {
                    currentY--;
                }
                else
                {
                    int min = (int)MathUtils.Min(
                            MathUtils.Abs(deltaA),
                            MathUtils.Min(MathUtils.Abs(deltaB),
                                    MathUtils.Abs(deltaC)));
                    if (min == MathUtils.Abs(deltaA))
                    {
                        currentX++;
                    }
                    else if (min == MathUtils.Abs(deltaC))
                    {
                        currentY--;
                    }
                    else
                    {
                        currentX++;
                        currentY--;
                    }
                }

                int x1 = centerX - currentX;
                int x2 = centerX + currentX + deltaX;
                int y1 = centerY - currentY;
                int y2 = centerY + currentY + deltaY;
                if (!Fill || lasty1 != y1)
                {
                    listener.NewPoint(lastx1, lasty1, lastx2, lasty2);
                    lasty1 = y1;
                    lasty2 = y2;
                }
                lastx1 = x1;
                lastx2 = x2;
            }
            if (lasty1 < lasty2)
            {
                for (; lasty1 <= lasty2; lasty1++, lasty2--)
                {
                    listener.NewPoint(centerX - a, lasty1, centerX + a + deltaX,
                            lasty2);
                }
            }
        }