public static FuelTree Spawn(string id, Vector3 position, int fuels) { tmpTree = null; for (int i = 0; i < pool.Count; i++) { if (!pool[i].isActiveAndEnabled) { tmpTree = pool[i]; tmpTree.gameObject.SetActive(true); break; } } if (tmpTree == null) { tmpTree = Instantiate(PrefabManager.Current.FuelTreePrefab); pool.Add(tmpTree); } tmpTree.transform.position = position; tmpTree.LoadedObjectDefinition = id; tmpTree.Fuels = fuels; WrappingWorld.Register(tmpTree); return(tmpTree); }
public void LoadWorld(WorldGenerator.WorldDefinition world) { isLoading = true; ResetWorld(); RocketToSpace.Current.gameObject.SetActive(true); PlayerCharacter.Current.gameObject.SetActive(true); PlayerCharacter.Current.ResetWorld(); RocketToSpace.Current.ResetWorld(); loadedWorld = world.ID; int width = world.Tiles.GetLength(0); int height = world.Tiles.GetLength(1); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { SpawnTile(x, y, world.Tiles[x, y], world.Tiles); } } for (int i = 0; i < world.ObjectList.Count; i++) { switch (world.ObjectList[i].Type) { case ObjectType.FuelPickup: FuelPickup.Spawn(world.ObjectList[i].ID, world.ObjectList[i].Position); break; case ObjectType.FuelTree: FuelTree.Spawn(world.ObjectList[i].ID, world.ObjectList[i].Position, world.ObjectList[i].RemainingIntValue); break; } } Register(RocketToSpace.Current); isLoading = false; }