コード例 #1
0
 public void SetTagModel(ref Button button, TagsType tagsType)
 {
     if (button.FontWeight == FontWeights.Normal)
     {
         button.FontWeight = FontWeights.Bold;
         button.Foreground = FindResource("MouseOverBrush") as SolidColorBrush;
         if (tagsType == TagsType.SongTags)
         {
             SongTags.Add(button.Content.ToString());
         }
         else if (tagsType == TagsType.SelectTags)
         {
             SelectTags.Add(button.Content.ToString());
         }
     }
     else if (button.FontWeight == FontWeights.Bold)
     {
         button.FontWeight = FontWeights.Normal;
         button.Foreground = FindResource("ForegroundBrush") as SolidColorBrush;
         if (tagsType == TagsType.SongTags)
         {
             SongTags.RemoveAt(SongTags.IndexOf(button.Content.ToString()));
         }
         else if (tagsType == TagsType.SelectTags)
         {
             SelectTags.RemoveAt(SelectTags.IndexOf(button.Content.ToString()));
         }
     }
 }
コード例 #2
0
ファイル: AudioManager.cs プロジェクト: Xhyzi/GravityBat
 /// <summary>
 /// Para la reproduccion de una cancion cargada.
 /// </summary>
 /// <param name="tag">Tag identificador de la cancion de parar.</param>
 public void StopSong(SongTags tag)
 {
     if (trackGOs.ContainsKey(tag))
     {
         trackGOs[tag].GetComponent <Song>().Stop();
     }
 }
コード例 #3
0
        private Button CreateButton(string content, int count)
        {
            var window = new Window();
            var button = new Button
            {
                Name            = "btn" + count,
                Content         = content,
                Width           = 70,
                Height          = 20,
                Background      = new SolidColorBrush(Colors.Transparent),
                BorderThickness = new Thickness(0),
                Template        = window.FindResource("TagsButtonTemplate") as ControlTemplate,
            };

            if (SongTags.Contains(content))
            {
                button.FontWeight = FontWeights.Bold;
                button.Foreground = FindResource("MouseOverBrush") as SolidColorBrush;
            }
            else
            {
                button.FontWeight = FontWeights.Normal;
                button.Foreground = FindResource("ForegroundBrush") as SolidColorBrush;
            }
            button.SetBinding(ButtonBase.CommandProperty, new Binding("SelectTagsCommand"));
            button.SetBinding(ButtonBase.CommandParameterProperty, new Binding {
                Source = button
            });
            return(button);
        }
コード例 #4
0
ファイル: AudioManager.cs プロジェクト: Xhyzi/GravityBat
 /// <summary>
 /// Continua la reproduccion de una cancion.
 /// </summary>
 /// <param name="tag">Tag identificador de la cancion a continuar.</param>
 public void ResumeSong(SongTags tag)
 {
     if (trackGOs.ContainsKey(tag))
     {
         trackGOs[tag].GetComponent <Song>().Resume();
     }
 }
コード例 #5
0
ファイル: AudioManager.cs プロジェクト: Xhyzi/GravityBat
        /// <summary>
        /// Carga una fichero de audio desde la carpeta Resources.
        /// </summary>
        /// <param name="tag">Tag identificador de la cancion a cargar</param>
        /// <returns>AudioClip con el fichero de audio</returns>
        private AudioClip GetAudioFromResources(SongTags tag)
        {
            string path = Constants.MUSIC_RESOURCES_PATH;

            switch (tag)
            {
            case SongTags.TITLE_THEME:
                path += Constants.TITLE_THEME;
                break;

            case SongTags.MENU_THEME:
                path += Constants.MENU_THEME;
                break;

            case SongTags.WORLD_1:
                path += Constants.WORLD_1_THEME;
                break;

            default:
                path += Constants.TITLE_THEME;
                break;
            }

            return(Resources.Load(path) as AudioClip);
        }
コード例 #6
0
        public void ClearTags(Window window)
        {
            SongTags.Clear();
            var tagsEditWindow = window as TagsEditingWindow;
            var userControl    = tagsEditWindow.TagsViewControl;

            userControl.ClearTags();
        }
コード例 #7
0
ファイル: AudioManager.cs プロジェクト: Xhyzi/GravityBat
        /// <summary>
        /// Carga una cancion y la guarda en el diccionario.
        /// </summary>
        /// <param name="tag">Tag identificador de la cancion a cargar</param>
        public void LoadSong(SongTags tag)
        {
            GameObject go = new GameObject();

            go.AddComponent <AudioSource>();
            go.GetComponent <AudioSource>().clip = GetAudioFromResources(tag);
            go.AddComponent <Song>();
            trackGOs.Add(tag, go);
        }
コード例 #8
0
        /**
         * Adds a song with manually tags
         * */
        public void AddSong(String filename, params String[] tags)
        {
            //Add into dictionaries
            List <String> taglist = new List <string>(tags);

            SongTags.Add(filename, taglist);

            // Always add implicit default tag

            /*{
             *  if (!TagSongs.ContainsKey(""))
             *      TagSongs.Add("", new List<string>());
             *
             *  TagSongs[""].Add(filename);
             * }
             *
             * foreach (String tag in tags)
             * {
             *  if (!TagSongs.ContainsKey(tag))
             *      TagSongs.Add(tag, new List<string>());
             *
             *  TagSongs[tag].Add(filename);
             * }*/

            // Switch for "default tag"
            if (taglist.Count == 0)
            {
                if (!TagSongs.ContainsKey(""))
                {
                    TagSongs.Add("", new List <string>());
                }

                TagSongs[""].Add(filename);
            }
            else
            {
                foreach (String tag in tags)
                {
                    if (!TagSongs.ContainsKey(tag))
                    {
                        TagSongs.Add(tag, new List <string>());
                    }

                    TagSongs[tag].Add(filename);
                }
            }

            //Sort all songs
            foreach (var songs in TagSongs.Values)
            {
                songs.Sort((s1, s2) => SongTags[s1].Count.CompareTo(SongTags[s2].Count));
            }
        }
コード例 #9
0
        public void RemoveSong(String filename)
        {
            SongTags.Remove(filename);

            foreach (var list in TagSongs.Values)
            {
                list.Remove(filename);
            }

            //Sort all songs
            foreach (var songs in TagSongs.Values)
            {
                songs.Sort((s1, s2) => SongTags[s1].Count.CompareTo(SongTags[s2].Count));
            }
        }
コード例 #10
0
ファイル: AudioManager.cs プロジェクト: Xhyzi/GravityBat
        /// <summary>
        /// Reproduce un audio.
        /// Si no esta cargado en su diccionario correspondiente lo carga.
        /// </summary>
        /// <param name="tag">Tag idenficador de la cancion a reproducir.</param>
        /// <param name="volume">Volumen al que se reproduce el audio.</param>
        public void Play(SongTags tag, float volume)
        {
            try
            {
                if (!trackGOs.ContainsKey(tag))
                {
                    LoadSong(tag);
                }

                trackGOs[tag].GetComponent <Song>().Play(Constants.DEFAULT_SONG_PITCH, Constants.DEFAULT_SONG_LOOP, Constants.DEFAULT_SONG_FADE);
            }
            catch (NullReferenceException nre)
            {
                Debug.LogError("No se ha podido cargar la cancion. Game Object eliminado." +
                               "\n" + nre.ToString() +
                               "\n" + nre.HelpLink);
            }
        }
コード例 #11
0
 public bool Contains(String song)
 {
     return(SongTags.ContainsKey(song));
 }