示例#1
0
    // Save the color array and the currentDay value to the Player Prefs
    public bool saveSettings()
    {
        PlayerPrefs.SetInt(currentDayKey, currentDay);
        bool savedTimes  = PlayerPrefsX.SetFloatArray(timeKey, times);
        bool savedColors = PlayerPrefsX.SetColorArray(colorsKey, colors);

        return(savedTimes && savedColors);
    }
    /// <summary>
    /// Remove color data index in ArrayPrefs.
    /// </summary>
    /// <param name="playerPrefsKey"></param>
    /// <param name="c"></param>
    /// <param name="t"></param>
    /// <param name="index"></param>
    private void Del(string playerPrefsKey, Color[] c, ColorType t, int index)
    {
        List <Color> list = new List <Color> ( );

        list.AddRange(c);
        list.RemoveAt(index);

        PlayerPrefsX.SetColorArray(playerPrefsKey, list.ToArray( ));
    }
示例#3
0
    // Use this for initialization
    void Start()
    {
        ResetColorsButton = false;
        colors            = PlayerPrefsX.GetColorArray(colorsKey);
        times             = PlayerPrefsX.GetFloatArray(timeKey);
        currentDay        = PlayerPrefs.GetInt(currentDayKey);

        if (!cam)
        {
            cam = FindObjectOfType <Camera>();
        }

        if (colors.Length < 1 || times.Length < 1)
        {
            Debug.Log("Initializing Colors!");
            colors = new Color[365];
            times  = new float[365];
            for (int i = 0; i < 365; i++)
            {
                colors[i] = new Color(1, 1, 1);
                times[i]  = 0;
            }
            currentDay = 0;
            PlayerPrefsX.SetColorArray(colorsKey, colors);
            PlayerPrefsX.SetFloatArray(timeKey, times);
            PlayerPrefs.SetInt(currentDayKey, 0);
        }

        //printColors();

        //visController.enabled = false;

        //printColors();

        //float bonus = 0.1f;

        //float RMin = 0.7f + bonus;
        //float RMax = 0.9f + bonus;
        //float GMin = 0.32f + bonus;
        //float GMax = 0.6f + bonus;
        //float BMin = 0.0f + bonus;
        //float BMax = 0.39f + bonus;

        //for (int j = 0; j < colors.Length; j++)
        //{
        //    if (j % 2 == 0)
        //        colors[j] = new Color(Random.Range(RMin, RMax), Random.Range(GMin, GMax), Random.Range(BMin, BMax), 1);
        //    else
        //        colors[j] = new Color(Random.Range(1 - RMin, 1 - RMax), Random.Range(1 - GMin, 1 - GMax), Random.Range(1 - BMin, 1 - BMax), 1);
        //}

        //for (int i = 0; i < times.Length; i++)
        //{
        //    times[i] = Random.Range(240, 375);
        //}
    }
    public void SaveColour()
    {
        // 03/02/2017 -> Lewis -> Updated code so now the colours are stored in a color array rather individual strings.
        // I have commented the original code in for now, so if we need to revert back to the old way we can do it quickly.

        // find the objects
        player1Color = GameObject.Find("Player1Text").GetComponent <Text>().color;
        player2Color = GameObject.Find("Player2Text").GetComponent <Text>().color;
        // set playerPrefs based on value toString()
        //PlayerPrefs.SetString("Team0Colour", player1Color.ToString());
        //PlayerPrefs.SetString("Team1Colour", player2Color.ToString());

        Color[] playerColors = new Color[2];
        playerColors[0] = player1Color;
        playerColors[1] = player2Color;
        PlayerPrefsX.SetColorArray("PlayerColors", playerColors);
    }
示例#5
0
 private void SavePresets()
 {
     if (colorPages != null)
     {
         int colorsCount = 0;
         foreach (var cp in colorPages)
         {
             colorsCount += cp.PageColors.Count;
         }
         var colors = new List <Color>();
         foreach (var cp in colorPages)
         {
             colors = colors.Concat(cp.PageColors).ToList();
         }
         var presets = new Color[colorsCount];
         for (int i = 0; i < colors.Count; i++)
         {
             presets[i] = colors.ElementAt(i);
         }
         PlayerPrefsX.SetColorArray(COLOR_PRESETS_KEY, presets);
     }
 }
 /// <summary>
 /// Set list color to ArrayPrefs.
 /// </summary>
 /// <param name="list"></param>
 /// <param name="t"></param>
 public void SetColorArr(List <Color> list, PlayerPrefsKeys t)
 {
     PlayerPrefsX.SetColorArray(t.ToString( ), list.ToArray( ));
 }