Пример #1
0
    void ChangeBallTrailColor(TrailRenderer ballTrail, Color32 color)
    {
        Color trailColor;

        if (color.Equals(WallColors.red))
        {
            trailColor = Color.red;
        }
        else if (color.Equals(WallColors.yellow))
        {
            trailColor = Color.yellow;
        }
        else if (color.Equals(WallColors.green))
        {
            trailColor = Color.green;
        }
        else if (color.Equals(WallColors.blue))
        {
            trailColor = new Color(0, 0.15f, 1, 1);
        }
        else if (color.Equals(WallColors.pink))
        {
            trailColor = Color.magenta;
        }
        else
        {
            trailColor = WallColors.defaultColor;
        }

        ballTrail.endColor   = trailColor;
        ballTrail.startColor = trailColor;
    }
Пример #2
0
    void BuildTerrainMap(TileMap givenMap)
    {
        // Takes the TileMaps' InputImage and creates an array of colors from its pixels.
        // Loops through that array, adjusting for x and y position, and checks the color of the pixel against the color presets.
        // Checks each pixel; you can speed this up, perhaps losing accuracy, by increasing the for loops' variable increase.
        Texture2D inputMap = givenMap.inputImage;

        Color32[] allPixels = inputMap.GetPixels32();

        for (int x = 0; x < inputMap.width; x += 1)
        {
            for (int y = 0; y < inputMap.height; y += 1)
            {
                Color32 col = allPixels[(y * inputMap.width) + x];
                if (col.Equals(landColor))
                {
                    givenMap.GetTileAt(x / 10, y / 10).SetTileTerrainType(Tile.TileTerrainType.Land);
                }
                else if (col.Equals(seaColor))
                {
                    givenMap.GetTileAt(x / 10, y / 10).SetTileTerrainType(Tile.TileTerrainType.Sea);
                }
                else if (col.Equals(mountainColor))
                {
                    givenMap.GetTileAt(x / 10, y / 10).SetTileTerrainType(Tile.TileTerrainType.Mountain);
                }
                else if (col.Equals(forestColor))
                {
                    givenMap.GetTileAt(x / 10, y / 10).SetTileTerrainType(Tile.TileTerrainType.Forest);
                }
            }
        }
    }
Пример #3
0
    private static Individual RandomRespectfulCrossover(Individual indiv1, Individual indiv2)
    {
        Individual child = new Individual();

        //Without creating similarity vector
        for (int i = 0; i < indiv1.GetSize(); i++)
        {
            Color32 gene1 = indiv1.GetGene(i);

            if (gene1.Equals(indiv2.GetGene(i)))
            {
                if (gene1.Equals(new Color32(255, 255, 255, 255)))
                {
                    child.SetGene(i, new Color32(255, 255, 255, 255));
                }
                else
                {
                    child.SetGene(i, new Color32(0, 0, 0, 255));
                }
            }
            else
            {
                child.SetGene(i, Random.value > 0.5f ? new Color32(255, 255, 255, 255) : new Color32(0, 0, 0, 255));
            }
        }

        return(child);
    }
Пример #4
0
        public static List <EquipmentIndex> GetEquipment()
        {
            List <EquipmentIndex> equipment = new List <EquipmentIndex>();

            List <EquipmentIndex> equip = new List <EquipmentIndex>();
            List <EquipmentIndex> lunar = new List <EquipmentIndex>();
            List <EquipmentIndex> other = new List <EquipmentIndex>();

            Color32 equipColor = ColorCatalog.GetColor(ColorCatalog.ColorIndex.Equipment);
            Color32 lunarColor = ColorCatalog.GetColor(ColorCatalog.ColorIndex.LunarItem);

            foreach (EquipmentIndex equipmentIndex in EquipmentCatalog.allEquipment)
            {
                Color32 currentEquipColor = ColorCatalog.GetColor(EquipmentCatalog.GetEquipmentDef(equipmentIndex).colorIndex);
                if (currentEquipColor.Equals(equipColor)) // equipment
                {
                    equip.Add(equipmentIndex);
                }
                else if (currentEquipColor.Equals(lunarColor)) // lunar equipment
                {
                    lunar.Add(equipmentIndex);
                }
                else // other
                {
                    other.Add(equipmentIndex);
                }
            }
            UmbraMenu.unreleasedEquipment = other;
            var result = equipment.Concat(lunar).Concat(equip).Concat(other).ToList();

            return(result);
        }
