void LoadColor(GameDataReader reader)
        {
            int count = reader.ReadInt();
            int max   = count <= colors.Length ? count : colors.Length;
            int i     = 0;

            for (; i < max; ++i)
            {
                SetColor(reader.ReadColor(), i);
            }
            if (count > max)
            {
                for (; i < count; i++)
                {
                    reader.ReadColor();
                }
            }
            else if (count < max)
            {
                for (; i < max; i++)
                {
                    SetColor(Color.white, i);
                }
            }
        }
Beispiel #2
0
        private void LoadColors(GameDataReader reader)
        {
            int count = reader.ReadInt();
            int max   = Mathf.Min(count, _colors.Length);

            int i = 0;

            for (; i < max; i++)
            {
                SetColor(reader.ReadColor(), i);
            }

            if (count > _colors.Length)
            {
                /// Read excess colors to maintain file index at correct position.
                for (; i < count; i++)
                {
                    reader.ReadColor();
                }
            }
            else if (count < _colors.Length)
            {
                /// Set missing colors to default.
                for (; i < _colors.Length; i++)
                {
                    SetColor(Color.white, i);
                }
            }
        }
Beispiel #3
0
 public override void Load(GameDataReader reader)
 {
     if (reader.Version >= 7)
     {
         base.Load(reader);
     }
     nextSequentialIndex = reader.ReadInt();
 }
Beispiel #4
0
        public override void Load(GameDataReader reader)
        {
            int savedCount = reader.ReadInt();

            for (int i = 0; i < savedCount; i++)
            {
                levelObjects[i].Load(reader);
            }
        }
Beispiel #5
0
        public override void Load(GameDataReader reader)
        {
            int count = reader.ReadInt();

            for (int i = 0; i < count; ++i)
            {
                persistableObjects[i].Load(reader);
            }
        }
        private IEnumerator LoadGame(GameDataReader reader)
        {
            int version = reader.Version;

            int count = version <= 0 ? -version : reader.ReadInt();

            if (version >= 3)
            {
                Random.State state = reader.ReadRandomState();
                if (!reseedOnLoad)
                {
                    Random.state = state;
                }
                CreationSpeed       = creationSpeedSlider.value = reader.ReadFloat();
                creationProgress    = reader.ReadFloat();
                DestructionSpeed    = destructionSpeedSlider.value = reader.ReadFloat();
                destructionProgress = reader.ReadFloat();
            }

            yield return(LoadLevel(version < 2 ? 1 : reader.ReadInt()));

            if (version >= 3)
            {
                GameLevel.Current.Load(reader);
            }

            for (int i = 0; i < count; i++)
            {
                int   factoryId  = version >= 5 ? reader.ReadInt() : 0;
                int   shapeId    = version > 0 ? reader.ReadInt() : 0;
                int   materialId = version > 0 ? reader.ReadInt() : 0;
                Shape instance   = shapeFactories[factoryId].Get(shapeId, materialId);
                instance.Load(reader);
            }

            for (int i = 0; i < shapes.Count; i++)
            {
                shapes[i].ResolveShapeInstances();
            }
        }
        IEnumerator LoadGame(GameDataReader reader)
        {
            int version = reader.Version;
            int count   = version > 0 ? reader.ReadInt() : -version;

            if (version >= 3)
            {
                Random.State state = reader.ReadRandomState();
                if (resetOnLoad)
                {
                    Random.state = state;
                }
                creationSpeedSlider.value    = CreationSpeed = reader.ReadFloat();
                creationProgress             = reader.ReadFloat();
                destructionSpeedSlider.value = DestructionSpeed = reader.ReadFloat();
                destructionProgress          = reader.ReadFloat();
            }
            yield return(LoadLevel(version < 2 ? 1 : reader.ReadInt()));

            if (version >= 3)
            {
                GameLevel.Current.Load(reader);
            }
            var tran = transform;

            for (int i = 0; i < count; i++)
            {
                int   factoryId = version >= 5 ? reader.ReadInt() : 0;
                int   shapeId   = version > 0 ? reader.ReadInt() : 0;
                int   matId     = version > 0 ? reader.ReadInt() : 0;
                Shape o         = shapeFactorys[factoryId].Get(shapeId, matId);
                o.transform.parent = tran;
                o.Load(reader);
                shapes.Add(o);
            }
        }
 public override void Load(GameDataReader reader)
 {
     _sequentialIndex = reader.ReadInt();
 }