示例#1
0
文件: Stats.cs 项目: Deus0/zoxel
        public SerializeableStats GetSerializeableClone()
        {
            SerializeableStats myClone = new SerializeableStats();

            myClone.stats      = stats.ToArray();
            myClone.states     = states.ToArray();
            myClone.regens     = regens.ToArray();
            myClone.attributes = attributes.ToArray();
            myClone.levels     = levels.ToArray();
            return(myClone);
        }
示例#2
0
文件: Stats.cs 项目: Deus0/zoxel
        public static Stats FromJson(string json)
        {
            if (json == null || json == "")
            {
                return(new Stats());
            }
            SerializeableStats myClone = UnityEngine.JsonUtility.FromJson <SerializeableStats>(json);
            Stats stats = new Stats {
            };

            if (myClone.stats == null)
            {
                Debug.LogError("JSON Null inside stats:\n" + json);
                return(new Stats());
            }
            stats.FromClone(myClone);
            return(stats);
        }
示例#3
0
文件: Stats.cs 项目: Deus0/zoxel
 public void FromClone(SerializeableStats myClone)
 {
     InitializeStats(myClone.stats.Length);
     if (myClone.stats != null)
     {
         for (int i = 0; i < myClone.stats.Length; i++)
         {
             stats[i] = myClone.stats[i];
         }
     }
     else
     {
         stats = new BlitableArray <Staz>(0, Allocator.Persistent);
     }
     if (myClone.states != null)
     {
         InitializeStates(myClone.states.Length);
         for (int i = 0; i < myClone.states.Length; i++)
         {
             states[i] = myClone.states[i];
         }
     }
     else
     {
         states = new BlitableArray <StateStaz>(0, Allocator.Persistent);
     }
     if (myClone.regens != null)
     {
         InitializeRegens(myClone.regens.Length);
         for (int i = 0; i < myClone.regens.Length; i++)
         {
             regens[i] = myClone.regens[i];
         }
     }
     else
     {
         regens = new BlitableArray <RegenStaz>(0, Allocator.Persistent);
     }
     if (myClone.attributes != null)
     {
         InitializeAttributes(myClone.attributes.Length);
         for (int i = 0; i < myClone.attributes.Length; i++)
         {
             attributes[i] = myClone.attributes[i];
         }
     }
     else
     {
         attributes = new BlitableArray <AttributeStaz>(0, Allocator.Persistent);
     }
     if (myClone.levels != null)
     {
         InitializeLevels(myClone.levels.Length);
         for (int i = 0; i < myClone.levels.Length; i++)
         {
             levels[i] = myClone.levels[i];
         }
     }
     else
     {
         levels = new BlitableArray <Level>(0, Allocator.Persistent);
     }
 }
示例#4
0
文件: Stats.cs 项目: Deus0/zoxel
        public string GetJson()
        {
            SerializeableStats myClone = GetSerializeableClone();

            return(UnityEngine.JsonUtility.ToJson(myClone));
        }