Пример #5
0
    /// <summary>
    /// This method is used to generate the level's data by setting the color of each pixel to a set number that will be used in BuildLevel();
    /// </summary>
    void GenerateLevelData()
    {
        for (int x = 0; x < LevelImage.width; x++)
        {
            for (int y = 0; y < LevelImage.height; y++)
            {
                Color32 data = LevelImage.GetPixel(x, y);
                if (data.Equals(groundColor))
                {
                    levelData[x, y] = 1;
                }

                if (data.Equals(pipeColor))
                {
                    levelData[x, y] = 2;
                }

                if (data.Equals(block1Color))
                {
                    levelData[x, y] = 3;
                }

                if (data.Equals(block2Color))
                {
                    levelData[x, y] = 4;
                }

                if (data.Equals(playerColor))
                {
                    levelData[x, y] = 5;
                }
            }
        }
    }
Пример #6
0
        void SpawnTileAt(Color32 c, int x, int y)
        {
            // If this is a white or transparent pixel, then it's meant to just be empty.
            if (c.Equals(white) || c.Equals(transparent))
            {
                return;
            }

            // Find the right color in our map
            foreach (ColorToPrefab ctp in colorToPrefabs)
            {
                // NOTE: This isn't optimized. You should have a dictionary lookup for max speed
                if (c.Equals(ctp.Color))
                {
                    // Spawn the prefab at the right location
                    GameObject go = (GameObject)Instantiate(ctp.Prefab, new Vector3(x, y, 0), Quaternion.identity);
                    if (!go.CompareTag("Player"))
                    {
                        go.transform.SetParent(this.transform);
                        go.name = string.Concat(ctp.Prefab.name, " (", x, ", ", y, ")");
                    }
                    return;
                }
            }

            // If we got to this point, it means we did not find a matching color in our array.
            Debug.LogError(string.Concat("No color to prefab found for: ", c, " at: ", " (", x, ", ", y, ")"));
        }
Пример #7
0
 public static Color32[] ColorSplitter(Color32 clrToSplit)
 {
     Color32[] clrSplitted;
     if (clrToSplit.Equals(MMConstants.RED) ||
         clrToSplit.Equals(MMConstants.YELLOW) ||
         clrToSplit.Equals(MMConstants.BLUE))
     {
         clrSplitted    = new Color32[2];
         clrSplitted[0] = clrToSplit;
         clrSplitted[1] = clrToSplit;
     }
     else if (clrToSplit.Equals(MMConstants.PURPLE))
     {
         clrSplitted = GetPurpleComposition();
     }
     else if (clrToSplit.Equals(MMConstants.GREEN))
     {
         clrSplitted = GetGreenComposition();
     }
     else //GetOrangeComposition
     {
         clrSplitted = GetOrangeComposition();
     }
     return(clrSplitted);
 }
Пример #8
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent title)
        {
            if (EditorPrefs.GetInt("ShiftUIManager.EnableExtendedColorPicker") == 1)
            {
                title    = EditorGUI.BeginProperty(position, title, property);
                position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), title);

                var indent = EditorGUI.indentLevel;
                EditorGUI.indentLevel = 0;

                float colorWidth = (position.width - hexFW - spacing - alphaFW - spacing);

                Color32 color  = property.colorValue;
                Color32 color2 = EditorGUI.ColorField(new Rect(position.x, position.y, colorWidth, position.height), property.colorValue);

                if (!color2.Equals(color))
                {
                    property.colorValue = color = color2;
                }

                string colorStringValue = EditorGUI.TextField(new Rect((position.x + colorWidth + spacing), position.y, hexFW, position.height), ColorToString(color));

                try
                {
                    color2 = StringToColor(colorStringValue);

                    if (!color2.Equals(color))
                    {
                        property.colorValue = color = color2;
                    }
                }

                catch { }

                float newAlpha = EditorGUI.Slider(new Rect((position.x + colorWidth + hexFW + (spacing * 2f)), position.y, alphaFW, position.height), property.colorValue.a, 0f, 1f);

                if (!newAlpha.Equals(property.colorValue.a))
                {
                    property.colorValue = new Color(property.colorValue.r, property.colorValue.g, property.colorValue.b, newAlpha);
                }

                EditorGUI.indentLevel = indent;
                EditorGUI.EndProperty();
            }

            else
            {
                title    = EditorGUI.BeginProperty(position, title, property);
                position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), title);
                float   colorWidth = (position.width);
                Color32 color      = property.colorValue;
                Color32 color2     = EditorGUI.ColorField(new Rect(position.x, position.y, colorWidth, position.height), property.colorValue);

                if (!color2.Equals(color))
                {
                    property.colorValue = color = color2;
                }
            }
        }
