Ejemplo n.º 1
0
    private void CreateStartingPoints()
    {
        Object obj = Resources.Load("PlayerStartingPoint");
        int    x   = (int)startingRoom.GetMedianPoint().x;
        int    y   = (int)startingRoom.GetMedianPoint().z;

        TileScript2D up    = DungeonGenerationUtils.GetUpTile(x, y, tilesMap);
        TileScript2D down  = DungeonGenerationUtils.GetDownTile(x, y, tilesMap);
        TileScript2D left  = DungeonGenerationUtils.GetLeftTile(x, y, tilesMap);
        TileScript2D right = DungeonGenerationUtils.GetRightTile(x, y, tilesMap);

        GameObject go = (GameObject)Utils.MyInstantiate(obj);

        go.transform.position = up.transform.position + new Vector3(0, 1f, 0);
        go.transform.SetParent(map.transform, false);

        go = (GameObject)Utils.MyInstantiate(obj);
        go.transform.position = down.transform.position + new Vector3(0, 1f, 0);
        go.transform.SetParent(map.transform, false);

        go = (GameObject)Utils.MyInstantiate(obj);
        go.transform.position = left.transform.position + new Vector3(0, 1f, 0);
        go.transform.SetParent(map.transform, false);

        go = (GameObject)Utils.MyInstantiate(obj);
        go.transform.position = right.transform.position + new Vector3(0, 1f, 0);
        go.transform.SetParent(map.transform, false);
    }
Ejemplo n.º 2
0
    private void CreateWall(GameObject gameObject, int x, int y)
    {
        TileScript2D up    = DungeonGenerationUtils.GetUpTile(x, y, tilesMap);
        TileScript2D down  = DungeonGenerationUtils.GetDownTile(x, y, tilesMap);
        TileScript2D left  = DungeonGenerationUtils.GetLeftTile(x, y, tilesMap);
        TileScript2D right = DungeonGenerationUtils.GetRightTile(x, y, tilesMap);

        UnityEngine.Object obj = null;
        float degrees          = 0;

        if (IsNullOrFloor(up) && IsNullOrFloor(down))
        {
            obj = Resources.Load("WallCubeH");
        }
        if (IsNullOrFloor(right) && IsNullOrFloor(left))
        {
            obj     = Resources.Load("WallCubeH");
            degrees = 90;
        }
        if (IsWall(up) && IsWall(left))
        {
            obj     = Resources.Load("WallAngle");
            degrees = 270;
        }

        if (IsWall(up) && IsWall(right))
        {
            obj     = Resources.Load("WallAngle");
            degrees = 180;
        }

        if (IsWall(down) && IsWall(left))
        {
            obj     = Resources.Load("WallAngle");
            degrees = 0;
        }

        if (IsWall(down) && IsWall(right))
        {
            obj     = Resources.Load("WallAngle");
            degrees = 90;
        }


        if (obj != null)
        {
            GameObject go = (GameObject)Utils.MyInstantiate(obj);
            go.transform.position = gameObject.transform.position + new Vector3(0, 1.5f, 0);
            go.transform.Rotate(Vector3.up, degrees);
            go.transform.SetParent(map.transform, false);
        }
    }
Ejemplo n.º 3
0
    private void CreateDoor(GameObject gameObject, int x, int y)
    {
        TileScript2D up      = DungeonGenerationUtils.GetUpTile(x, y, tilesMap);
        TileScript2D down    = DungeonGenerationUtils.GetDownTile(x, y, tilesMap);
        float        degrees = 90;

        UnityEngine.Object obj = Resources.Load("Door");
        if (IsWall(up) && IsWall(down))
        {
            degrees = 0;
        }

        GameObject go = (GameObject)Utils.MyInstantiate(obj);

        go.transform.position = gameObject.transform.position + new Vector3(0, 1.5f, 0);
        go.transform.Rotate(Vector3.up, degrees);
        go.transform.SetParent(map.transform, false);
        if (lockedDoors.ContainsKey(gameObject))
        {
            LockDoorAndCreateKey(go, gameObject);
        }
    }