Beispiel #1
0
    public void changeScene(string destination, string source)
    {
        if (destination != "LoadMenu" && source != "LoadMenu")
        {
            _player.gameObject.GetComponent <PlayerController>().stop_moving();
        }

        SceneLoadData s = new SceneLoadData();

        s.destination = destination;
        s.source      = source;
        _player.setSceneLoadData(s);

        prepare_to_leave_scene(destination, source);

        var scene_to_load = "";

        if (destination.Contains("overworld"))
        {
            scene_to_load = "SceneGenTest";
        }
        else if (destination.Contains("PortalRoom"))
        {
            scene_to_load = "PortalRoom";
        }
        else if (destination.Contains("dungeon"))
        {
            scene_to_load = "TemplateDungeon";
        }

        Application.LoadLevel(scene_to_load);
    }
Beispiel #2
0
    public void changeScene(string destination, string source)
    {
        if (destination != "LoadMenu" && source != "LoadMenu") {
            _player.gameObject.GetComponent<PlayerController>().stop_moving();
        }

        SceneLoadData s = new SceneLoadData();
        s.destination = destination;
        s.source = source;
        _player.setSceneLoadData(s);

        prepare_to_leave_scene(destination, source);

        var scene_to_load = "";
        if (destination.Contains("overworld")) {
            scene_to_load = "SceneGenTest";
        }
        else if (destination.Contains("PortalRoom")) {
            scene_to_load = "PortalRoom";
        }
        else if (destination.Contains("dungeon")) {
            scene_to_load = "TemplateDungeon";
        }

        Application.LoadLevel(scene_to_load);
    }
Beispiel #3
0
 public void StartInitialize()
 {
     this._scenesLoadedCounter = 0;
     for (int i = 0; i < this._scenesToLoad.Length; ++i)
     {
         SceneLoadData sceneToLoad = this._scenesToLoad[i];
         SceneLoader.Instance.LoadSceneAsync(sceneToLoad.sceneName, LoadSceneMode.Additive, this.SceneLoadCallback);
     }
 }
Beispiel #4
0
    public void hostNetwork()
    {
        if (gameObject.GetComponent<PlayerMain>().getSceneLoadData().source.Contains("overworld")) {
            _networking = true;
            SceneLoadData newSceneLoadData = new SceneLoadData();
            newSceneLoadData.source = "LoadMenu";
            newSceneLoadData.destination = "NS" + gameObject.GetComponent<PlayerMain>().getSceneLoadData().source;
            gameObject.GetComponent<PlayerMain>().setSceneLoadData(newSceneLoadData);
            Debug.Log("Loading: " + newSceneLoadData.destination);

            _paused = false;
            Debug.Log("Spawning Host Player");
            Application.LoadLevel("NSceneGenTest");

            }
    }
Beispiel #5
0
    public void hostNetwork()
    {
        if (gameObject.GetComponent <PlayerMain>().getSceneLoadData().source.Contains("overworld"))
        {
            _networking = true;
            SceneLoadData newSceneLoadData = new SceneLoadData();
            newSceneLoadData.source      = "LoadMenu";
            newSceneLoadData.destination = "NS" + gameObject.GetComponent <PlayerMain>().getSceneLoadData().source;
            gameObject.GetComponent <PlayerMain>().setSceneLoadData(newSceneLoadData);
            Debug.Log("Loading: " + newSceneLoadData.destination);

            _paused = false;
            Debug.Log("Spawning Host Player");
            Application.LoadLevel("NSceneGenTest");
        }
    }
 private void GetToLoad()
 {
     toLoad.Clear();
     if (next != null)
     {
         // get scenes from current
         for (int i = 0; i < next.scenes.Count; i++)
         {
             if (next.scenes[i].sceneShort != gameManagerSceneName)
             {
                 var sd = new SceneLoadData();
                 sd.asyncLoad = next.scenes[i].asyncLoad;
                 sd.scene     = next.scenes[i].sceneShort;
                 toLoad.Add(sd);
             }
         }
     }
 }
        public void ChangeGameState(GameStateAsset s, out bool result)
        {
            if (!ProccessRequests)
            {
                result = false;
                return;
            }
            next = s;
            GetToUnload();
            GetToLoad();
            if (loadMode == GMLoadMode.LEAVE_REPEATED)
            {
                for (int i = toLoad.Count - 1; i >= 0; i--)
                {
                    SceneLoadData sc = toLoad[i];
                    if (toUnload.Contains(sc.scene))
                    {
                        toUnload.Remove(sc.scene);
                        toLoad.RemoveAt(i);
                    }
                }
            }
            InvokeOnChangeRequest(current, next);

            if (current != null)
            {
                fsm.ChangeState(OUT_STATE);
            }
            else
            {
                fsm.ChangeState(IN_STATE);
            }
            string stackTrace = UnityEngine.StackTraceUtility.ExtractStackTrace();

            AddAccess(s, stackTrace);
            _currentGameState = s;
            result            = true;
            return;
        }