Пример #9
0
        public static List <ItemIndex> GetItems()
        {
            List <ItemIndex> items = new List <ItemIndex>();

            List <ItemIndex> boss  = new List <ItemIndex>();
            List <ItemIndex> tier3 = new List <ItemIndex>();
            List <ItemIndex> tier2 = new List <ItemIndex>();
            List <ItemIndex> tier1 = new List <ItemIndex>();
            List <ItemIndex> lunar = new List <ItemIndex>();
            List <ItemIndex> other = new List <ItemIndex>();

            Color32 bossColor  = ColorCatalog.GetColor(ColorCatalog.ColorIndex.BossItem);
            Color32 tier3Color = ColorCatalog.GetColor(ColorCatalog.ColorIndex.Tier3Item);
            Color32 tier2Color = ColorCatalog.GetColor(ColorCatalog.ColorIndex.Tier2Item);
            Color32 tier1Color = ColorCatalog.GetColor(ColorCatalog.ColorIndex.Tier1Item);
            Color32 lunarColor = ColorCatalog.GetColor(ColorCatalog.ColorIndex.LunarItem);

            foreach (ItemIndex itemIndex in ItemCatalog.allItems)
            {
                Color32 itemColor = ColorCatalog.GetColor(ItemCatalog.GetItemDef(itemIndex).colorIndex);
                if (itemColor.Equals(bossColor)) // boss
                {
                    boss.Add(itemIndex);
                }
                else if (itemColor.Equals(tier3Color)) // tier 3
                {
                    tier3.Add(itemIndex);
                }
                else if (itemColor.Equals(tier2Color)) // tier 2
                {
                    tier2.Add(itemIndex);
                }
                else if (itemColor.Equals(tier1Color)) // tier 1
                {
                    tier1.Add(itemIndex);
                }
                else if (itemColor.Equals(lunarColor)) // lunar
                {
                    lunar.Add(itemIndex);
                }
                else // Other
                {
                    other.Add(itemIndex);
                }
            }

            UmbraMenu.bossItems       = boss;
            UmbraMenu.unreleasedItems = other;
            var result = items.Concat(boss).Concat(tier3).Concat(tier2).Concat(tier1).Concat(lunar).Concat(other).ToList();

            return(result);
        }
Пример #10
0
    public void LoadMap(Texture2D newMap)
    {
        EmptyMap();

        //for now load all the tiles
        Color32[] pixels = newMap.GetPixels32();
        width  = newMap.width;
        height = newMap.height;

        tiles = new GameTile[width, height];

        //CreateBackground ();
        //TODO:
        //when these maps are eventually loaded separately, we'll need to know how big the total world is first
        //then update the map with offsets, but for now assume this one map is the entire map
        path.InitializeGrid(width, height);

        for (int x = 0; x < width; x++)
        {
            for (int y = 0; y < height; y++)
            {
                Color32 currentPixel   = pixels[(y * width) + x];
                Color32 fullColorPixel = GetFullColor(currentPixel);

                tiles[x, y] = new GameTile();
                if (fullColorPixel.Equals(publicTileData[1].fileColor) && currentPixel.a > 0)
                {
                    LoadTile(x, y, 1);
                }
                else
                {
                    if (fullColorPixel.Equals(playerSpawnColor))
                    {
                        player.transform.position      = new Vector3(x, y, 0);
                        Camera.main.transform.position = new Vector3(x, y, Camera.main.transform.position.z);
                    }

                    LoadTile(x, y, 0);
                    if (currentPixel.a > 0 && colorIds.ContainsKey(fullColorPixel))
                    {
                        blocker.AddFreeTile(colorIds[fullColorPixel], new Vector3(x, y, 0), currentPixel.a);
                    }
                }
            }
        }

        path.AddNeighbors();
        blocker.SortSpawnLists();

        UpdateBitmaskTiles();
    }
