public void RotateCircuitsAndSpikesNinetyDegrees()
    {
        string previousLeftConnection = leftConnection;

        leftConnection   = bottomConnection;
        bottomConnection = rightConnection;
        rightConnection  = topConnection;
        topConnection    = previousLeftConnection;

        string previousTopLeftSpikeColor = topLeftSpike.GetSpikeColor();
        string previousTopLeftSpikeState = topLeftSpike.GetSpikeState();

        topLeftSpike.SetupNewValues(bottomLeftSpike.GetSpikeColor(), bottomLeftSpike.GetSpikeState());
        topLeftSpike.SetSpikeImage("topleft");

        bottomLeftSpike.SetupNewValues(bottomRightSpike.GetSpikeColor(), bottomRightSpike.GetSpikeState());
        bottomLeftSpike.SetSpikeImage("bottomleft");

        bottomRightSpike.SetupNewValues(topRightSpike.GetSpikeColor(), topRightSpike.GetSpikeState());
        bottomRightSpike.SetSpikeImage("bottomright");

        topRightSpike.SetupNewValues(previousTopLeftSpikeColor, previousTopLeftSpikeState);
        topRightSpike.SetSpikeImage("topright");
    }
    public void SetTopCard()
    {
        Image[]        imageHolders   = GetComponentsInChildren <Image>();
        AllSpikeImages allSpikeImages = FindObjectOfType <AllSpikeImages>();

        if (cards.Count == 0)
        {
            foreach (Image image in imageHolders)
            {
                image.sprite = allSpikeImages.GetEmptyImage();
            }
        }
        else
        {
            HackCard topCard = cards[0];
            foreach (Image image in imageHolders)
            {
                switch (image.name)
                {
                case "HackDeckCardBack":
                    image.sprite = allSpikeImages.GetCardBack();
                    break;

                case "LeftCircuit":
                    string color;
                    if (tempLeftCircuit != null)
                    {
                        color = tempLeftCircuit;
                    }
                    else
                    {
                        color = topCard.GetLeftCircuit();
                    }
                    Sprite currentImage = allSpikeImages.GetCircuitImageByColorAndDirection(color, "left");
                    image.sprite = currentImage;
                    break;

                case "TopCircuit":
                    if (tempTopCircuit != null)
                    {
                        color = tempTopCircuit;
                    }
                    else
                    {
                        color = topCard.GetTopCircuit();
                    }
                    currentImage = allSpikeImages.GetCircuitImageByColorAndDirection(color, "top");
                    image.sprite = currentImage;
                    break;

                case "RightCircuit":
                    if (tempRightCircuit != null)
                    {
                        color = tempRightCircuit;
                    }
                    else
                    {
                        color = topCard.GetRightCircuit();
                    }
                    currentImage = allSpikeImages.GetCircuitImageByColorAndDirection(color, "right");
                    image.sprite = currentImage;
                    break;

                case "DownCircuit":
                    if (tempBottomCircuit != null)
                    {
                        color = tempBottomCircuit;
                    }
                    else
                    {
                        color = topCard.GetBottomCircuit();
                    }
                    currentImage = allSpikeImages.GetCircuitImageByColorAndDirection(color, "bottom");
                    image.sprite = currentImage;
                    break;

                case "TopLeftSpike":
                    Spike  currentspike = topCard.GetTopLeftSpike();
                    string state        = currentspike.GetSpikeState();
                    color        = currentspike.GetSpikeColor();
                    currentImage = allSpikeImages.GetSpikebyColorCornerAndState(color, "topleft", state);
                    image.sprite = currentImage;
                    break;

                case "TopRightSpike":
                    currentspike = topCard.GetTopRightSpike();
                    state        = currentspike.GetSpikeState();
                    color        = currentspike.GetSpikeColor();
                    currentImage = allSpikeImages.GetSpikebyColorCornerAndState(color, "topright", state);
                    image.sprite = currentImage;
                    break;

                case "BottomLeftSpike":
                    currentspike = topCard.GetBottomLeftSpike();
                    state        = currentspike.GetSpikeState();
                    color        = currentspike.GetSpikeColor();
                    currentImage = allSpikeImages.GetSpikebyColorCornerAndState(color, "bottomleft", state);
                    image.sprite = currentImage;
                    break;

                case "BottomRightSpike":
                    currentspike = topCard.GetbottomRightSpike();
                    state        = currentspike.GetSpikeState();
                    color        = currentspike.GetSpikeColor();
                    currentImage = allSpikeImages.GetSpikebyColorCornerAndState(color, "bottomright", state);
                    image.sprite = currentImage;
                    break;

                case "CardImage":
                    image.sprite = topCard.GetCardImage();
                    break;
                }
            }
        }
    }
