Exemplo n.º 1
0
    private void ReturnToBedroom()
    {
        ScenesData.resetLastPositions();
        LoadNewArea loadArea = gameObject.AddComponent <LoadNewArea>();

        loadArea.sceneToLoad = "bedroom";
        loadArea.LoadArea();
    }
    public static void SendHintsAndBoardLatAndLong(byte playerCount)
    {
        object[]          content           = new object[] { ScenesData.GetValidRiddlesCoords(), ScenesData.GetValidRiddlesText(), ScenesData.treasureCoords, playerCount };
        RaiseEventOptions raiseEventOptions = new RaiseEventOptions {
            Receivers = ReceiverGroup.All
        };

        PhotonNetwork.RaiseEvent(10, content, raiseEventOptions, SendOptions.SendReliable);
    }
Exemplo n.º 3
0
    //DATOS DEL SCENEMANAGER
    public static void SaveSceneData(ScenesManager SM)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/scenesdata.info";
        FileStream      stream    = new FileStream(path, FileMode.Create);

        ScenesData sceneData = new ScenesData(SM);

        formatter.Serialize(stream, sceneData);
        stream.Close();
    }
Exemplo n.º 4
0
    internal static void Init()
    {
        // EditorWindow.GetWindow() will return the open instance of the specified window or create a new
        // instance if it can't find one. The second parameter is a flag for creating the window as a
        // Utility window; Utility windows cannot be docked like the Scene and Game view windows.
        var window = (ScenesWindowEditor)GetWindow(typeof(ScenesWindowEditor), false, "Scenes");

        window.position = new Rect(window.position.xMin + 100f, window.position.yMin + 100f, 200f, 400f);

        string settingsFilePath = EditorPrefs.GetString(SETTINGS_FILE_PATH_KEY);

        if (string.IsNullOrEmpty(settingsFilePath))
        {
            var paths = new List <string> {
                Path.Combine(Application.dataPath, "scenes.json"),
                Path.Combine(Application.dataPath, "Scenes", "scenes.json"),
                Path.Combine(Application.dataPath, "_app", "Scenes", "scenes.json"),
            };
            foreach (var p in paths)
            {
                if (File.Exists(p))
                {
                    settingsFilePath = p;
                    EditorPrefs.SetString(SETTINGS_FILE_PATH_KEY, settingsFilePath);
                    break;
                }
            }
        }

        if (string.IsNullOrEmpty(settingsFilePath))
        {
            CreateNewSettings();
        }
        else
        {
            try
            {
                string json = File.ReadAllText(settingsFilePath);
                scenesData = JsonUtility.FromJson <ScenesData>(json);
            }
            catch (Exception ex)
            {
                Debug.Log(ex);
                CreateNewSettings();
            }
        }
    }
Exemplo n.º 5
0
    static void SaveLevel()
    {
        // Find the Scene controller if not already attached.
        if (_sceneControl == null)
        {
            SceneController sc = null;
            object[] obj = GameObject.FindObjectsOfType(typeof(GameObject));
            foreach (object o in obj)
            {
                GameObject g = (GameObject)o;
                sc = g.GetComponent<SceneController>();
                if (sc == null) { continue; }
                break;
            }
            if (sc == null) { Debug.LogError("Could Not Save this scene. There is no scene controller."); return; }
            _sceneControl = sc;
        }

        Debug.Log("Saving the Level");
        EditorApplication.SaveScene("Assets/Scenes/Levels/" + _sceneControl.Name + ".unity");

        // Add the Scene to the build Settings
        string newPath = "Assets/Scenes/Levels/" + _sceneControl.Name + ".unity";
        EditorBuildSettingsScene[] original = EditorBuildSettings.scenes;
        ScenesData data = new ScenesData();

        // Make sure that the new scene does not already exist.

        for (int i = 0; i < original.Length; i++)
        {
            data.Scenes.Add(new SceneData(original[i].path, i));
            if (original[i].path == newPath)
            {
                Debug.Log("This Scene has already been added to the build settings.");
                return;
            }
        }
        data.Scenes.Add(new SceneData(newPath, original.Length));
        DataManager.SaveToResources(data);
        EditorBuildSettingsScene[] newSettings = new EditorBuildSettingsScene[original.Length + 1];
        System.Array.Copy(original, newSettings, original.Length);
        EditorBuildSettingsScene sceneToAdd = new EditorBuildSettingsScene(newPath, true);
        newSettings[newSettings.Length - 1] = sceneToAdd;
        EditorBuildSettings.scenes = newSettings;
    }