Пример #11
0
 public override void GiveMulticolourInfo(Color32 pixel)
 {
     if (pixel.Equals(new Color32(153, 0, 0, 255)))
     {
         startColour = Wavelength.I;
     }
     else if (pixel.Equals(new Color32(153, 153, 0, 255)))
     {
         startColour = Wavelength.V;
     }
     else if (pixel.Equals(new Color32(153, 0, 153, 255)))
     {
         startColour = Wavelength.U;
     }
 }
Пример #12
0
 public override void GiveMulticolourInfo(Color32 pixel)
 {
     if (pixel.Equals(new Color32(0, 150, 255, 255)))
     {
         upgrade = Pickup.line;
     }
     else if (pixel.Equals(new Color32(0, 100, 255, 255)))
     {
         upgrade = Pickup.area;
     }
     else if (pixel.Equals(new Color32(0, 50, 255, 255)))
     {
         upgrade = Pickup.displace;
     }
 }
Пример #13
0
    public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
    {
        label = EditorGUI.BeginProperty(pos, label, prop);

        // Draw label
        pos = EditorGUI.PrefixLabel(pos, GUIUtility.GetControlID(FocusType.Passive), label);

        // Don't make child fields be indented
        var indent = EditorGUI.indentLevel;

        EditorGUI.indentLevel = 0;

        float colorWidth = (pos.width - hexFieldWidth - spacing - alphaFieldWidth - spacing);

        Color32 color  = prop.colorValue;
        Color32 color2 = EditorGUI.ColorField(new Rect(pos.x, pos.y, colorWidth, pos.height), prop.colorValue);

        if (!color2.Equals(color))
        {
            prop.colorValue = color = color2;
        }

        string colorString = EditorGUI.TextField(new Rect((pos.x + colorWidth + spacing), pos.y, hexFieldWidth, pos.height), CommonColorBuffer.ColorToString(color));

        try
        {
            color2 = CommonColorBuffer.StringToColor(colorString);

            if (!color2.Equals(color))
            {
                prop.colorValue = color = color2;
            }
        }
        catch { }


        float newAlpha = EditorGUI.Slider(new Rect((pos.x + colorWidth + hexFieldWidth + (spacing * 2f)), pos.y, alphaFieldWidth, pos.height), prop.colorValue.a, 0f, 1f);

        if (!newAlpha.Equals(prop.colorValue.a))
        {
            prop.colorValue = new Color(prop.colorValue.r, prop.colorValue.g, prop.colorValue.b, newAlpha);
        }

        // Set indent back to what it was
        EditorGUI.indentLevel = indent;

        EditorGUI.EndProperty();
    }
Пример #14
0
 private void Awake()
 {
     if (PlayerColor.Equals(GraphicsL.fullAlpha))
     {
         GraphicsL.RandomColor();
     }
 }
Пример #15
0
        private bool CompareColors(Color c1, Color c2)
        {
            Color32 tColor1 = c1;
            Color32 tColor2 = c2;

            return(tColor1.Equals(tColor2));
        }
Пример #16
0
    void ReplaceTargetColor(Texture2D originalTexture, Texture2D modifiedTexture, Color32 targetColor, Color32 replacementColor)
    {
        int targetColorFoundCount = 0;

        for (int y = 0; y < originalTexture.height; y++)
        {
            for (int x = 0; x < originalTexture.width; x++)
            {
                Color32 currentOriginalPixelColor = originalTexture.GetPixel(x, y);
                if (currentOriginalPixelColor.Equals(targetColor))
                {
                    targetColorFoundCount++;
                }

                Color32 modifiedTexturePixelColor = replacementColor;

                modifiedTexture.SetPixel(x, y, modifiedTexturePixelColor);
            }
        }
        if (targetColorFoundCount > 0)
        {
            modifiedTexture.Apply();
        }
        Debug.Log("TargetColor: " + targetColor.ToString() + " found " + targetColorFoundCount + " times");
    }
