예제 #1
0
    public static bool Load(int savenum, ref FieldScript field)
    {
        if (PlayerPrefs.HasKey(savenum + ".cstatsr") && field != false)
        {
            lengthx = PlayerPrefs.GetInt(savenum + ".x");
            lengthz = PlayerPrefs.GetInt(savenum + ".z");
            field.SetSize(lengthx - 2, lengthz - 2);
            bool[] CellStatsRS;
            CellStatsRS = new bool[lengthx * lengthz];

            CellStatsRS = PlayerPrefsX.GetBoolArray(savenum + ".cstatsr");
            for (int i = 0; i < lengthx; i++)
            {
                for (int z = 0; z < lengthz; z++)
                {
                    field.CellStatsR[i, z] = CellStatsRS[i * lengthz + z];
                }
            }

            for (int i = 1; i < lengthx - 1; i++)
            {
                for (int z = 1; z < lengthz - 1; z++)
                {
                    if (field.CellStatsR[i, z])
                    {
                        field.Cells[i, z].transform.rotation = field.AliveR;
                        field.ReActivate(i, z);
                    }
                    if (!field.CellStatsR[i, z])
                    {
                        field.Cells[i, z].transform.rotation = field.DeadR;
                    }
                    //FIXME
                    //quick solution
                }
            }
            field.SetAllModefied();
            Debug.Log("loaded on " + savenum + " with: " + lengthx + ", " + lengthz);
            return(true);
        }
        else
        {
            Debug.Log("Load fail");
            return(false);
        }
    }