Exemplo n.º 6
0
    public static ScenesData LoadSceneData()
    {
        string path = Application.persistentDataPath + "/scenesdata.info";

        if (File.Exists(path))
        {
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream      stream    = new FileStream(path, FileMode.Open);
            ScenesData      sceneData = formatter.Deserialize(stream) as ScenesData;
            stream.Close();

            return(sceneData);
        }
        else
        {
            Debug.LogError("SaveFile not found in" + path);
            return(null);
        }
    }
Exemplo n.º 7
0
 public void CreateRoom()
 {
     if (ScenesData.CheckNumberOfZerosRiddleCoordsAndTreasure() == 0)
     {
         Text roomCode = GameObject.Find("RoomCode").GetComponent <Text>();
         Debug.Log("Created room with code: " + roomCode.text.Substring(roomCode.text.Length - 4, 4) + " lenght " + (roomCode.text.Length - (roomCode.text.Length - 4)));
         PhotonNetwork.CreateRoom(roomCode.text.Substring(roomCode.text.Length - 4, 4), new RoomOptions {
             MaxPlayers = maxPlayersPerRoom
         });
         ScenesData.roomCode = string.Copy(roomCode.text.Substring(roomCode.text.Length - 4, 4));
     }
     else
     {
         GameObject.Find("SetRiddles").SetActive(false);
         GameObject.Find("Treasure Location").SetActive(false);
         GameObject.Find("Button_start").SetActive(false);
         Resources.FindObjectsOfTypeAll <GameObject>()
         .FirstOrDefault(g => g.name == "ErrorDisplay")
         .SetActive(true);
     }
 }
Exemplo n.º 8
0
 static void UpdateScenesData()
 {
     EditorBuildSettingsScene[] original = EditorBuildSettings.scenes;
     ScenesData data = new ScenesData();
     for (int i = 0; i < original.Length; i++)
     {
         Debug.Log("[" + i + "] Found Scene: " + original[i].path);
         data.Scenes.Add(new SceneData(original[i].path, i));
     }
     DataManager.SaveToResources<ScenesData>(data);
     Debug.Log("Update Complete");
 }
Exemplo n.º 9
0
 public void OnNewGame()
 {
     ScenesData.resetLastPositions();
 }
Exemplo n.º 10
0
    public bool LoadSceneData()
    {
        ScenesData data = new ScenesData();
        DataManager.Load(out data);
        _scenes = data.Scenes;

        return _scenes.Count>0;
    }
Exemplo n.º 11
0
 static void CreateNewSettings()
 {
     scenesData = new ScenesData()
     {
     };
 }
