Exemple #1
0
    //This function creates rooms with a specified setting. Currently it is only used to give tiles a color.
    protected LDRoom CreateRoom(IntVector2 currentPos, int[] roomSize, LDRoomSettings setting, bool fixColor)
    {
        LDRoom newRoom = ScriptableObject.CreateInstance <LDRoom>();

        //Check if there already is a room here. In that case, we want to add the new cells to that room
        //If there is a room, it is stored in newRoom
        if (!OverlapsRoom(currentPos, roomSize, ref newRoom))
        {
            Debug.Log(string.Format("Creating Room of [{0}, {1}], color: {2}", roomSize[0], roomSize[1], setting.floorMaterial.name));
            newRoom.settings = setting;
        }
        else
        {
            Debug.Log("Expanding Room.");
        }

        //Add cells to the room, whether it is new or not
        for (int x = currentPos.x - roomSize[0] / 2; x < currentPos.x + roomSize[0] / 2; x++)
        {
            for (int z = currentPos.z - roomSize[1] / 2; z < currentPos.z + roomSize[1] / 2; z++)
            {
                if (ContainsCoordinates(new IntVector2(x, z)))
                {
                    cells[x, z].AddToRoom(newRoom, fixColor);
                }
            }
        }
        return(newRoom);
    }
Exemple #2
0
 public LDCell()
 {
     ////we should be able to find these automatically, but I get a weird bug.
     //closedForm = transform.GetChild(0).gameObject;
     //openForm = transform.GetChild(1).gameObject;
     //indicator = transform.GetChild(2).gameObject;
     room           = null;
     CanChangeColor = true;
 }
Exemple #3
0
 public void AddToRoom(LDRoom _room, bool fixColor)
 {
     room = _room;
     room.Add(this);
     openForm.SetActive(true);
     closedForm.SetActive(false);
     if (CanChangeColor)
     {
         openForm.GetComponent <Renderer>().material = room.settings.floorMaterial;  // We only have a floor
         CanChangeColor = fixColor;
     }
 }
Exemple #4
0
 protected bool OverlapsRoom(IntVector2 currentPos, int[] roomSize, ref LDRoom room)
 {
     for (int x = currentPos.x - roomSize[0] / 2; x < currentPos.x + roomSize[0] / 2; x++)
     {
         for (int z = currentPos.z - roomSize[1] / 2; z < currentPos.z + roomSize[1] / 2; z++)
         {
             if (ContainsCoordinates(new IntVector2(x, z)))
             {
                 if (cells[x, z].room != null)
                 {
                     room = cells[x, z].room;
                     return(true);
                 }
             }
         }
     }
     return(false);
 }