Ejemplo n.º 1
0
 public PortalPosition(Vector2 p1, Vector2 p2)
 {
     this.p1   = p1;
     this.p2   = p2;
     this.p1Or = WallOrientation.Left;
     this.p2Or = WallOrientation.Left;
 }
Ejemplo n.º 2
0
    public static Vector2 ToOffset(this WallOrientation wallOrientation)
    {
        switch (wallOrientation)
        {
        case WallOrientation.TopLeft:
            return(topLeftOffset);

        case WallOrientation.Top:
            return(Vector2.up);

        case WallOrientation.TopRight:
            return(topRightOffset);

        case WallOrientation.Left:
            return(Vector2.left);

        case WallOrientation.Right:
            return(Vector2.right);

        case WallOrientation.BottomLeft:
            return(bottomLeftOffset);

        case WallOrientation.Bottom:
            return(Vector2.down);

        case WallOrientation.BottomRight:
            return(bottomRightOffset);
        }

        throw new ArgumentOutOfRangeException(nameof(wallOrientation), wallOrientation, null);
    }
Ejemplo n.º 3
0
    //Find the correct orientation of the portal
    private Quaternion GetPortalRotation(RaycastHit2D hit)
    {
        Quaternion rot;

        if (hit.normal.y == 1)
        {
            shotOr = WallOrientation.Floor;
            rot    = Quaternion.Euler(0, 0, 270);
        }
        else if (hit.normal.y == -1)
        {
            shotOr = WallOrientation.Ceiling;
            rot    = Quaternion.Euler(0, 0, 90);
        }
        else if (hit.normal.x == 1)
        {
            shotOr = WallOrientation.Left;
            rot    = Quaternion.Euler(0, 0, 180);
        }
        else
        {
            shotOr = WallOrientation.Right;
            rot    = Quaternion.identity;
        }
        return(rot);
    }
Ejemplo n.º 4
0
    public static Quaternion ToLookRotation(this WallOrientation wallOrientation)
    {
        switch (wallOrientation)
        {
        case WallOrientation.Bottom:
            return(Quaternion.Euler(0, 0, 0));

        case WallOrientation.BottomRight:
            return(Quaternion.Euler(0, 0, 45));

        case WallOrientation.Right:
            return(Quaternion.Euler(0, 0, 90));

        case WallOrientation.TopRight:
            return(Quaternion.Euler(0, 0, 135));

        case WallOrientation.Top:
            return(Quaternion.Euler(0, 0, 180));

        case WallOrientation.TopLeft:
            return(Quaternion.Euler(0, 0, 225));

        case WallOrientation.Left:
            return(Quaternion.Euler(0, 0, 270));

        case WallOrientation.BottomLeft:
            return(Quaternion.Euler(0, 0, 315));

        default:
            throw new Exception($"{wallOrientation} is not valid");
        }
    }
Ejemplo n.º 5
0
    private void ChangeWallOrientation(WallOrientation orientation, RoomNode[] roomNodes)
    {
        foreach (var roomNode in roomNodes)
        {
            var sameOrientation = roomNode.wallOrientation == orientation;
            Debug.Log(sameOrientation);
            roomNode.wallOrientation = orientation;

            var newIndex = roomNode.meshIndex;
            if (sameOrientation)
            {
                newIndex++;
            }

            roomNode.meshIndex = newIndex;

            SetMesh(roomNode, orientation, newIndex);

            if (!roomNode.GetComponent <MeshRenderer>())
            {
                roomNode.gameObject.AddComponent <MeshRenderer>();
            }

            roomNode.GetComponent <MeshRenderer>().sharedMaterial = roomNode.wallPiece.material;

            roomNode.transform.rotation = Quaternion.identity;
        }
    }
Ejemplo n.º 6
0
 private void LoadExhibits(DefaultNamespace.VREM.Model.Wall wall, WallOrientation orientation)
 {
     foreach (Exhibit e in wall.exhibits)
     {
         Debug.Log(string.Format("E: {0}/{1} at {2}/{3}", e.position.x, e.position.y, e.size.x, e.size.y));
         var disp = Display(e.GetURLEncodedPath(), orientation, e.position.x, e.position.y, e.size.x, e.size.y, e.light, e.GetURLEncodedAudioPath());
         disp.SetExhibitModel(e);
     }
 }