Beispiel #8
0
    // Update is called once per frame
    void Update()
    {
        //_pos = gameObject.transform.position;
        if (Input.GetKeyDown(KeyCode.Return)) {
            if (!_networking) {
                if (_paused.Equals(true)) {

                    foreach (Transform child in this.transform) {
                        child.gameObject.SetActive(true);
                    }
                    gameObject.GetComponent<PlayerController>().enabled = true;
                    gameObject.GetComponent<Collider>().enabled = true;
                    if (_level == "StartingPortalRoom")
                        _level = "PortalRoom"; //To avoid going back to starting portal room and creating 2 players

                    SceneLoadData newSceneLoadData = new SceneLoadData();
                    newSceneLoadData.destination = gameObject.GetComponent<PlayerMain>().getSceneLoadData().source;
                    newSceneLoadData.source = "LoadMenu";
                    gameObject.GetComponent<PlayerMain>().setSceneLoadData(newSceneLoadData);

                    Application.LoadLevel(_level);
                    //gameObject.transform.position = _pos;

                    _paused = false;
                }
                else if (gameObject.GetComponent<PlayerController>().isStopped()) {
                    SceneLoadData newSceneLoadData = new SceneLoadData();
                    newSceneLoadData.destination = "LoadMenu";
                    if (gameObject.GetComponent<PlayerMain>().getSceneLoadData() != null) {
                        newSceneLoadData.source = gameObject.GetComponent<PlayerMain>().getSceneLoadData().destination;
                    }
                    else newSceneLoadData.source = "StartingPortalRoom";
                    //newSceneLoadData.source = Application.loadedLevelName;
                    gameObject.GetComponent<PlayerMain>().setSceneLoadData(newSceneLoadData);
                    _level = Application.loadedLevelName;
                    //_pos = gameObject.transform.position;

                    Application.LoadLevel("LoadMenu");

                    foreach (Transform child in this.transform) {
                        child.gameObject.SetActive(false);
                    }
                    gameObject.GetComponent<PlayerController>().enabled = false;
                    gameObject.GetComponent<Collider>().enabled = false;

                    //Time.timeScale = 0;

                    _paused = true;
                }
            }
            else {
                Debug.Log(GameObject.FindGameObjectsWithTag("NetworkPlayer").Length);
                if (GameObject.FindGameObjectsWithTag("NetworkPlayer").Length == 1) {
                    GameObject g = GameObject.FindGameObjectWithTag("NetworkPlayer");
                    gameObject.transform.position = g.transform.position;
                    GameObject.FindGameObjectWithTag("NetworkManager").GetComponent<NetworkManager>().StopHost();
                    GameObject.FindGameObjectWithTag("NetworkManager").GetComponent<NetworkManagerHUD>().enabled = false;
                    GameObject.FindGameObjectWithTag("NetworkManager").GetComponent<NetworkManager>().enabled = false;

                    foreach (Transform child in this.transform) {
                        child.gameObject.SetActive(true);
                    }
                    gameObject.GetComponent<PlayerController>().enabled = true;
                    gameObject.GetComponent<Collider>().enabled = true;
                    SceneLoadData newSceneLoadData = gameObject.GetComponent<PlayerMain>().getSceneLoadData();
                    newSceneLoadData.destination = newSceneLoadData.destination.Substring(2);
                    gameObject.GetComponent<PlayerMain>().setSceneLoadData(newSceneLoadData);
                    _networking = false;

                    Application.LoadLevel("SceneGenTest");
                }
            }
        }
    }
