Esempio n. 1
0
        // Add a theme to the repo if it's valid
        public void RegisterThemeSprites(Theme_SO sprites)
        {
            if (_themeSprites.ContainsKey(sprites.Name))
            {
                DialogueLogger.LogWarning($"Theme sprites for {sprites.Name} already exist, overwritting");
            }

            if (validateSprites(sprites))
            {
                _themeSprites[sprites.Name] = sprites;
            }
        }
Esempio n. 2
0
        // Check all the values are valid
        private bool validateSprites(Theme_SO sprites)
        {
            var names = new List <string>();

            if (sprites.ThemeSprites.Count == 0)
            {
                DialogueLogger.LogWarning($"Trying to register theme sprites for {sprites.Name} but the sprite list is empty");
            }

            foreach (var spritePair in sprites.ThemeSprites)
            {
                // Check name
                if (string.IsNullOrEmpty(spritePair.Name) || string.IsNullOrWhiteSpace(spritePair.Name))
                {
                    DialogueLogger.LogError($"Error registering theme sprites for {sprites.Name}, one or more of the names is empty");
                    return(false);
                }

                // Check for duplicate names
                if (names.Contains(spritePair.Name))
                {
                    DialogueLogger.LogError($"Error registering theme sprites for {sprites.Name}, there is already a sprite with the name {spritePair.Name}. Each sprite must have a unique name");
                    return(false);
                }

                names.Add(spritePair.Name);

                // Check sprites
                if (spritePair.Sprite == null)
                {
                    DialogueLogger.LogError($"Error registering theme sprites for {sprites.Name} with the sprite name {spritePair.Name}, but the sprite is empty");
                    return(false);
                }
            }

            return(true);
        }