Ejemplo n.º 7
0
    /// <summary>
    /// </summary>
    /// <param name="url">url to access image</param>
    /// <param name="wall">wall orientation</param>
    /// <param name="x">x coordinate for corresponding wall based on left lower anchor</param>
    /// <param name="y">x coordinate for corresponding wall based on left lower anchor</param>
    public Displayal Display(string url, WallOrientation wall, float x, float y, float w, float h, bool lightOn = true,
                             string audioUrl = null)
    {
        Debug.Log(string.Format("{0}, {1}, {2}/{3}, {4}/{5}", url, wall, x, y, w, h));
        var displayal = Instantiate(PlanePrefab);

        var go = GameObject.Find("VirtualExhibitionManager");

        if (go.GetComponent <VREPController>().Settings.PlaygroundEnabled)
        {
            //var r = displayal.AddComponent<Rigidbody>();
            //r.useGravity = false;

            /*var i = displayal.AddComponent<Interactable>();
             * i.hideHandOnAttach = true;
             * i.useHandObjectAttachmentPoint = true;
             * i.handFollowTransformPosition = true;
             * i.handFollowTransformRotation = true;
             * i.highlightOnHover = true;
             * var t = displayal.AddComponent<Throwable>();
             * t.releaseVelocityStyle = ReleaseStyle.NoChange;
             * t.restoreOriginalParent = false;*/
        }

        if (!LightingActivated || !lightOn)
        {
            displayal.transform.Find("Directional light").gameObject.SetActive(false);
        }


        var disp = displayal.gameObject.GetComponent <Displayal>();

        var image = displayal.transform.Find("Plane").gameObject.AddComponent <ImageLoader>(); // Displayal

        var mycanv = displayal.transform.Find("MyCanvas").gameObject.AddComponent <Paintable>();

        //ImageLoader image = displayal.AddComponent<ImageLoader>();// ImageDisplayPlane
        image.ReloadImage(url);
        Debug.Log(GetWallForOrientation(wall));
        var pos = GetWallForOrientation(wall).CalculatePosition(transform.position, new Vector2(x, y));
        var rot = GetWallForOrientation(wall).CalculateRotation();

        displayal.transform.position   = pos;
        displayal.transform.rotation   = Quaternion.Euler(rot);
        displayal.transform.localScale = ScalingUtility.convertMeters2PlaneScaleSize(w, h);

        if (audioUrl != null)
        {
            Debug.Log("added audio to display object");
            var closenessDetector = displayal.AddComponent <ClosenessDetector>();
            closenessDetector.url = audioUrl;
        }


        displayedImages.Add(displayal);
        return(disp);
    }
Ejemplo n.º 8
0
 public Wall(float x, float y, int z, int length, int[] wall, WallOrientation orientation)
 {
     X           = x;
     Y           = y;
     Z           = z;
     Length      = length;
     Data        = wall;
     Orientation = orientation;
 }
        private static ExhibitionWall CreateExhibitionWall(WallOrientation orientation, DefaultNamespace.VREM.Model.Room room, GameObject anchor)
        {
            var wall = anchor.AddComponent <ExhibitionWall>();

            wall.Anchor    = anchor;
            wall.WallModel = null;
            wall.WallData  = room.GetWall(orientation);
            return(wall);
        }
Ejemplo n.º 10
0
    public Wall(Vector3 position, Quaternion rotation, WallOrientation Orientation, WallType type = WallType.SimpleWall)
    {
        WallPosition      = position;
        WallRotation      = rotation;
        TypeOfWall        = type;
        OrientationOfWall = Orientation;

        TypeOfWall = WallType.SimpleWall;
    }
Ejemplo n.º 11
0
    public void HideWall(WallOrientation orientation)
    {
        int index = (int)orientation;

        if (walls[index] != null)
        {
            Destroy(walls[index]);
            this.walls[index]       = null;
            this.wallsActive[index] = false;
        }
    }
Ejemplo n.º 12
0
        public Wall GetWall(WallOrientation orientation)
        {
            foreach (var wall in walls)
            {
                WallOrientation wor = (WallOrientation)Enum.Parse(typeof(WallOrientation), wall.direction, true);
                if (wor.Equals(orientation))
                {
                    return(wall);
                }
            }

            return(null);
        }
