コード例 #1
0
    // Function to choose the prefab type to make
    private void FindColour(int x, int y, Color32 pixel)
    {
        bool found = false;

        foreach (BitTypetoPrefab pair in relations)
        {
            if (knowledge.BitTypeByColour.ContainsKey(pair.bitType) && pixel.Equals(knowledge.BitTypeByColour[pair.bitType]))
            {
                MakeBit(x, y, pair.prefab, pair.bitType);
                found = true;
                break;
            }
        }
        if (!found)
        {
            BitType bitType = BitType.Void;
            if (pixel.a != 0)
            {
                if (FindColourInList(beaconFacingColours, pixel))
                {
                    bitType = BitType.BeaconTR;
                }
                else if (FindColourInList(beaconStartingColours, pixel))
                {
                    bitType = BitType.BeaconTL;
                }
                else if (FindColourInList(beaconUpgradeColours, pixel))
                {
                    bitType = BitType.BeaconBR;
                }
                else if (FindColourInList(pickupUpgradeColours, pixel))
                {
                    bitType = BitType.Upgrade;
                }
                if (bitType != BitType.Void)
                {
                    MakeBit(x, y, FindPrefabFromBitType(bitType), bitType);
                    mostRecentBit.GiveMulticolourInfo(pixel);
                    found = true;
                }
            }
            if (!found)
            {
                MakeBit(x, y, voidPrefab, BitType.Void);
            }
        }
    }