Exemple #1
0
    void Start()
    {
        LevelColors = ColorFactory.FromTheme(Theme);

        var solidBlocks = GameObject.FindGameObjectsWithTag("Solid");

        Colorize(solidBlocks, ColorFactory.Black);

        _player               = GameObject.FindGameObjectWithTag("Player");
        _color1Blocks         = GameObject.FindGameObjectsWithTag("Color1");
        _color2Blocks         = GameObject.FindGameObjectsWithTag("Color2");
        _colorMixedBlocks     = GameObject.FindGameObjectsWithTag("ColorMixed");
        _antiColor1Blocks     = GameObject.FindGameObjectsWithTag("AntiColor1");
        _antiColor2Blocks     = GameObject.FindGameObjectsWithTag("AntiColor2");
        _antiColorMixedBlocks = GameObject.FindGameObjectsWithTag("AntiColorMixed");

        Colorize(_color1Blocks, LevelColors.Color1);
        Colorize(_color2Blocks, LevelColors.Color2);
        Colorize(_colorMixedBlocks, LevelColors.ColorMixed);
        Colorize(_antiColor1Blocks, LevelColors.Color1);
        Colorize(_antiColor2Blocks, LevelColors.Color2);
        Colorize(_antiColorMixedBlocks, LevelColors.ColorMixed);

        Colorize(GameObject.FindGameObjectsWithTag("Trigger"), ColorFactory.Transparent);
        Colorize(GameObject.FindGameObjectsWithTag("ZeroGravity"), ColorFactory.Gray);

        UpdateColors(ColorInput.None);
    }
    /// <summary>
    /// Gets the current level's color from the save
    /// Sets the color to the level
    /// </summary>
    void SetColor()
    {
        if (!PlayerPrefs.HasKey("Color"))
        {
            PlayerPrefs.SetString("Color", "Blue");
            PlayerPrefs.Save();
        }

        currentColorString = PlayerPrefs.GetString("Color");

        LevelColor newColor = new LevelColor();

        for (int i = 0; i < colors.Length; i++)
        {
            newColor = colors[i];
            if (newColor.ColorString == currentColorString)
            {
                colorIndex = i;
                break;
            }
        }

        cam.backgroundColor = newColor.backgroundColor;
        foreach (Transform t in conveyorParent)
        {
            if (t.CompareTag("Conveyor"))
            {
                t.GetComponent <Conveyor>().SetColor(newColor.conveyorColor);
            }
        }
    }
    /// <summary>
    /// Picks the next color in the color array
    /// Changes the color of the level
    /// </summary>
    public void ChangeColor()
    {
        colorIndex++;

        if (colorIndex >= colors.Length)
        {
            colorIndex = 0;
        }

        LevelColor newColor = colors[colorIndex];

        cam.backgroundColor = newColor.backgroundColor;

        foreach (Transform t in conveyorParent)
        {
            if (t.CompareTag("Conveyor"))
            {
                t.GetComponent <Conveyor>().SetColor(newColor.conveyorColor);
            }
        }
        currentColorString = newColor.ColorString;


        PlayerPrefs.SetString("Color", currentColorString);
        PlayerPrefs.Save();
    }
Exemple #4
0
    //变更关卡颜色
    public void ChooseLevelColor()
    {
        int index = -1;

        do
        {
            index = Random.Range(0, colors.Count);
        } while (currentLevelColor != null && index == colors.IndexOf(currentLevelColor));
        currentLevelColor = colors[index];
    }
Exemple #5
0
 void Awake()
 {
     _Instance = this;
     if (PlayerPrefs.GetInt(ConstValue.XmlDataKeyName.PlayerInGameSuccessCount) == 0)
     {
         currentLevelColor = colors[0];
     }
     else
     {
         ChooseLevelColor();
     }
 }