コード例 #1
0
        public bool Decode(Encoding encodings)
        {
            Debug.Log("EncodableLevel Encoding Data\n" + encodings.DebugString());
//			int count = encodings.Int(0);
//			for (int i = 0 ; i < count ; i++)
//			{
//				PartGenerator generator = ObjectPoolManager.GetObject(GameSettings.instance.partGeneratorPrefab);
//				generator.Decode(encodings.SubEncoding(1+i));
//			}
            int i = 0;

            MechanismType [] mechanismTypes = new MechanismType [] { MechanismType.Generator, MechanismType.Grabber, MechanismType.WeldingRig };
            foreach (MechanismType type in mechanismTypes)
            {
                int count = encodings.Int(i);
                i++;
                for (int j = 0; j < count; j++)
                {
                    Mechanism newMechanism = ObjectPoolManager.GetObject <Mechanism>(GameSettings.instance.GetMechanism(type));
                    newMechanism.Decode(encodings.SubEncoding(i));
                    i++;
                }
            }

            GridManager.instance.targetConstructions = encodings.Int(i + 0);
//			GridManager.instance.targetConstructions2 = encodings.Int(i+1);
            Construction target0 = Construction.DecodeCreate(encodings.SubEncoding(i + 2));

//			Debug.Log ("Setting Target0 "+encodings.SubEncoding(i+2).DebugString());
//			Debug.Log ("Setting Target0 "+Encoding.Encode(target0));
            GridManager.instance.SetTarget(target0);
            target0.DestroySelf();
//			Construction target0 = Construction.DecodeCreate(encodings.SubEncoding(i+3));
//			CoroutineUtils.WaitOneFrameAndDo(() => GridManager.instance.SetTarget(target0));

            GridManager.instance.LevelOptions = encodings.Int(i + 4);
            return(true);
        }