Exemplo n.º 12
0
        void Update()
        {
            GameObject instance;
            Scene      currentScene = SceneManager.GetActiveScene();
            string     sceneName    = currentScene.name;

            if (sceneName == "ARScene")
            {
                for (int i = 0, j = 0; i < ScenesData.playersCoords.Length; i += 2, j++)
                {
                    if (ScenesData.playersCoords[i] != 0)
                    {
                        if (ScenesData.playersCoords[i] != ScenesData.lastPlayersCoords[i])
                        {
                            ScenesData.lastPlayersCoords[i] = ScenesData.playersCoords[i];
                            GameObject obj = GameObject.Find("Player" + j + "Location");
                            if (obj == null)
                            {
                                instance           = Instantiate(playerTarget);
                                instance.name      = "Player" + j + "Location";
                                _locations[j]      = new Vector2d(ScenesData.playersCoords[i], ScenesData.playersCoords[i + 1]);
                                _spawnedObjects[j] = instance;
                            }
                            else
                            {
                                _locations[j]      = new Vector2d(ScenesData.playersCoords[i], ScenesData.playersCoords[i + 1]);
                                _spawnedObjects[j] = obj;
                            }
                        }
                    }
                }
            }
            else
            {
                if (Input.touchCount > 0)
                {
                    Touch touch = Input.GetTouch(0);
                    switch (touch.phase)
                    {
                    case TouchPhase.Began:
                        startPos = touch.position;
                        break;

                    case TouchPhase.Moved:
                        break;

                    case TouchPhase.Ended:
                        Vector2 touchPos = touch.position;
                        if (touchPos == startPos)
                        {
                            startPos = new Vector2(0, 0);
                            //assign distance of camera to ground plane to z, otherwise ScreenToWorldPoint() will always return the position of the camera
                            //http://answers.unity3d.com/answers/599100/view.html
                            var pos          = _referenceCamera.ScreenToWorldPoint(new Vector3(touchPos.x, touchPos.y, _referenceCamera.transform.localPosition.y));
                            var latlongDelta = _map.WorldToGeoPosition(pos);
                            if (ScenesData.treasForT == true)
                            {
                                _locations[5] = latlongDelta;
                                ScenesData.AddNewTreasureCord(latlongDelta);
                                if (_spawnedObjects[5] == null)
                                {
                                    instance           = Instantiate(markers[5]);
                                    _spawnedObjects[5] = instance;
                                }
                            }
                            else
                            {
                                _locations[ScenesData.currentRiddle - 1] = latlongDelta;
                                ScenesData.AddNewRiddleCoords(latlongDelta);
                                if (_spawnedObjects[ScenesData.currentRiddle - 1] == null)
                                {
                                    instance = Instantiate(markers[ScenesData.currentRiddle - 1]);
                                    _spawnedObjects[ScenesData.currentRiddle - 1] = instance;
                                }
                            }
                            if (ScenesData.treasForT == true)
                            {
                                SceneManager.LoadScene("Treasure");
                            }
                            else
                            {
                                SceneManager.LoadScene("Riddle");
                            }
                        }
                        break;
                    }
                }
                else if (Input.GetMouseButtonUp(1))
                {
                    var mousePosScreen = Input.mousePosition;
                    //assign distance of camera to ground plane to z, otherwise ScreenToWorldPoint() will always return the position of the camera
                    //http://answers.unity3d.com/answers/599100/view.html
                    mousePosScreen.z = _referenceCamera.transform.localPosition.y;
                    var pos          = _referenceCamera.ScreenToWorldPoint(mousePosScreen);
                    var latlongDelta = _map.WorldToGeoPosition(pos);
                    if (ScenesData.treasForT == true)
                    {
                        _locations[5] = latlongDelta;
                        ScenesData.AddNewTreasureCord(latlongDelta);
                        if (_spawnedObjects[5] == null)
                        {
                            instance           = Instantiate(markers[5]);
                            _spawnedObjects[5] = instance;
                        }
                    }
                    else
                    {
                        _locations[ScenesData.currentRiddle - 1] = latlongDelta;
                        ScenesData.AddNewRiddleCoords(latlongDelta);
                        if (_spawnedObjects[ScenesData.currentRiddle - 1] == null)
                        {
                            instance = Instantiate(markers[ScenesData.currentRiddle - 1]);
                            _spawnedObjects[ScenesData.currentRiddle - 1] = instance;
                        }
                    }
                    if (ScenesData.treasForT == true)
                    {
                        SceneManager.LoadScene("Treasure");
                    }
                    else
                    {
                        SceneManager.LoadScene("Riddle");
                    }
                }
            }

            int count = _spawnedObjects.Length;

            for (int i = 0; i < count; i++)
            {
                if (_spawnedObjects[i] != null)
                {
                    var spawnedObject = _spawnedObjects[i];
                    var location      = _locations[i];
                    spawnedObject.transform.localPosition = _map.GeoToWorldPosition(location, true);
                    spawnedObject.transform.localScale    = new Vector3(_spawnScale, _spawnScale, _spawnScale);
                }
            }
        }