Ejemplo n.º 13
0
    private void SetMesh(RoomNode roomNode, WallOrientation orientation, int meshIndex = -1)
    {
        RenameNode(roomNode, true);

        var meshFilter = roomNode.GetComponent <MeshFilter>();

        if (!meshFilter)
        {
            meshFilter = roomNode.gameObject.AddComponent <MeshFilter>();
        }

        meshFilter.mesh = roomNode.wallPiece.GetMeshFromOrientation(orientation, roomNode.isDiagonal, meshIndex);
        UpdateWall(meshFilter.gameObject);
    }
Ejemplo n.º 14
0
    //if index == -1, returns random
    public Mesh GetMeshFromOrientation(WallOrientation orientation, bool isDiagonal, int index = -1)
    {
        List <Mesh> meshList;

        switch (orientation)
        {
        case WallOrientation.TopLeft:
            meshList = isDiagonal ? diagonal : corner;
            break;

        case WallOrientation.BottomLeft:
            meshList = isDiagonal ? diagonal90 : corner90;
            break;

        case WallOrientation.BottomRight:
            meshList = isDiagonal ? diagonal180 : corner180;
            break;

        case WallOrientation.TopRight:
            meshList = isDiagonal ? diagonal270 : corner270;
            break;

        case WallOrientation.Top:
            meshList = straight;
            break;

        case WallOrientation.Left:
            meshList = straight90;
            break;

        case WallOrientation.Bottom:
            meshList = straight180;
            break;

        case WallOrientation.Right:
            meshList = straight270;
            break;

        default:
            throw new System.Exception(orientation + " is not a valid enum value");
        }

        Debug.Log(index);
        if (index == -1)
        {
            index = Random.Range(0, meshList.Count);
        }

        return(meshList[index % meshList.Count]);
    }
        private static Material GetMaterialForWallOrientation(WallOrientation orientation,
                                                              DefaultNamespace.VREM.Model.Room roomData)
        {
            foreach (DefaultNamespace.VREM.Model.Wall wallData in roomData.walls)
            {
                WallOrientation wor = (WallOrientation)Enum.Parse(typeof(WallOrientation), wallData.direction, true);
                if (wor.Equals(orientation))
                {
                    Debug.Log("Material " + wallData.texture + " for room " + roomData.position);
                    return(TexturingUtility.LoadMaterialByName(wallData.texture, true));
                }
            }

            throw new ArgumentException("Couldn't find material for orientation " + orientation + " in room at " +
                                        roomData.position);
        }
