Beispiel #1
0
    /// <summary>
    /// Awakes this instance.
    /// </summary>
    void Awake()
    {
        //ゲームの任意の部分からアクセスされる変数firstSceneLoadedに影響します
        FirstSceneLoaded = this.FirstSceneToLoad;

        // まず、競合する他のインスタンスがあるかどうかを確認します
        if (CharacterList != null || EquipmentList != null || ItemList != null)
        {
            // その場合、他のインスタンスを破棄します
            Destroy(gameObject);
        }



        PreviousScene        = string.Empty;
        CurrentScene         = string.Empty;
        PlayerPosition       = default(Vector3);
        PlayerXPosition      = default(int);
        PlayerYPosition      = default(int);
        PlayerZPosition      = default(int);
        ControlsBlocked      = false;
        JustEnteredTheScreen = false;



        // ここで、シングルトンインスタンスを保存します
        CharacterList = new   List <CharactersData>();
        EquipmentList = new List <ItemsData> ();
        ItemList      = new List <ItemsData> ();

        //ゲームデータを初期化する
        Datas.PopulateDatas();

        //新しいゲームのデータを初期化します
        InitializeDatas();

        //さらに、シーン間で破壊しないようにします(これはオプションです)
        DontDestroyOnLoad(gameObject);

        //指定した最初のシーンを表示する
        SceneManager.LoadScene(FirstSceneLoaded);
    }
Beispiel #2
0
    /// <summary>
    /// Awakes this instance.
    /// </summary>
    void Awake()
    {
        //Affect the variable firstSceneLoaded to be accesed from any part of the game
        FirstSceneLoaded = this.FirstSceneToLoad;

        // First we check if there are any other instances conflicting
        if (CharacterList != null || EquipmentList != null || ItemList != null)
        {
            // If that is the case, we destroy other instances
            Destroy(gameObject);
        }



        PreviousScene        = string.Empty;
        CurrentScene         = string.Empty;
        PlayerPosition       = default(Vector3);
        PlayerXPosition      = default(int);
        PlayerYPosition      = default(int);
        PlayerZPosition      = default(int);
        ControlsBlocked      = false;
        JustEnteredTheScreen = false;



        // Here we save our singleton instance
        CharacterList = new   List <CharactersData>();
        EquipmentList = new List <ItemsData> ();
        ItemList      = new List <ItemsData> ();

        //Initialize games datas
        Datas.PopulateDatas();

        //initialize data for a new game
        InitializeDatas();

        // Furthermore we make sure that we don't destroy between scenes (this is optional)
        DontDestroyOnLoad(gameObject);

        SceneManager.LoadScene(FirstSceneLoaded);
    }
 // Use this for initialization
 /// <summary>
 /// Starts this instance.
 /// </summary>
 void Start()
 {
     Datas.PopulateDatas();
 }