private void SetupSpikes(HackCard hackCard)
    {
        string emptyImagePath = "CardParts/Circuits/EMPTYCIRCUIT";

        if (hackCard.GetTopLeftSpike().GetSpikeColor() != "none")
        {
            string topLeftSpikePath = "CardParts/Spikes/" + hackCard.GetTopLeftSpike().GetSpikeColor().ToUpper() + "-UPLEFT";
            topLeftSpikeImage.sprite = Resources.Load <Sprite>(topLeftSpikePath);
        }
        else
        {
            topLeftSpikeImage.sprite = Resources.Load <Sprite>(emptyImagePath);
        }

        if (hackCard.GetTopRightSpike().GetSpikeColor() != "none")
        {
            string topRightSpikePath = "CardParts/Spikes/" + hackCard.GetTopRightSpike().GetSpikeColor().ToUpper() + "-UPRIGHT";
            topRightSpikeImage.sprite = Resources.Load <Sprite>(topRightSpikePath);
        }
        else
        {
            topRightSpikeImage.sprite = Resources.Load <Sprite>(emptyImagePath);
        }

        if (hackCard.GetBottomLeftSpike().GetSpikeColor() != "none")
        {
            string bottomLeftSpikePath = "CardParts/Spikes/" + hackCard.GetBottomLeftSpike().GetSpikeColor().ToUpper() + "-BOTTOMLEFT";
            bottomLeftSpikeImage.sprite = Resources.Load <Sprite>(bottomLeftSpikePath);
        }
        else
        {
            bottomLeftSpikeImage.sprite = Resources.Load <Sprite>(emptyImagePath);
        }

        if (hackCard.GetbottomRightSpike().GetSpikeColor() != "none")
        {
            string bottomRightSpikePath = "CardParts/Spikes/" + hackCard.GetbottomRightSpike().GetSpikeColor().ToUpper() + "-BOTTOMRIGHT";
            bottomRightSpikeImage.sprite = Resources.Load <Sprite>(bottomRightSpikePath);
        }
        else
        {
            bottomRightSpikeImage.sprite = Resources.Load <Sprite>(emptyImagePath);
        }
    }
Example #2
0
    public void UpdateSpikeConnections()
    {
        FindAndStoreAdjacentSquares();

        if (attachedHackCard.GetTopLeftSpike().GetSpikeColor() != "none")
        {
            CheckAndUpdateTopLeftSpike();
        }
        if (attachedHackCard.GetTopRightSpike().GetSpikeColor() != "none")
        {
            CheckAndUpdateTopRightSpike();
        }
        if (attachedHackCard.GetBottomLeftSpike().GetSpikeColor() != "none")
        {
            CheckAndUpdateBottomLeftSpike();
        }
        if (attachedHackCard.GetbottomRightSpike().GetSpikeColor() != "none")
        {
            CheckAndUpdateBottomRightSpike();
        }
    }
    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;
                }
            }
        }
    }