Example #1
0
        public BoardLibraryEntry AddBoardLibraryEntryIfTileNotYetEntered(TileBase tileToTest)
        {
            BoardLibraryEntry entry = CheckLibraryForTile(tileToTest, BuildTileKeyLibraryDictionary());

            if (entry == null)
            {
                entry = new BoardLibraryEntry();

                entry.tile = tileToTest;
                char firstCharInTileName = tileToTest.name[0];

                if (!CheckBoardLibraryForUsedCharIds(firstCharInTileName))
                {
                    entry.characterId = firstCharInTileName;
                }
                else
                {
                    entry.characterId = RandomCharFromAllowedChars();
                }

                boardLibraryEntryList.Add(entry);
                Debug.Log("Tile from tilemap not yet in Library. Added the tile " + entry.tile + " to " + this.name + " with charId " + entry.characterId);
            }

            return(entry);
        }
Example #2
0
 public void SetDefaultTileOnProfileCreation(TileBase defaultTileBase)
 {
     if (boardLibraryEntryList.Count == 0)
     {
         BoardLibraryEntry defaultEntry = new BoardLibraryEntry();
         defaultEntry.tile = defaultTileBase;
         defaultEntry.useAsDefaultEmptySpace = true;
         defaultEntry.characterId            = '0';
         boardLibraryEntryList.Add(defaultEntry);
     }
 }
Example #3
0
        public BoardLibraryEntry GetDefaultEntry()
        {
            BoardLibraryEntry entry = null;

            for (int i = 0; i < boardLibraryEntryList.Count; i++)
            {
                if (boardLibraryEntryList[i].useAsDefaultEmptySpace)
                {
                    entry = boardLibraryEntryList[i];
                    return(entry);
                }
            }

            if (boardLibraryEntryList.Count > 0)
            {
                return(boardLibraryEntryList[0]);
            }
            else
            {
                Debug.LogError("Library entry list is empty, draw some tiles and save them to add them to the library.");
                return(null);
            }
        }