Worlds


You can setup worlds within your game that will typically each contain a number of Levels. World functionality is based upon GameItem and it’s related classes and so also inherit all features such as the ability to use in app purchase, unlocking, selection screens and so forth. This page will focus on additions and differences from those documented elsewhere.

Setup

You can setup worlds automatically through GameManager or manually through scripting. When using GameManager, you specify the number of worlds that you want and then the worlds will be initialised based upon localisation strings and resource files as documented in the information about GameItems.

When setting up Worlds you can specify whether Levels should also be automatically created. If you enable automatic creation of levels then you will need to specify ‘Level Number Ranges’ which are unique identifiers for the created levels that will be used when looking up resources etc. The numbers themselves are otherwise not too important however it is advisable to leave a gap in the ranges in case you want to later add more levels.

You can access all Worlds using the GameItemManager available through GameManager.Instance.Worlds. Any levels for a world are available through the World’s Levels property. When a world is selected any levels it contains will also be available through GameManager.Instance.Levels.

Object Model

The World class represents an instance of a World and inherits from GameItem exposing all of the same properties and methods. Character overrides IdentifierBase to ‘World’ and IdentifierBasePrefs to ‘W’ to distinguish it from other GameItems.

Woeld also exposes any Levels it contains through the Levels property and has a LevelStarCountTotal shortcut property for retrieving the total number of stars across all contained Levels.

Configuration files should be placed into the Resources\World\ folder with the name World_<ID> where ID corresponds to the World’s ID.

World Selection

CreateWorldButtons and WorldButton behave in a similar to their base classes for laying out the character selection display. WorldButton additionally listens for messages of type WorldPurchasedMessage to update the display automatically if they are purchased through in app purchasing. WorldButton will also set the Worlds contained Levels into GameManager.Instance.Levels if the World is unlocked and clicked.

The selected World is always available through the GameManager.Instance.Worlds.Selected property.

World Display

The selected World is always available through the GameManager.Instance.Worlds.Selected property and so through this you can access things such as the currently selected Worlds name, description, extension data etc.

The ShowWorldInfo component can be added to a gameobject with a UI Text component to automatically update the Text display with customisable information about the currently selected World .

Prefabs

Prefabs associated with Worlds can be setup and retrieved as discussed in the description on GameItem.

The World specific InstantiateWorldPrefab component is an implementation of InstantiatePrefab that will use prefabs from the currently selected World.

Sprites

Prefabs associated with Worlds can be setup and retrieved as discussed in the description on GameItem.

The World specific SetImageToWorldSprite and SetSpriteRendererToWorldSprite components behave in a similar to their base components for setting sprites from the currently selected World.

Unlocking

Like all GameItems you can have World in a locked status. Unlocking can be done through code, by collecting coins and adding a UI button with the UnlockWorldButton attached or through in app purchase.

See also

If you have any thoughts or suggestions on improvements or additions to the World features then please let us know!