Ejemplo n.º 1
0
        private IEnumerator LoadRoomOverTime(RoomEnum room)
        {
            isProcessing = true;
            LoadingDialog.Instance.Open(
                LoadingDialog.IndicatorStyleEnum.Prefab,
                LoadingDialog.ProgressStyleEnum.None,
                LoadingDialog.MessageStyleEnum.Visible,
                "Loading room data");

            /*List<Mesh> loadedMeshes = new List<Mesh>();
             * IList<Mesh> meshes = null;
             * // Keep trying to load meshes until we no longer find a file
             * for (int i = 0; i < MaxRoomMeshes; i++) {
             *  // See if the file exists
             *  string fileName = GetMeshFileName(i, room);
             *  string path = System.IO.Path.Combine(MeshSaver.MeshFolderName, fileName + ".room");
             *  if (System.IO.File.Exists(path)) {
             *      loadedMeshes.AddRange(MeshSaver.Load(fileName));
             *      yield return new WaitForSeconds(0.05f);
             *  } else {
             *      // If it doesn't, we're done here
             *      break;
             *  }
             * }*/

            yield return(new WaitForSeconds(0.5f));

            LoadingDialog.Instance.Close();
            while (LoadingDialog.Instance.IsLoading)
            {
                yield return(null);
            }

            // Open again with a progress bar showing room creation progress
            LoadingDialog.Instance.Open(
                LoadingDialog.IndicatorStyleEnum.Prefab,
                LoadingDialog.ProgressStyleEnum.Percentage,
                LoadingDialog.MessageStyleEnum.Visible,
                "Creating room");

            /*for (int i = 0; i < loadedMeshes.Count; i++) {
             *  LoadingDialog.Instance.SetProgress((float)i / loadedMeshes.Count);
             *  GameObject newMeshObject = new GameObject(GetMeshFileName(i, room));
             *  MeshFilter mf = newMeshObject.AddComponent<MeshFilter>();
             *  mf.sharedMesh = loadedMeshes[i];
             *  newMeshObject.AddComponent<MeshRenderer>();
             *  yield return null;
             * }*/

            yield return(new WaitForSeconds(0.5f));

            LoadingDialog.Instance.Close();

            currentRoom  = room;
            isProcessing = false;
        }
Ejemplo n.º 2
0
        private IEnumerator SaveRoomOverTime(RoomEnum room)
        {
            // TEMP disable save room until caching is implemented
            currentRoom = room;
            yield break;
            // TEMP

            isProcessing = true;
            LoadingDialog.Instance.Open(
                LoadingDialog.IndicatorStyleEnum.Prefab,
                LoadingDialog.ProgressStyleEnum.Percentage,
                LoadingDialog.MessageStyleEnum.Visible,
                "Saving room");

            //TEMP tag the meshes as moon surface while we're here
            List <MeshFilter> meshes = SpatialMappingManager.Instance.GetMeshFilters();

            for (int i = 0; i < meshes.Count; i++)
            {
                meshes[i].gameObject.tag = EnvironmentManager.MoonSurfaceTag;
            }

            /*List<MeshFilter> meshes = SpatialMappingManager.Instance.GetMeshFilters();
             * //List<MeshFilter> meshes = SpatialUnderstanding.Instance.UnderstandingCustomMesh.GetMeshFilters();
             * List<Mesh> saveMesh = new List<Mesh>();
             * for (int i = 0; i < meshes.Count; i++) {
             *  saveMesh.Add(meshes[i].sharedMesh);
             *  MeshSaver.Save(GetMeshFileName(i, room), saveMesh);
             *  LoadingDialog.Instance.SetProgress((float)i / meshes.Count);
             *  yield return new WaitForSeconds (0.05f);
             *  saveMesh.Clear();
             * }*/

            // TEMP test loading screen
            float progress = 0f;

            while (progress < 1f)
            {
                progress += Time.deltaTime * 0.5f;
                LoadingDialog.Instance.SetProgress(progress);
                yield return(null);
            }

            LoadingDialog.Instance.Close();

            currentRoom  = room;
            isProcessing = false;
        }