Exemple #3
0
    private void CheckAndUpdateTopLeftSpike()
    {
        Spike currentSpike   = attachedHackCard.GetTopLeftSpike();
        Spike leftSpike      = leftSquare.GetTopRightSpike();
        Spike aboveLeftSpike = aboveLeftDiagonalSquare.GetBottomRightSpike();
        Spike aboveSpike     = aboveSquare.GetBottomLeftSpike();

        string color = currentSpike.GetSpikeColor();

        if (leftSpike && aboveSpike && aboveLeftSpike && color == leftSpike.GetSpikeColor() && color == aboveSpike.GetSpikeColor() && color == aboveLeftSpike.GetSpikeColor())
        {
            // ALL FOUR CONNECTED
            currentSpike.SetState("two");
            aboveSpike.SetState("two");
            leftSpike.SetState("two");
            aboveLeftSpike.SetState("two");
            UpdatePoints(color, 4);
        }
        else if (leftSpike && aboveLeftSpike && color == leftSpike.GetSpikeColor() && color == aboveLeftSpike.GetSpikeColor())
        {
            // LEFT, DIAGONAL
            currentSpike.SetState("left");
            leftSpike.SetState("two");
            aboveLeftSpike.SetState("down");
            UpdatePoints(color, 3);
        }
        else if (aboveSpike && aboveLeftSpike && color == aboveSpike.GetSpikeColor() && color == aboveLeftSpike.GetSpikeColor())
        {
            // UP DIAGONAL
            currentSpike.SetState("up");
            aboveSpike.SetState("two");
            aboveLeftSpike.SetState("right");
            UpdatePoints(color, 3);
        }
        else if (leftSpike && aboveSpike && color == leftSpike.GetSpikeColor() && color == aboveSpike.GetSpikeColor())
        {
            // LEFT UP
            currentSpike.SetState("two");
            leftSpike.SetState("right");
            aboveSpike.SetState("down");
            UpdatePoints(color, 3);
        }
        else if (leftSpike && color == leftSpike.GetSpikeColor())
        {
            // LEFT
            currentSpike.SetState("left");
            leftSpike.SetState("right");
            UpdatePoints(color, 2);
        }
        else if (aboveSpike && color == aboveSpike.GetSpikeColor())
        {
            // UP
            currentSpike.SetState("up");
            aboveSpike.SetState("down");
            UpdatePoints(color, 2);
        }
        else
        {
            // NONE
            currentSpike.SetState("closed");
        }

        currentSpike.SetSpikeImage("topleft");
        if (aboveSpike)
        {
            aboveSpike.SetSpikeImage("bottomleft");
        }
        if (aboveLeftSpike)
        {
            aboveLeftSpike.SetSpikeImage("bottomright");
        }
        if (leftSpike)
        {
            leftSpike.SetSpikeImage("topright");
        }
    }
Exemple #4
0
    private void CheckAndUpdateBottomRightSpike()
    {
        Spike currentSpike    = attachedHackCard.GetbottomRightSpike();
        Spike rightSpike      = rightSquare.GetBottomLeftSpike();
        Spike belowRightSpike = belowRightDiagonalSquare.GetTopLeftSpike();
        Spike belowSpike      = belowSquare.GetTopRightSpike();

        string color = currentSpike.GetSpikeColor();

        if (rightSpike && belowSpike && belowRightSpike && color == rightSpike.GetSpikeColor() && color == belowSpike.GetSpikeColor() && color == belowRightSpike.GetSpikeColor())
        {
            // ALL FOUR CONNECTED
            currentSpike.SetState("two");
            belowSpike.SetState("two");
            rightSpike.SetState("two");
            belowRightSpike.SetState("two");
            UpdatePoints(color, 4);
        }
        else if (rightSpike && belowRightSpike && color == rightSpike.GetSpikeColor() && color == belowRightSpike.GetSpikeColor())
        {
            // RIGHT, DIAGONAL
            currentSpike.SetState("right");
            rightSpike.SetState("two");
            belowRightSpike.SetState("up");
            UpdatePoints(color, 3);
        }
        else if (belowSpike && belowRightSpike && color == belowSpike.GetSpikeColor() && color == belowRightSpike.GetSpikeColor())
        {
            // DOWN DIAGONAL
            currentSpike.SetState("down");
            belowSpike.SetState("two");
            belowRightSpike.SetState("left");
            UpdatePoints(color, 3);
        }
        else if (rightSpike && belowSpike && color == rightSpike.GetSpikeColor() && color == belowSpike.GetSpikeColor())
        {
            // RIGHT DOWN
            currentSpike.SetState("two");
            rightSpike.SetState("left");
            belowSpike.SetState("up");
            UpdatePoints(color, 3);
        }
        else if (rightSpike && color == rightSpike.GetSpikeColor())
        {
            // RIGHT
            currentSpike.SetState("right");
            rightSpike.SetState("left");
            UpdatePoints(color, 2);
        }
        else if (belowSpike && color == belowSpike.GetSpikeColor())
        {
            // DOWN
            currentSpike.SetState("down");
            belowSpike.SetState("up");
            UpdatePoints(color, 2);
        }
        else
        {
            // NONE
            currentSpike.SetState("closed");
        }

        currentSpike.SetSpikeImage("bottomright");
        if (belowSpike)
        {
            belowSpike.SetSpikeImage("topright");
        }
        if (belowRightSpike)
        {
            belowRightSpike.SetSpikeImage("topleft");
        }
        if (rightSpike)
        {
            rightSpike.SetSpikeImage("bottomleft");
        }
    }