Пример #17
0
    void SpawnTileAt(Color32 c, int x, int y)
    {
        //find the right color in our map

        //if pixel transparent then ignore
        if (c.a <= 0)
        {
            return;
        }

        //if want to speed up use dictionary look up
        foreach (ColorToPrefab ctp in colorToPrefab)
        {
            if (c.Equals(ctp.color))
            {
                //spawn prefab at the right location
                GameObject go = (GameObject)Instantiate(ctp.prefab, new Vector3(x, 0, y), Quaternion.identity);
                go.transform.parent = gameObject.transform;
                return;
            }
        }
        //if we got here then there was no colour matched

        Debug.LogError("colour: " + c.ToString() + " was not matched");
    }
Пример #18
0
    void OnPixel(Color32 color, Vector3 position, PixelContext context)
    {
        var entry = m_prefabs.FirstOrDefault(e => e.color.Equals(color));

        if (entry != null)
        {
            var go = (GameObject)Instantiate(entry.prefab, position, Quaternion.identity);
            go.transform.parent = transform;
            m_loadedObjects.Add(go);

            if (color.Equals(m_fenceColor) && m_useFence)
            {
                bool down  = context.Down.Equals(m_emptyColor);
                bool up    = context.Up.Equals(m_emptyColor);
                bool left  = context.Left.Equals(m_emptyColor);
                bool right = context.Right.Equals(m_emptyColor);

                if (down || up || left || right)
                {
                    Quaternion rotation = Quaternion.identity;

                    var fenceGO = (GameObject)Instantiate(m_fencePrefab, position, rotation);
                    fenceGO.transform.parent = transform;
                    m_loadedObjects.Add(fenceGO);
                }
            }
        }
    }
Пример #19
0
        public static void ChangeTargetColorToAlpha(Texture2D originalTexture, Texture2D modifiedTexture, Color32 targetColor)
        {
            int targetColorFoundCount = 0;

            for (int y = 0; y < originalTexture.height; y++)
            {
                for (int x = 0; x < originalTexture.width; x++)
                {
                    Color32 currentOriginalPixelColor = originalTexture.GetPixel(x, y);
                    byte    alphaValue = 255;
                    if (currentOriginalPixelColor.Equals(targetColor))
                    {
                        targetColorFoundCount++;
                        alphaValue = 0;
                    }

                    Color32 modifiedTexturePixelColor = new Color32(currentOriginalPixelColor.r,
                                                                    currentOriginalPixelColor.g,
                                                                    currentOriginalPixelColor.b,
                                                                    alphaValue);

                    modifiedTexture.SetPixel(x, y, modifiedTexturePixelColor);
                }
            }
            if (targetColorFoundCount > 0)
            {
                modifiedTexture.Apply();
            }
#if DEBUGGING
            Debug.Log("TargetColor: " + targetColor.ToString() + " found " + targetColorFoundCount + " times");
#endif
        }
Пример #20
0
    void degenerateTile(int x, int y)
    {
        Color32    pixelColor  = map.GetPixel(x, y);
        Vector3Int currentCell = new Vector3Int(x, y, 0);
        Color32    red         = Color.red;

        if (pixelColor.a == 0)
        {
            // The pixel is transparrent. Let's ignore it!
            return;
        }
        else if (pixelColor.Equals(red))
        {
            foreach (colorToTile colorMapping in colorMappings)
            {
                if (colorMapping.color.Equals(pixelColor))
                {
                    colliderGrid.SetTile(currentCell, null);
                }
            }
            return;
        }
        else
        {
            foreach (colorToTile colorMapping in colorMappings)
            {
                if (colorMapping.color.Equals(pixelColor))
                {
                    tilemapGrid.SetTile(currentCell, null);
                }
            }
        }
    }
