C# Game Programming Cookbook for Unity 3D / Программирование игр на Unity 3D C#. Книга готовых решений.: 3.3.1 Разбор скрипта

Оглавление
Английский оригинал Перевод на русский

Сожалеем, но текст оригинала доступен только зарегистрированным пользователям.

public class BasePlayerManager : MonoBehavior
{
public bool didInit;
// the user manager and AI controllers are publically accessible so
// that our individual control scripts can access them easily
public BaseUserManager DataManager;
// note that we initialize on Awake in this class so that it is
// ready for other classes to access our details when they
// initialize on Start
public virtual void Awake ()
{
didInit=false;
Init();
}

ilia1395 26.10.14 в 13:08

0

public virtual void Init ()
{ // cache ref to our user manager
DataManager= gameObject.GetComponent<BaseUserManager>();
if(DataManager==null) DataManager= gameObject.AddComponent<BaseUserManager>();
// do play init things in this function
didInit= true;
}

ilia1395 26.10.14 в 13:08

0

public virtual void GameFinished()
{
DataManager.SetIsFinished(true);
}
public virtual void GameStart()
{
DataManager.SetIsFinished(false);
}
}

ilia1395 26.10.14 в 13:08

0
Минутку...