Example #1
0
        protected IEnumerator SendPlayerToActionNode(int chunkID, string actionNodeName, float delay)
        {
            if (!GUILoading.IsLoading)
            {
                yield return(GUILoading.LoadStart(GUILoading.Mode.FullScreenBlack));
            }
            Player.Local.Despawn();
            //start off by setting the primary chunk
            GameWorld.Get.SetPrimaryChunk(chunkID);
            //action nodes won't exist unless it's primary
            while (GameWorld.Get.PrimaryChunk.CurrentMode != ChunkMode.Primary)              //wait for the chunk to load before we send it there
            //Debug.Log("Waiting for primary chunk to load");
            {
                yield return(null);
            }
            ActionNodeState nodeState = null;

            if (GameWorld.Get.PrimaryChunk.GetNode(actionNodeName, false, out nodeState))
            {
                //send player to location
                string     locationPath  = WIGroup.AllButLastInPath(nodeState.ParentGroupPath);
                string     locationName  = WIGroup.LastInPath(nodeState.ParentGroupPath);
                STransform spawnPosition = nodeState.Transform;
                if (nodeState.IsLoaded)
                {
                    spawnPosition = new STransform(nodeState.actionNode.transform, false);
                }
                yield return(StartCoroutine(SendPlayerToLocation(chunkID, locationPath, locationName, spawnPosition, GameWorld.Get.PrimaryChunk.ChunkOffset, delay)));
            }
            if (GUILoading.IsLoading)
            {
                yield return(GUILoading.LoadStart(GUILoading.Mode.FullScreenBlack));
            }
            yield break;
        }