public void Load() { Dictionary <Vec2, ResourceType> types = new Dictionary <Vec2, ResourceType>(); SetTypes(TestWriter.Load(ChunkSaveName(), out types)); // lataa tiilet // lataa tiilien resurssit foreach (var keyvaluepair in types) { Vec2 v = keyvaluepair.Key; ResourceType type = keyvaluepair.Value; GameObject go = null; if (ResourceManager.Instance.IsTrunkType(type)) // kaikki destroyed { go = ObjectPool.instance.GetObjectForType(Resource.GetResourcePrefabName(type), false); go.gameObject.GetComponent <Resource>().Init(true); go.transform.position = new Vector3(v.X + offsetX * CHUNK_SIZE, v.Y + offsetY * CHUNK_SIZE, ZlayerManager.GetZFromY(go.transform.position)); go.transform.parent = _parent.transform; worldObjects[keyvaluepair.Key] = go; } else // #HaCK ctrl_c_ctrl_v { go = ObjectPool.instance.GetObjectForType(Resource.GetResourcePrefabName(type), false); if (go != null) { go.gameObject.GetComponent <Resource>().Init(false); go.transform.position = new Vector3(v.X + offsetX * CHUNK_SIZE, v.Y + offsetY * CHUNK_SIZE, ZlayerManager.GetZFromY(go.transform.position)); go.transform.parent = _parent.transform; worldObjects[keyvaluepair.Key] = go; } } } }