Esempio n. 1
0
 public void AddDoorListRange(DoorList d)
 {
     floor.AddRange(d.floor);
     wall.AddRange(d.wall);
     door.AddRange(d.door);
     return;
 }
Esempio n. 2
0
    public DoorList CreateAllDoors()
    {
        DoorList dl = new DoorList();

        if (Opening.Equals(Direction.None))
        {
            Debug.Log("Bye");
            return(dl);
        }
        if (Opening.HasFlag(Direction.Up))
        {
            dl.AddDoorListRange(FindUpOpening());
        }
        if (Opening.HasFlag(Direction.Right))
        {
            dl.AddDoorListRange(FindRightOpening());
        }
        if (Opening.HasFlag(Direction.Down))
        {
            dl.AddDoorListRange(FindDownOpening());
        }
        if (Opening.HasFlag(Direction.Left))
        {
            dl.AddDoorListRange(FindLeftOpening());
        }
        return(dl);
    }
Esempio n. 3
0
 public void CopyRoomObjects(RoomObj room)
 {
     foreach (var current in room.TerrainObjList)
     {
         TerrainObjList.Add(current.Clone() as TerrainObj);
     }
     foreach (var current2 in room.GameObjList)
     {
         GameObjList.Add(current2.Clone() as GameObj);
     }
     foreach (var current3 in room.DoorList)
     {
         var doorObj = current3.Clone() as DoorObj;
         doorObj.Room = this;
         DoorList.Add(doorObj);
     }
     foreach (var current4 in room.EnemyList)
     {
         EnemyList.Add(current4.Clone() as EnemyObj);
     }
     foreach (var current5 in room.BorderList)
     {
         BorderList.Add(current5.Clone() as BorderObj);
     }
 }
Esempio n. 4
0
        public IWebElement GetRandomDoor()
        {
            List <string> doorsId    = GetDoorId();
            Random        r          = new Random();
            string        randomDoor = doorsId[r.Next(0, doorsId.Count)];

            return(DoorList.Where(e => e.GetAttribute(HtmlAttributesConsts.OBJECT_ID).Equals(randomDoor)).FirstOrDefault());
        }
Esempio n. 5
0
 public override void Dispose()
 {
     if (!IsDisposed)
     {
         foreach (var current in DoorList)
         {
             current.Dispose();
         }
         DoorList.Clear();
         DoorList = null;
         foreach (var current2 in TerrainObjList)
         {
             current2.Dispose();
         }
         TerrainObjList.Clear();
         TerrainObjList = null;
         foreach (var current3 in GameObjList)
         {
             current3.Dispose();
         }
         GameObjList.Clear();
         GameObjList = null;
         foreach (var current4 in EnemyList)
         {
             current4.Dispose();
         }
         EnemyList.Clear();
         EnemyList = null;
         foreach (var current5 in BorderList)
         {
             current5.Dispose();
         }
         BorderList.Clear();
         BorderList = null;
         BGRender   = null;
         LinkedRoom = null;
         foreach (var current6 in TempEnemyList)
         {
             current6.Dispose();
         }
         TempEnemyList.Clear();
         TempEnemyList = null;
         Player        = null;
         m_fairyChestText.Dispose();
         m_fairyChestText = null;
         m_pauseBG.Dispose();
         m_pauseBG = null;
         m_indexText.Dispose();
         m_indexText = null;
         m_roomInfoText.Dispose();
         m_roomInfoText = null;
         base.Dispose();
     }
 }
Esempio n. 6
0
        /// <summary>
        /// Converts <see cref="DoorListSerialized"/> to <see cref="DoorList"/>.
        /// </summary>
        /// <returns/>
        public DoorList ToDoorList()
        {
            var result = new DoorList();

            foreach (var roomDoor in RoomsAndDoors)
            {
                foreach (var(point, step) in roomDoor.Doors)
                {
                    result.AddDoor(step, roomDoor.Room, point);
                }
            }

            return(result);
        }
Esempio n. 7
0
    public void CreateRooms()
    {
        foreach (Vector3Int v3i in initRooms)
        {
            Debug.Log(v3i + ": " + rooms[v3i.x, v3i.y].Opening);
            TextMeshProUGUI vectorPos = Instantiate(pfTMP, VectorPanel);
            vectorPos.transform.localPosition = (v3i * roomSize) + (new Vector3(roomSize.x * 0.5f, roomSize.y * 0.5f, 0f));
            vectorPos.text = "" + v3i;

            List <Vector3Int> floorsToAdd = rooms[v3i.x, v3i.y].CreateFloors(roomSize);
            foreach (Vector3Int fta in floorsToAdd)
            {
                floorMap.SetTile(new Vector3Int(((v3i.x * roomSize.x) + fta.x), ((v3i.y * roomSize.y) + fta.y), 0), floor);
            }
            List <Vector3Int> wallsToAdd = rooms[v3i.x, v3i.y].CreateWalls(1 == 1);
            foreach (Vector3Int wta in wallsToAdd)
            {
                wallMap.SetTile(new Vector3Int(((v3i.x * roomSize.x) + wta.x), ((v3i.y * roomSize.y) + wta.y), 0), wall);
            }
            DoorList doorsAndMoreToAdd = rooms[v3i.x, v3i.y].CreateAllDoors();
            foreach (Vector3Int f in doorsAndMoreToAdd.floor)
            {
                wallMap.SetTile(new Vector3Int(((v3i.x * roomSize.x) + f.x), ((v3i.y * roomSize.y) + f.y), 0), null);
                floorMap.SetTile(new Vector3Int(((v3i.x * roomSize.x) + f.x), ((v3i.y * roomSize.y) + f.y), 0), floor);
            }
            foreach (Vector3Int w in doorsAndMoreToAdd.wall)
            {
                wallMap.SetTile(new Vector3Int(((v3i.x * roomSize.x) + w.x), ((v3i.y * roomSize.y) + w.y), 0), wall);
            }
            foreach (Vector3Int d in doorsAndMoreToAdd.door)
            {
                wallMap.SetTile(new Vector3Int(((v3i.x * roomSize.x) + d.x), ((v3i.y * roomSize.y) + d.y), 0), door);
            }
        }
        created = true;
    }