Пример #21
0
            public override List <UIVertex> GetUIVertexTriangleStream(Vector2 offset, Vector2 scale, Color32 color)
            {
                uiVertexTriangleStream.Clear();

                color = (Color)color * (Color)this.color;

                if (color.Equals(uiVerts[0].color))                 //no change in color, skip setting it
                {
                    for (int i = 0; i < uiVerts.Length; i++)
                    {
                        uiVerts[i].position = new Vector3((points[i].x + offset.x) * scale.x,
                                                          (points[i].y + offset.y) * scale.y,
                                                          0f);
                    }
                }
                else
                {
                    for (int i = 0; i < uiVerts.Length; i++)
                    {
                        uiVerts[i].color    = color;
                        uiVerts[i].position = new Vector3((points[i].x + offset.x) * scale.x,
                                                          (points[i].y + offset.y) * scale.y,
                                                          0f);
                    }
                }

                for (int i = 0; i < triangles.Length; i++)
                {
                    uiVertexTriangleStream.Add(uiVerts[triangles[i]]);
                }

                return(uiVertexTriangleStream);
            }
Пример #22
0
 public void UpdateColor()
 {
     if (!isInvincible)
     {
         Color32 mainColor;
         if (level == -1)
         {
             mainColor = WHITE;
         }
         else
         {
             mainColor = levels[level % 5];
         }
         targetColor = new Color32(mainColor.r, mainColor.g, mainColor.b, alpha[life]);
         if (!currentColor.Equals(targetColor))
         {
             lastTimeColor = currentColor;
             colorTimer.Reset();
         }
         else
         {
             currentColor  = targetColor;
             lastTimeColor = currentColor;
         }
     }
     else
     {
         targetColor = levels[(level + 5) % 5];
     }
     Render();
 }
Пример #23
0
    void SpawnAsteroidAt(Color32 c, int x, int y)
    {
        //If the pixel is black, then nothing should be there.
        if (c.Equals(backgroundColor))
        {
            return;
        }

        //Find the right color in our map

        //Not really optimized. Try a dictionary instead for max performance.
        foreach (ColorToPrefab ctp in colorToPrefab)
        {
            if (ctp.color.Equals(c))
            {
                Quaternion randomRot = Quaternion.Euler(Random.Range(0, 180f), Random.Range(0, 180f), Random.Range(0, 180f));
                GameObject go        = (GameObject)Instantiate(ctp.prefabs[Random.Range(0, ctp.prefabs.Length)], new Vector3(x * spacing, Random.Range(heightRange.x, heightRange.y), y * spacing), randomRot);
                go.GetComponent <Renderer>().material = asteroidMaterials[Random.Range(0, asteroidMaterials.Length)];
                go.transform.localScale = new Vector3((int)Random.Range(minSize.x, maxSize.x), (int)Random.Range(minSize.y, maxSize.y), (int)Random.Range(minSize.z, maxSize.z));
                go.transform.SetParent(this.transform);
                return;
            }
        }

        //If we are here, there is not a matching color in the array.
        Debug.LogError("No color to prefab dound for " + c.ToString());
        return;
    }
Пример #24
0
        void SpawnTileAt(Transform parent, Color32 c, int x, int y)
        {
            if (c.Equals(Empty))
            {
                return;
            }

            SO_Color2Prefab mySO  = LevelPalette;
            string          sufix = "(Clone)";

            foreach (Color2Prefab ctp in mySO.color2prefab)
            {
                if (ctp.color.Equals(c))
                {
                    GameObject go = (GameObject)Instantiate(ctp.prefab, new Vector3(x, y, 0), Quaternion.identity);
                    go.name = go.name.Substring(0, go.name.Length - sufix.Length);

                    //to group or not to group
                    if (ctp.excludeFromMerge == false)
                    {
                        go.transform.SetParent(staticsParent.transform);
                        SetStaticsCollider(go.transform);
                        go.isStatic = true;
                    }
                    else
                    {
                        go.transform.SetParent(parent);
                    }
                    return;
                }
            }
            Debug.LogError("no more items in list: " + c.ToString());
        }
Пример #25
0
    List <ComputerMove> getComputerMoves(Color32 color)
    {
        List <ComputerMove> posibleMoves = new List <ComputerMove>();
        List <BasePiece>    pieces       = new List <BasePiece>();

        if (color.Equals(new Color32(25, 25, 25, 255)))
        {
            pieces = mBlackPieces;
        }
        else
        {
            pieces = mWhitePieces;
        }

        foreach (BasePiece piece in pieces)
        {
            piece.computerOptions();
            foreach (Cell tile in piece.mHighlightedCells)
            {
                posibleMoves.Add(new ComputerMove(piece.mCurrentCell, tile, piece));
            }
        }

        return(posibleMoves);
    }