Ejemplo n.º 16
0
 public Surface3D(SurfaceType type, float width, float height, int textureAtlasX, int textureAtlasY, uint textureWidth, uint textureHeight,
                  uint mappedTextureWidth, uint mappedTextureHeight, Rect virtualScreen, WallOrientation wallOrientation, bool alpha, int frameCount,
                  float extrude)
 {
     Type                = type;
     Width               = width;
     Height              = height;
     this.virtualScreen  = virtualScreen;
     textureAtlasOffset  = new Position(textureAtlasX, textureAtlasY);
     WallOrientation     = wallOrientation;
     TextureWidth        = textureWidth;
     TextureHeight       = textureHeight;
     MappedTextureWidth  = mappedTextureWidth;
     MappedTextureHeight = mappedTextureHeight;
     Alpha               = alpha;
     FrameCount          = frameCount;
     this.extrude        = extrude;
 }
        /// <summary>
        /// TODO Fix rotations!
        /// </summary>
        /// <returns></returns>
        /// <exception cref="ArgumentOutOfRangeException"></exception>
        public static Vector3 CalculateRotation(WallOrientation orientation)
        {
            switch (orientation)
            {
            case WallOrientation.NORTH:
                return(new Vector3(90, 180, 0));

            case WallOrientation.EAST:
                return(new Vector3(90, 0, 0));

            case WallOrientation.SOUTH:
                return(new Vector3(90, -180, 0));

            case WallOrientation.WEST:
                return(new Vector3(90, 90, 0));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Ejemplo n.º 18
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="orientation"></param>
    /// <returns></returns>
    /// <exception cref="ArgumentOutOfRangeException"></exception>
    private Wall GetWallForOrientation(WallOrientation orientation)
    {
        switch (orientation)
        {
        case WallOrientation.NORTH:
            return(GetWall(_northWallName));

        case WallOrientation.EAST:
            return(GetWall(_eastWallName));

        case WallOrientation.SOUTH:
            return(GetWall(_southWallName));

        case WallOrientation.WEST:
            return(GetWall(_westWallName));

        default:
            throw new ArgumentOutOfRangeException("orientation", orientation, null);
        }
    }
Ejemplo n.º 19
0
        private static GameObject CreateAnchor(WallOrientation orientation, GameObject room, CuboidRoomModel model)
        {
            var anchor = new GameObject(orientation + "Anchor");

            anchor.transform.parent = room.transform;
            var pos      = Vector3.zero;
            var a        = 0f;
            var sizeHalf = model.Size / 2f;

            switch (orientation)
            {
            case WallOrientation.NORTH:
                pos = new Vector3(-sizeHalf, 0, sizeHalf);
                a   = 0;
                break;

            case WallOrientation.EAST:
                pos = new Vector3(sizeHalf, 0, sizeHalf);
                a   = 90;
                break;

            case WallOrientation.SOUTH:
                pos = new Vector3(sizeHalf, 0, -sizeHalf);
                a   = 180;
                break;

            case WallOrientation.WEST:
                pos = new Vector3(-sizeHalf, 0, -sizeHalf);
                a   = 270;
                break;

            default:
                throw new ArgumentOutOfRangeException("orientation", orientation, null);
            }

            anchor.transform.Rotate(Vector3.up, a);
            anchor.transform.localPosition = pos;
            return(anchor);
        }
Ejemplo n.º 20
0
        public void SetWall(int column, int row, WallOrientation wallOrientation, bool isThere)
        {
            column++;              // To allow for -1, -1 coordinates
            row++;
            switch (wallOrientation)
            {
            case WallOrientation.Horizontal:
                if (_allHorizontalWalls[column, row] != isThere)
                {
                    _allHorizontalWalls[column, row] = isThere;
                    wallsChanged = true;
                }
                break;

            case WallOrientation.Vertical:
                if (_allVerticalWalls[column, row] != isThere)
                {
                    _allVerticalWalls[column, row] = isThere;
                    wallsChanged = true;
                }
                break;
            }
        }
Ejemplo n.º 21
0
    public void instantiateWall(Wall wallType, Vector3 position, WallOrientation wallOrientation)
    {
        if (wallType == Wall.empty)
        {
            return;
        }

        int x = (int)position.x;
        int y = (int)position.y;
        int z = (int)position.z;

        float pictureSpawnChance = 0.01f;

        GameObject wallObject = getWallObjectByType(wallType);
        GameObject wall;

        GameObject curPainting;

        if ((int)(Random.value * 2) == 1)
        {
            curPainting = paintingObj;
        }
        else
        {
            curPainting = paintingObj2;
        }


        if (wallObject != null)
        {
            switch (wallOrientation)
            {
            case WallOrientation.front:
                wall = Instantiate(wallObject, new Vector3(x, y + 0.5f, z + 0.5f), Quaternion.Euler(0, 0, 0));
                if (Random.value < pictureSpawnChance)
                {
                    Instantiate(curPainting, new Vector3(x, y, z), Quaternion.Euler(0, 0, 0));
                }
                break;

            case WallOrientation.back:
                wall = Instantiate(wallObject, new Vector3(x, y + 0.5f, z - 0.5f), Quaternion.Euler(0, 0, 0));
                if (Random.value < pictureSpawnChance)
                {
                    Instantiate(curPainting, new Vector3(x, y, z), Quaternion.Euler(0, 180, 0));
                }
                break;

            case WallOrientation.left:
                wall = Instantiate(wallObject, new Vector3(x - 0.5f, y + 0.5f, z), Quaternion.Euler(0, 90, 0));
                if (Random.value < pictureSpawnChance)
                {
                    Instantiate(curPainting, new Vector3(x, y, z), Quaternion.Euler(0, -90, 0));
                }
                break;

            case WallOrientation.right:
                wall = Instantiate(wallObject, new Vector3(x + 0.5f, y + 0.5f, z), Quaternion.Euler(0, 90, 0));
                if (Random.value < pictureSpawnChance)
                {
                    Instantiate(curPainting, new Vector3(x, y, z), Quaternion.Euler(0, 90, 0));
                }
                break;

            default:
                wall = Instantiate(wallObject, new Vector3(x, y, z), Quaternion.Euler(0, 0, 0));
                break;
            }


            StoneDoor sd = wall.GetComponent <StoneDoor>();
            if (sd != null)
            {
                sd.setPlayer(player);
            }
        }
    }
Ejemplo n.º 22
0
    // Update is called once per frame
    void Update()
    {
        //if (Input.GetButtonDown("Jump") && !this.generationStarted)
        if (!this.generationStarted)
        {
            this.generationStarted = true;
            StartCoroutine(InstantiateCells());
        }
        if (this.stack.Count > 0)
        {
            Cell current = this.stack.Peek();

            bool valid  = false;
            int  checks = 0;

            //Quitamos los decimales
            // Son las coordenadas del array[width, heigh]
            int current_x = (int)((current.transform.position.x - posXini) / 2);
            int current_y = (int)((current.transform.position.z - posZini) / 2);

            while (checks < 10 && !valid)
            {
                checks++;
                WallOrientation direction = (WallOrientation)Random.Range(0, 4);

                switch (direction)
                {
                case WallOrientation.WEST:
                    if (current_x > 0)
                    {
                        Cell next = this.cellGrid[current_x - 1, current_y];

                        if (!next.isVisited)
                        {
                            current.HideWall(WallOrientation.WEST);
                            next.HideWall(WallOrientation.EAST);

                            next.isVisited = true;
                            this.stack.Push(next);
                            valid = true;
                        }
                    }
                    break;

                case WallOrientation.NORTH:
                    if (current_y < (this.height - 1))
                    {
                        Cell next = this.cellGrid[current_x, current_y + 1];

                        if (!next.isVisited)
                        {
                            current.HideWall(WallOrientation.NORTH);
                            next.HideWall(WallOrientation.SOUTH);

                            next.isVisited = true;
                            this.stack.Push(next);
                            valid = true;
                        }
                    }
                    break;


                case WallOrientation.EAST:
                    if (current_x < (this.width - 1))
                    {
                        Cell next = this.cellGrid[current_x + 1, current_y];

                        if (!next.isVisited)
                        {
                            current.HideWall(WallOrientation.EAST);
                            next.HideWall(WallOrientation.WEST);

                            next.isVisited = true;
                            this.stack.Push(next);
                            valid = true;
                        }
                    }
                    break;


                case WallOrientation.SOUTH:
                    if (current_y > 0)
                    {
                        Cell next = this.cellGrid[current_x, current_y - 1];

                        if (!next.isVisited)
                        {
                            current.HideWall(WallOrientation.SOUTH);
                            next.HideWall(WallOrientation.NORTH);

                            next.isVisited = true;
                            this.stack.Push(next);
                            valid = true;
                        }
                    }
                    break;
                }
            }

            if (!valid)
            {
                this.stack.Pop();
            }
        }
        else if (!this.characterSpawwned && this.generationFinished)
        {
            this.characterSpawwned = true;
            //this.SpawnPlayer();

            Cell entrada = this.cellGrid[enterX, enterZ];
            entrada.HideWall(WallOrientation.SOUTH);
            Cell salida = this.cellGrid[exitX, exitZ];
            salida.HideWall(WallOrientation.NORTH);
        }
    }
Ejemplo n.º 23
0
 private static bool IsValidWallOrientation(WallOrientation orientation)
 {
     return(orientation == WallOrientation.Horizontal ||
            orientation == WallOrientation.Vertical);
 }
Ejemplo n.º 24
0
 public Wall(FieldCoordinate topLeft, WallOrientation orientation)
 {
     Orientation = orientation;
     TopLeft     = topLeft;
 }
Ejemplo n.º 25
0
 public void SetOrientationOfWall(WallOrientation orientation)
 {
     OrientationOfWall = orientation;
 }
Ejemplo n.º 26
0
 public WallNode(WallOrientation orientation, MazeNode parent)
 {
     Orientation = orientation;
     Parent      = parent;
     Neighbor    = null;
 }
Ejemplo n.º 27
0
 public WallData(WallOrientation orientation)
 {
     Orientation = orientation;
 }
Ejemplo n.º 28
0
    public bool IsWallActive(WallOrientation orientation)
    {
        int index = (int)orientation;

        return(this.wallsActive[index]);
    }
Ejemplo n.º 29
0
 /// <summary>
 ///     Returns the wall for the orientation.
 /// </summary>
 /// <param name="orientation">The orientation for which the wall is requested</param>
 /// <returns>The ExhibitionWall component for the specified orientation</returns>
 public ExhibitionWall GetWallForOrientation(WallOrientation orientation)
 {
     return(Walls.Find(wall => wall.GetOrientation() == orientation));
 }
Ejemplo n.º 30
0
 public PlaceWallAction(int column, int row, WallOrientation wallAlignment)
 {
     Column        = column;
     Row           = row;
     WallAlignment = wallAlignment;
 }