Exemple #1
0
    void Update()
    {
                #if !UNITY_EDITOR
        if (EarlyOut())
        {
            return;
        }
                #endif

        GameObject    locomotion = GameObject.Find("BezierLocomotion");
        ArcTeleporter teleporter = locomotion.GetComponent <ArcTeleporter>();

        if (teleporter.teleportState)
        {
            Vector3 end     = raycaster.End;
            Vector3 control = raycaster.Control;

            float recip = 1.0f / (float)(segments - 1);
            for (int i = 0; i < segments; ++i)
            {
                float   t      = (float)i * recip;
                Vector3 sample = SampleCurve(arcRaycaster.Start, end, control, Mathf.Clamp01(t));
                arcRenderer.SetPosition(i, sample);
            }

            SetCurveVisuals();
        }
    }
Exemple #2
0
 void Awake()
 {
     instance = this;
     if (arcRaycaster == null)
     {
         arcRaycaster = GetComponent <ArcRaycaster> ();
     }
     if (arcRaycaster == null)
     {
         Debug.LogError("ArcTeleporter's Arc Ray Caster is not set");
     }
     if (objectToMove == null)
     {
         Debug.LogError("ArcTeleporter's target object is not set");
     }
 }
Exemple #3
0
 public void OnEnable()
 {
     m_Component = (ArcTeleporter)target;
     if (m_Component.raycastLayer != null)
     {
         raycastLayersSize = m_Component.raycastLayer.Count;
     }
     else
     {
         raycastLayersSize = 0;
     }
     if (m_Component.tags != null)
     {
         tagsSize = m_Component.tags.Count;
     }
     else
     {
         tagsSize = 0;
     }
 }
Exemple #4
0
 public void OnEnable()
 {
     teleporter           = (ArcTeleporter)target;
     serializedTeleporter = new SerializedObject(teleporter);
     if (teleporter.raycastLayer != null)
     {
         raycastLayersSize = teleporter.raycastLayer.Count;
     }
     else
     {
         raycastLayersSize = 0;
     }
     if (teleporter.tags != null)
     {
         tagsSize = teleporter.tags.Count;
     }
     else
     {
         tagsSize = 0;
     }
 }
    // Use this for initialization
    void Start()
    {
        string jsonPath = Path.Combine(Application.streamingAssetsPath, mapJsonFile);

        print(jsonPath);
        if (File.Exists(jsonPath))
        {
            // Read the json from the file into a string
            string dataAsJson = File.ReadAllText(jsonPath);
            // Pass the json to JsonUtility, and tell it to create a GameData object from it
            mapData = JsonUtility.FromJson <Map>(dataAsJson);
        }
        else
        {
            print("error on reading json file");
        }

        Room prevRoom = Instantiate(startRoom, level);
        // instantiate player
        OVRCameraRig  player     = Instantiate(playerPrefab, playerSpawn.position, playerSpawn.rotation);
        ArcTeleporter teleporter = Instantiate(teleporterPrefab);

        teleporter.objectToMove = player.transform;
        teleporter.GetComponent <TallRaycaster>().trackingSpace = player.GetComponentInChildren <Transform>();

        // generate rooms
        for (int i = 0; i < mapData.rooms.Length; i++)
        {
            // room type is middle room unless this is last room
            Room roomType = (i == mapData.rooms.Length - 1) ? endRoom : middleRoom;

            RoomContent rc = mapData.rooms[i];

            Room currentRoom = Instantiate(roomType, level);

            // get the previous exit and this entrance
            Transform prevExit     = prevRoom.exits[prevRoom.exits.Length - 1];
            Transform roomEntrance = currentRoom.exits[0];

            // calculate world offset based on previous exit

            currentRoom.transform.rotation = new Quaternion(roomEntrance.rotation.x - prevExit.rotation.x,
                                                            roomEntrance.rotation.y - (prevExit.rotation.y + 180),
                                                            roomEntrance.rotation.z - prevExit.rotation.z,
                                                            roomEntrance.rotation.w - prevExit.rotation.w);
            currentRoom.transform.position = prevExit.position - currentRoom.transform.rotation * roomEntrance.localPosition;

            //room is created, fill with content
            for (int j = 0; j < rc.imagePaths.Length && j < currentRoom.paintingSpawns.Length; j++)
            {
                Texture2D  texture = loadImage(new Vector2(100, 100), Path.Combine(Application.streamingAssetsPath, rc.imagePaths[j]));
                GameObject prefab  = Instantiate(paintingPrefab, currentRoom.paintingSpawns[j].position, currentRoom.paintingSpawns[j].rotation);
                prefab.GetComponent <Renderer>().material.mainTexture = texture;
            }

            currentRoom.SetAudio(rc.audioPath);

            GameObject tmp = Instantiate(textMeshPro, currentRoom.textSpawn.position, currentRoom.textSpawn.rotation);
            tmp.GetComponent <TMPro.TextMeshPro>().text = rc.text;

            // instanstiate room
            prevRoom = currentRoom;
        }
    }