Beispiel #9
0
 public void setSceneLoadData(SceneLoadData data)
 {
     _sceneLoadData = data;
 }
Beispiel #10
0
 public void setSceneLoadData(SceneLoadData data)
 {
     _sceneLoadData = data;
 }
Beispiel #11
0
    // Update is called once per frame
    void Update()
    {
        //_pos = gameObject.transform.position;
        if (Input.GetKeyDown(KeyCode.Return))
        {
            if (!_networking)
            {
                if (_paused.Equals(true))
                {
                    foreach (Transform child in this.transform)
                    {
                        child.gameObject.SetActive(true);
                    }
                    gameObject.GetComponent <PlayerController>().enabled = true;
                    gameObject.GetComponent <Collider>().enabled         = true;
                    if (_level == "StartingPortalRoom")
                    {
                        _level = "PortalRoom"; //To avoid going back to starting portal room and creating 2 players
                    }
                    SceneLoadData newSceneLoadData = new SceneLoadData();
                    newSceneLoadData.destination = gameObject.GetComponent <PlayerMain>().getSceneLoadData().source;
                    newSceneLoadData.source      = "LoadMenu";
                    gameObject.GetComponent <PlayerMain>().setSceneLoadData(newSceneLoadData);

                    Application.LoadLevel(_level);
                    //gameObject.transform.position = _pos;

                    _paused = false;
                }
                else if (gameObject.GetComponent <PlayerController>().isStopped())
                {
                    SceneLoadData newSceneLoadData = new SceneLoadData();
                    newSceneLoadData.destination = "LoadMenu";
                    if (gameObject.GetComponent <PlayerMain>().getSceneLoadData() != null)
                    {
                        newSceneLoadData.source = gameObject.GetComponent <PlayerMain>().getSceneLoadData().destination;
                    }
                    else
                    {
                        newSceneLoadData.source = "StartingPortalRoom";
                    }
                    //newSceneLoadData.source = Application.loadedLevelName;
                    gameObject.GetComponent <PlayerMain>().setSceneLoadData(newSceneLoadData);
                    _level = Application.loadedLevelName;
                    //_pos = gameObject.transform.position;

                    Application.LoadLevel("LoadMenu");

                    foreach (Transform child in this.transform)
                    {
                        child.gameObject.SetActive(false);
                    }
                    gameObject.GetComponent <PlayerController>().enabled = false;
                    gameObject.GetComponent <Collider>().enabled         = false;

                    //Time.timeScale = 0;

                    _paused = true;
                }
            }
            else
            {
                Debug.Log(GameObject.FindGameObjectsWithTag("NetworkPlayer").Length);
                if (GameObject.FindGameObjectsWithTag("NetworkPlayer").Length == 1)
                {
                    GameObject g = GameObject.FindGameObjectWithTag("NetworkPlayer");
                    gameObject.transform.position = g.transform.position;
                    GameObject.FindGameObjectWithTag("NetworkManager").GetComponent <NetworkManager>().StopHost();
                    GameObject.FindGameObjectWithTag("NetworkManager").GetComponent <NetworkManagerHUD>().enabled = false;
                    GameObject.FindGameObjectWithTag("NetworkManager").GetComponent <NetworkManager>().enabled    = false;

                    foreach (Transform child in this.transform)
                    {
                        child.gameObject.SetActive(true);
                    }
                    gameObject.GetComponent <PlayerController>().enabled = true;
                    gameObject.GetComponent <Collider>().enabled         = true;
                    SceneLoadData newSceneLoadData = gameObject.GetComponent <PlayerMain>().getSceneLoadData();
                    newSceneLoadData.destination = newSceneLoadData.destination.Substring(2);
                    gameObject.GetComponent <PlayerMain>().setSceneLoadData(newSceneLoadData);
                    _networking = false;

                    Application.LoadLevel("SceneGenTest");
                }
            }
        }
    }