Пример #26
0
 void Update()
 {
     if (!targetColor.Equals(currentColor))
     {
         colorTimer.Tick(Time.deltaTime);
         if (colorTimer.Expired())
         {
             currentColor  = targetColor;
             lastTimeColor = targetColor;
             RenderColor();
         }
         else
         {
             currentColor = new Color32(targetColor.r, targetColor.g, targetColor.b, GetChannelLerp(3, lastTimeColor, targetColor, colorTimer.percent));
             RenderColor();
         }
     }
     if (bouncingState)
     {
         bouncingCounter.Tick(Time.deltaTime);
         if (bouncingCounter.Expired())
         {
             bouncingState = false;
             this.transform.localPosition = initPosition;
         }
         else
         {
             this.transform.localPosition = initPosition + bouncingDirection * Mathf.Sin(Mathf.PI * bouncingCounter.percent) * .1f;
         }
     }
 }
    void SpawnTileAt(Color32 c, int x, int y)
    {
        // If this is a transparent pixel, then it's meant to just be empty.
        if (c.a <= 0)
        {
            return;
        }

        // Find the right color in our map

        // NOTE: This isn't optimized. You should have a dictionary lookup for max speed
        foreach (ColorToPrefab ctp in colorToPrefab)
        {
            if (c.Equals(ctp.color))
            {
                // Spawn the prefab at the right location
                GameObject go = (GameObject)Instantiate(ctp.prefab, new Vector3(x, y, 0), Quaternion.identity);
                go.transform.SetParent(this.transform);
                // maybe do more stuff to the gameobject here?
                return;
            }
        }

        // If we got to this point, it means we did not find a matching color in our array.

        Debug.LogError("No color to prefab found for: " + c.ToString());
    }
Пример #28
0
    private void SpawnTileAt(Color32 pixelColor, int x, int y, Transform parent)
    {
        if (pixelColor.a <= 0)
        {
            return;
        }

        foreach (ColorToPrefab colorToPrefab in ColorsToPrefabs)
        {
            if (pixelColor.Equals(colorToPrefab.TypeColor))
            {
                if (colorToPrefab.Prefab != null)
                {
                    GameObject gameObject = ObjectPoolManager.Instance.GetObjectFromPool(colorToPrefab.Prefab.name);
                    gameObject.transform.SetPositionAndRotation(new Vector3(x, y, 0), Quaternion.identity);
                    gameObject.transform.SetParent(parent);
                    gameObject.name = colorToPrefab.Prefab.name;
                    return;
                }
                else
                {
                    Debug.Log(colorToPrefab.Prefab.name);
                    colorToPrefab.Prefab = new GameObject("EmptyGameObject");
                    return;
                }
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        textTimer += Time.deltaTime;
        if (textTimer >= 0.33f)
        {
            textTimer = 0.0f;
            switch (currentWord)
            {
            case firstWord:
                updateWordColor(firstWord, 5);
                currentWord = secondWord;
                break;

            case secondWord:
                updateWordColor(secondWord, 12);
                currentWord = firstWord;

                if (currentColor.Equals(startingColor))
                {
                    currentColor = endingColor;
                }
                else
                {
                    currentColor = startingColor;
                }

                break;
            }
        }
    }
Пример #30
0
    void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag == "ColorWheel")
        {
            Color32 sectionColor = (Color32)collision.GetComponent <SpriteRenderer>().color;
            if (!sectionColor.Equals(this.color))
            {
                GameManager.Instance.EndGame();
            }
        }

        if (collision.tag == "Pin")
        {
            GameManager.Instance.EndGame();
        }
        else if (collision.tag == "Rotator")
        {
            if (!GameManager.Instance.isGameOver)
            {
                GameManager.Instance.pinCount += 1;
                GameManager.Instance.SetScore();
            }
            isPinned = true;
            transform.SetParent(collision.transform);
        }
    }