예제 #1
0
        private string DuplicateRoom(RoomData originalData)
        {
            // Add a new room file, yo!
            string newRoomKey = originalData.MyWorldData.GetUnusedRoomKey(originalData.RoomKey);

            RoomSaverLoader.SaveRoomFileAs(originalData, originalData.WorldIndex, newRoomKey);
            return(newRoomKey);
        }
예제 #2
0
    private RoomData AddRoomFromFile(string roomKey)
    {
        RoomData newRoomData = new RoomData(this, roomKey);

        RoomSaverLoader.LoadRoomDataFromItsFile(newRoomData);
        roomDatas.Add(roomKey, newRoomData);
        return(newRoomData);
    }
예제 #3
0
 //private void SnapTilesSelectedToGrid() {
 //    foreach (RoomTile tile in tilesSelected) {
 //        Vector2 pos = tile.MyRoomData.PosGlobal;
 //        pos = SnapToGrid(pos);
 //        tile.MyRoomData.SetPosGlobal(pos);
 //    }
 //}
 private void ToggleTilesSelectedIsSecret()
 {
     // Toggle and save 'em all.
     foreach (RoomTile tile in tilesSelected)
     {
         RoomData rd = tile.MyRoomData;
         rd.SetIsSecret(!rd.IsSecret);
         RoomSaverLoader.UpdateRoomPropertiesInRoomFile(rd);
         tile.RefreshAllVisuals();
     }
 }
예제 #4
0
 private void ToggleTilesSelectedIsClustStart()
 {
     // Toggle and save 'em all.
     foreach (RoomTile tile in tilesSelected)
     {
         RoomData rd = tile.MyRoomData;
         rd.isClustStart = !rd.isClustStart;
         RoomSaverLoader.UpdateRoomPropertiesInRoomFile(rd);
     }
     // Reload the world, as our Clusters may have changed from this.
     ReloadAllTiles();
 }
예제 #5
0
 public void SaveRoomFile()
 {
     // Save it!
     RoomSaverLoader.SaveRoomFile(CurrRoom);
     // Update properties that may have changed.
     if (CurrRoom.MyClusterData != null)
     {
         CurrRoom.MyClusterData.RefreshSnackCount();
     }
     // Update total edibles counts!
     dm.RefreshSnackCountGame();
 }
예제 #6
0
        private void OnMouseDown()
        {
            RoomData rd = roomTileRef.MyRoomData;
            // Determine the new value of our flag!
            int newDesignerFlagValue = rd.DesignerFlag + 1;

            if (newDesignerFlagValue >= NUM_FLAG_TYPES)
            {
                newDesignerFlagValue = 0;
            }                                                                             // Loop back to 0.
            // Set and save!
            rd.SetDesignerFlag(newDesignerFlagValue);
            RoomSaverLoader.UpdateRoomPropertiesInRoomFile(rd);
            // Update the designerFlag button
            UpdateDesignerFlagButtonVisuals();
        }
예제 #7
0
    public void ReloadRoomData(string roomKey)
    {
        // Safety check.
        if (!roomDatas.ContainsKey(roomKey))
        {
            //Debug.LogWarning("Can't reload RoomData; doesn't exist. World: " + worldIndex + ", RoomKey: " + roomKey);
            //return;
            AddRoomFromFile(roomKey);
        }
        RoomData roomData = GetRoomData(roomKey);

        // Reload all of this roomData's contents! (WITHOUT remaking it or anything-- it's important to retain all references to it!)
        RoomSaverLoader.LoadRoomDataFromItsFile(roomData);
        // Refresh fundamental world/room properties!
        SetAllRoomDatasFundamentalProperties();
    }