Esempio n. 8
0
 /// <summary>
 /// Converts <see cref="DoorList"/> to <see cref="DoorListSerialized"/>.
 /// </summary>
 /// <param name="doorsList"/>
 /// <returns/>
 public static DoorListSerialized FromDoorList(DoorList doorsList)
 => new DoorListSerialized()
 {
     RoomsAndDoors = doorsList.DoorsPerRoom.Values.Select(roomDoor => (RoomDoorsSerialized)roomDoor).ToList()
 };
Esempio n. 9
0
 private List <string> GetDoorId()
 {
     return(DoorList.Select(e => e.GetAttribute(HtmlAttributesConsts.OBJECT_ID)).ToList());
 }
Esempio n. 10
0
    public DoorList FindLeftOpening()
    {
        DoorList   dl = new DoorList();
        Vector3Int lowBound = new Vector3Int(-1, -1, 0), highBound = new Vector3Int(-1, -1, 0);

        for (int y = 0; y < RoomGrid.GetLength(1); y++)
        {
            for (int x = 0; x < RoomGrid.GetLength(0); x++)
            {
                if (RoomGrid[x, y] == TileType.wall && lowBound.y == -1)
                {
                    lowBound.x = x;
                    lowBound.y = y;
                }
                if (RoomGrid[x, RoomGrid.GetLength(1) - 1 - y] == TileType.wall && highBound.y == -1)
                {
                    highBound.x = x;
                    highBound.y = RoomGrid.GetLength(1) - y;
                }
            }
        }
        if ((lowBound.y + 1) < highBound.y)
        {
            bool       DoorFound = false;
            Vector3Int bad       = new Vector3Int(-1, -1, -1);
            int        StartDoor = UnityEngine.Random.Range(lowBound.y + 1, highBound.y);

            List <Walker> wallChecks = new List <Walker>
            {
                new Walker(0, StartDoor, 0, 0, RoomGrid.GetLength(0), RoomGrid.GetLength(1)),
                new Walker(0, StartDoor, 0, 0, RoomGrid.GetLength(0), RoomGrid.GetLength(1))
            };

            while (!DoorFound)
            {
                int option = -1;
                foreach (Walker w in wallChecks)
                {
                    Vector3Int temp;
                    if (option < 0)
                    {
                        temp = w.ControlledStep(2);
                    }
                    else
                    {
                        temp = w.ControlledStep(0);
                    }
                    option *= -1;
                    if (temp == bad)
                    {
                        w.pos     = new Vector3Int((w.pos.x + 1), StartDoor, w.pos.z);
                        w.prevPos = w.pos;
                    }
                    else
                    {
                        if (w.pos != w.prevPos && w.pos.x == w.prevPos.x && !DoorFound)
                        {
                            if (RoomGrid[w.pos.x, w.pos.y] == TileType.wall && RoomGrid[w.prevPos.x, w.prevPos.y] == TileType.wall)
                            {
                                DoorFound = true;
                                if (RoomGrid[w.pos.x + 1, w.pos.y] != TileType.floor || RoomGrid[w.prevPos.x + 1, w.prevPos.y] != TileType.floor)
                                {
                                    RoomGrid[w.pos.x + 1, w.pos.y]         = TileType.floor;
                                    RoomGrid[w.prevPos.x + 1, w.prevPos.y] = TileType.floor;
                                    dl.floor.Add(new Vector3Int(w.pos.x + 1, w.pos.y, w.pos.z));
                                    dl.floor.Add(new Vector3Int(w.prevPos.x + 1, w.prevPos.y, w.prevPos.z));
                                    dl.wall.AddRange(FindNeighborsToWall(w.pos.x + 1, w.pos.y));
                                    dl.wall.AddRange(FindNeighborsToWall(w.prevPos.x + 1, w.prevPos.y));
                                }
                                RoomGrid[w.pos.x, w.pos.y]         = TileType.door;
                                RoomGrid[w.prevPos.x, w.prevPos.y] = TileType.door;
                                dl.door.Add(w.pos);
                                dl.door.Add(w.prevPos);
                                if (w.pos.y < w.prevPos.y)
                                {
                                    doors[3] = new Door(w.pos, w.prevPos, Direction.Left);
                                }
                                else
                                {
                                    doors[3] = new Door(w.prevPos, w.pos, Direction.Left);
                                }
                            }
                        }
                    }
                }
            }
        }
        return(dl);
    }