Ejemplo n.º 3
0
        public bool HasSavedRoom(RoomEnum room)
        {
            // TEMP
            bool hasSavedRoom = false;

            switch (room)
            {
            case RoomEnum.Room1:
                break;

            case RoomEnum.Room2:
                break;

            case RoomEnum.Room3:
                break;
            }
            return(hasSavedRoom);
        }
Ejemplo n.º 4
0
    public static string GetRoomName(RoomEnum re)
    {
        string name;

        switch (re)
        {
        case RoomEnum.Dragon:
            name = dragon;
            break;

        case RoomEnum.Exhibit:
            name = exhibit;
            break;

        case RoomEnum.Seaworld:
            name = seaworld;
            break;

        default:
            name = seaworld;
            break;
        }
        return(name);
    }
    /**
     * Given the current direction we need to look to it's edge to see if we are ath the edge of the map or not. If we are in an edge
     * we would need to replace the room so the player can't escape from the maze
     *
     */
    private void CheckBorder(GameObject previousRoom)
    {
        RoomEnum roomType = RoomEnum.None;

        RaycastHit2D hiDown  = Physics2D.Raycast(previousRoom.transform.position, previousRoom.transform.up * -1, collisionRadius, whatIsBorder);
        RaycastHit2D hiUp    = Physics2D.Raycast(previousRoom.transform.position, previousRoom.transform.up, collisionRadius, whatIsBorder);
        RaycastHit2D hiLeft  = Physics2D.Raycast(previousRoom.transform.position, previousRoom.transform.right * -1, collisionRadius, whatIsBorder);
        RaycastHit2D hiRight = Physics2D.Raycast(previousRoom.transform.position, previousRoom.transform.right, collisionRadius, whatIsBorder);

        if (hiLeft)
        {
            roomType |= RoomEnum.Left; // 1
        }

        if (hiRight)
        {
            roomType |= RoomEnum.Right; // 2
        }

        if (hiDown)
        {
            roomType |= RoomEnum.Bottom; // 4
        }

        if (hiUp)
        {
            roomType |= RoomEnum.Top; // 8
        }

        int pos = -1;

        switch (roomType)
        {
        case RoomEnum.Left:
            //Debug.Log("Need to close left");
            pos = 0;
            break;

        case RoomEnum.Right:
            //Debug.Log("Need to close right");
            pos = 3;
            break;

        case RoomEnum.Bottom:
            //Debug.Log("Need to close bottom");
            pos = 6;
            break;

        case RoomEnum.Top:
            //Debug.Log("Need to close top");
            pos = 7;
            break;

        case RoomEnum.Left | RoomEnum.Top:
            //Debug.Log("Need to close left and top");
            pos = 2;
            break;

        case RoomEnum.Left | RoomEnum.Bottom:
            //Debug.Log("Need to close left and bottom");
            pos = 1;
            break;

        case RoomEnum.Right | RoomEnum.Top:
            //Debug.Log("Need to close right and top");
            pos = 5;
            break;

        case RoomEnum.Right | RoomEnum.Bottom:
            //Debug.Log("Need to close right and bottom");
            pos = 4;
            break;

        default:
            break;
        }

        if (pos != -1)
        {
            // we overlay a wall
            Instantiate(edgeRooms[pos], transform.position, Quaternion.identity);
        }
    }
Ejemplo n.º 6
0
 public void LoadRoom(RoomEnum room)
 {
     StartCoroutine(LoadRoomOverTime(room));
 }
Ejemplo n.º 7
0
 public void SaveRoom(RoomEnum room)
 {
     StartCoroutine(SaveRoomOverTime(room));
 }
Ejemplo n.º 8
0
 private string GetMeshFileName(int meshIndex, RoomEnum room)
 {
     return(room.ToString() + "_" + meshIndex.ToString("D8"));
 }