예제 #8
0
    private void DuplicateCurrRoom()
    {
        // Add a new room file, yo!
        RoomData currRD     = CurrRoom.MyRoomData;
        string   newRoomKey = currRD.MyWorldData.GetUnusedRoomKey(currRD.RoomKey);

        RoomSaverLoader.SaveRoomFileAs(currRD, currRD.WorldIndex, newRoomKey);
        dm.ReloadWorldDatas();
        RoomData newRD = dm.GetRoomData(currRD.WorldIndex, newRoomKey, false);

        newRD.isClustStart = false;                                                           // say new room's NOT a clustStart.
        newRD.SetPosGlobal(newRD.PosGlobal + new Vector2(15, -15) * GameProperties.UnitSize); // offset its position a bit.
        newRD.SetDesignerFlag(0);                                                             // Reset its designerFlag
        RoomSaverLoader.UpdateRoomPropertiesInRoomFile(newRD);                                // update file!
        dm.currRoomData = newRD;
        SceneHelper.ReloadScene();
    }
예제 #9
0
    private RoomData AddNewRoom(string roomKey)
    {
        if (GetRoomData(roomKey) != null)   // Safety check.
        {
            Debug.LogError("Whoa, trying to make a Room with key: " + roomKey + ", but one already exists!");
            return(null);
        }
        // Make/populate/add it!
        RoomData rd = new RoomData(this, roomKey);

        rd.SetPosGlobal(GetBrandNewRoomPos());
        RoomSaverLoader.AddEmptyRoomElements(ref rd);
        roomDatas.Add(roomKey, rd);
        // Refresh fundamental world/room properties!
        SetAllRoomDatasFundamentalProperties();
        // Save the file!
        RoomSaverLoader.SaveRoomFile(rd);
        return(rd);
    }
예제 #10
0
    public void OnRoomNameTextEndEdit()
    {
        string newName = tif_roomName.text;

        // MAY rename!
        if (RoomSaverLoader.MayRenameRoomFile(room, newName))
        {
            // Rename the room file, and reload all RoomDatas!
            RoomSaverLoader.RenameRoomFile(room, newName);
            dataManager.ReloadWorldDatas();
            // Save that this is the most recent room we've been to!
            SaveStorage.SetString(SaveKeys.LastPlayedRoomKey(room.WorldIndex), newName);
            dataManager.currRoomData = dataManager.GetRoomData(room.WorldIndex, room.RoomKey, false);
            // Reload the scene for safety.
            SceneHelper.ReloadScene();
        }
        // May NOT rename.
        else
        {
            ResetRoomNameText();
        }
    }
예제 #11
0
        private void OnMouseUp()
        {
            int mouseButton = InputController.GetMouseButtonUp();

            // Dragging a TILE(S), released the LEFT mouse button, AND not holding down the multi-selection key??
            if (tilesSelected.Count > 0 && mouseButton == 0 && !isKeyMultiSelection)
            {
                // Save all dragging tiles' roomData to file (and clear out any snapshot datas)!
                foreach (RoomTile tile in tilesSelected)
                {
                    RoomSaverLoader.UpdateRoomPropertiesInRoomFile(tile.MyRoomData);
                }
                // Update the world-bounds, room neighbors, etc.!
                CurrWorldData.SetAllRoomDatasFundamentalProperties();
                // Update ALL Tiles' visuals.
                foreach (RoomTile tile in CurrWorldRoomTiles)
                {
                    tile.RefreshColors();
                }

//			// Mouse up = release all roomTilesSelected!
//			DeselectTilesSelected();
            }
        }
예제 #12
0
    public void OnRoomNameTextChanged()
    {
        // Change color if there's a naming conflict!
        string newName = tif_roomName.text;
        Color  color;

        if (newName == room.RoomKey)
        {
            color = new Color(0, 0, 0, 0.4f);
        }                                                                // Same name? Black.
        else if (RoomSaverLoader.MayRenameRoomFile(room, newName))
        {
            color = new Color(130 / 255f, 160 / 255f, 40 / 255f);
        }                                                                                                             // Can rename? Green!
        else
        {
            color = new Color(140 / 255f, 55 / 255f, 40 / 255f);
        }                                                       // CAN'T rename? Red.
        // Apply the color.
        foreach (TextMeshProUGUI t in tif_roomName.GetComponentsInChildren <TextMeshProUGUI>())
        {
            t.color = color;
        }
    }