Exemple #1
0
        // Load the player's SongBook when the save is reloaded
        public override void LoadData(SerializationReader Reader)
        {
            base.LoadData(Reader);
            Songs.Clear();
            int songCount = Reader.ReadInt32();

            for (int i = 0; i < songCount; i++)
            {
                acegiak_Song song = new acegiak_Song();
                song.Name    = Reader.ReadString();
                song.Notes   = Reader.ReadString();
                song.Faction = Reader.ReadString();
                song.Effect  = Reader.ReadString();
                string themes = Reader.ReadString();
                if (string.IsNullOrEmpty(themes))
                {
                    song.Themes = new List <string>();
                }
                else
                {
                    song.Themes = themes.Split(',').ToList();
                }
                Songs.Add(song);
            }
        }
        public void PlaySong(GameObject player)
        {
            acegiak_Song song = ChooseSong(player);

            List <UnityEngine.GameObject> GOs = new List <UnityEngine.GameObject>();

            foreach (string voice in SoundName.Split(';'))
            {
                string[] bits = voice.Split(':');

                UnityEngine.GameObject gameObject;
                gameObject = new UnityEngine.GameObject();
                gameObject.transform.position = new Vector3(0f, 0f, 1f);
                gameObject.name = "MusicPlayer";
                gameObject.AddComponent <acegiak_AudioSequencer>();
                UnityEngine.Object.DontDestroyOnLoad(gameObject);

                acegiak_AudioSequencer component = gameObject.GetComponent <acegiak_AudioSequencer>();

                if (bits.Length > 1)
                {
                    component.Read(bits[0], song.Notes, bits[1]);
                }
                else
                {
                    component.Read(bits[0], song.Notes, String.Empty);
                }
                GOs.Add(gameObject);
            }
            foreach (UnityEngine.GameObject GO in GOs)
            {
                GO.GetComponent <acegiak_AudioSequencer>().Play();
            }
            IPart.AddPlayerMessage((player.IsPlayer()?"You play":player.The + player.DisplayNameOnly + player.GetVerb("play")) + " " + song.Name + " on " + ParentObject.the + ParentObject.DisplayNameOnly);
            if (song.Effect != null)
            {
                //IPart.AddPlayerMessage("Effect:"+song.Effect);
                try{
                    Effect effect = Activator.CreateInstance(Type.GetType(song.Effect)) as Effect;
                    //effect.Duration = Stat.Rnd2.Next(100);
                    //IPart.AddPlayerMessage("Effect:"+effect.DisplayName);
                    player.ApplyEffect(effect);
                }catch (Exception E) {
                    Debug.Log("CAVES OF CHORDS COULD NOT LOAD PLAYER EFFECT: " + song.Effect);
                }
            }
            player.FireEvent(Event.New("PlayedSong", "Object", ParentObject));
        }
Exemple #3
0
 public void SongsIKnow()
 {
     if (ParentObject.IsPlayer())
     {
         // Songs = GetBaseSongs().Select(b=>new acegiak);
         return;
     }
     Loading.SetLoadingStatus("Composing songs...");
     for (int i = Stat.Rnd2.Next(5); i > 0; i--)
     {
         acegiak_Song song = SongOfMyPeople();
         if (song != null)
         {
             Songs.Add(song);
         }
     }
     Loading.SetLoadingStatus(null);
 }
Exemple #4
0
        public acegiak_Song SongOfMyPeople()
        {
            if (ParentObject == null || ParentObject.GetPart <Brain>() == null || ParentObject.GetPart <Brain>().GetPrimaryFaction() == null)
            {
                return(null);
            }
            List <string>       tags          = FactionTags(ParentObject.GetPart <Brain>().GetPrimaryFaction());
            List <acegiak_Song> ElligbleSongs = new List <acegiak_Song>();

            foreach (GameObject item in GetBaseSongs())
            {
                if (item.HasTag("musictags"))
                {
                    List <string> songtags = item.GetTag("musictags").Split(',').ToList();
                    if (tags.Where(b => songtags.Contains(b)).Any())
                    {
                        acegiak_Song Song = new acegiak_Song();
                        Song.Notes  = item.GetTag("musicnotes");
                        Song.Name   = item.GetBlueprint().Name;
                        Song.Effect = item.GetTag("musiceffect");
                        if (Song.Effect != null)
                        {
                            Song.Effect = Song.Effect.Split(',').ToList().GetRandomElement();
                        }
                        if (item.HasTag("musicthemes"))
                        {
                            Song.Themes = item.GetTag("musicthemes").Split(',').ToList();
                        }
                        ElligbleSongs.Add(Song);
                    }
                }
            }
            if (ElligbleSongs.Count() <= 0)
            {
                return(null);
            }
            return(MakeItCultural(ElligbleSongs.GetRandomElement(), ParentObject.GetPart <Brain>().GetPrimaryFaction()));
        }
        public void Compose(GameObject who)
        {
            List <UnityEngine.GameObject> GOs = new List <UnityEngine.GameObject>();

            foreach (string voice in SoundName.Split(';'))
            {
                string[] bits = voice.Split(':');

                UnityEngine.GameObject gameObject;
                gameObject = new UnityEngine.GameObject();
                gameObject.transform.position = new Vector3(0f, 0f, 1f);
                gameObject.name = "MusicPlayer";
                gameObject.AddComponent <acegiak_AudioSequencer>();
                gameObject.GetComponent <acegiak_AudioSequencer>().recordVoice = bits[0];
                if (bits.Length > 1)
                {
                    gameObject.GetComponent <acegiak_AudioSequencer>().recordVolume = Int32.Parse(bits[1]) / 100f;
                }
                UnityEngine.Object.DontDestroyOnLoad(gameObject);

                GOs.Add(gameObject);
            }

            foreach (UnityEngine.GameObject GO in GOs)
            {
                acegiak_AudioSequencer component = GO.GetComponent <acegiak_AudioSequencer>();
                component.Record();
            }
            Popup.AskString("Play with 0-9", "", 300);

            // acegiak_ScreenBufferMaker p = delegate(ScreenBuffer sb, int charcode)
            //  {
            //      ConsoleChar c = new ConsoleChar();
            //      c.Tile = "Tiles/sw_box.bmp";
            //      sb[1,1] = c;
            //      ConsoleChar f = new ConsoleChar();
            //      f.Tile = "Tiles/sw_box.bmp";
            //      sb[3,3] = f;
            //      //IPart.AddPlayerMessage("Boxy?");
            //      return sb;
            //  };
            // acegiak_CustomPopup.CustomRender(p,20,10);

            if (XRLCore.Core.Game.Player.Body.HasSkill("acegiak_Customs_Music"))
            {
                string songname = Popup.AskString("Name this song. (leave blank to forget)", "", 140);
                if (songname != null && songname.Length > 0)
                {
                    acegiak_SongBook book = who.GetPart <acegiak_SongBook>();
                    if (book == null)
                    {
                        Popup.Show(who.The + who.DisplayNameOnly + " can't remember songs.");
                    }
                    else
                    {
                        acegiak_Song song = new acegiak_Song();
                        song.Name  = songname;
                        song.Notes = GOs[0].GetComponent <acegiak_AudioSequencer>().Print();
                        book.Songs.Add(song);

                        JournalAPI.AddAccomplishment("You wrote a song: " + song.Name);
                        JournalAPI.AddObservation(song.Name, song.Name, "Songs", null, null, true);
                    }
                }
            }

            who.FireEvent(Event.New("PlayedSong", "Object", ParentObject));
        }
Exemple #6
0
        public acegiak_Song MakeItCultural(acegiak_Song song, string faction)
        {
            if (song.Themes != null)
            {
                List <string> songwords = new List <string> {
                    "song", "tune", "lullabye", "sound", "call", "tone"
                };
                string FactionFancy = Factions.get(faction).DisplayName;
                string theme        = song.Themes.GetRandomElement();
                string themeShort   = theme.Replace("the ", "").Replace("ing", "");
                switch (Stat.Rnd2.Next(8))
                {
                case 0:
                    song.Name = Grammar.Adjectify(FactionFancy) + " " + theme.Replace("the ", "") + " " + songwords.GetRandomElement();
                    break;

                case 1:
                    song.Name = theme.Replace("the ", "") + " " + songwords.GetRandomElement() + " of " + FactionInfo.getFormattedName(faction);
                    break;

                case 2:
                    song.Name = Grammar.Adjectify(themeShort) + " " + songwords.GetRandomElement() + " of " + FactionInfo.getFormattedName(faction);
                    break;

                case 3:
                    song.Name = Grammar.Adjectify(FactionFancy) + " " + songwords.GetRandomElement() + " of " + theme;
                    break;

                case 4:
                    song.Name = Grammar.MakePossessive(FactionFancy) + " " + songwords.GetRandomElement() + " of " + theme;
                    break;

                case 5:
                    song.Name = Grammar.MakePossessive(FactionFancy) + " " + song.Themes.GetRandomElement() + " " + songwords.GetRandomElement();
                    break;

                case 6:
                    song.Name = Grammar.MakePossessive(FactionFancy) + " " + Grammar.Adjectify(song.Themes.GetRandomElement()) + " " + songwords.GetRandomElement();
                    break;

                case 7:
                    song.Name = Grammar.Adjectify(themeShort) + " " + songwords.GetRandomElement() + " of " + FactionInfo.getFormattedName(faction);
                    break;
                }
                song.Name = Grammar.MakeTitleCase(song.Name);
            }

            List <List <float> > noteData = new List <List <float> >();

            foreach (string note in song.Notes.Split(';'))
            {
                List <float> notefloats = new List <float>();
                foreach (string notebit in note.Split(','))
                {
                    if (notebit.Length > 0)
                    {
                        float f = acegiak_AudioSequencer.ParseFloat(notebit);
                        notefloats.Add(f);
                    }
                }
                noteData.Add(notefloats);
            }


            noteData = noteTransform(noteData, FactionTags(faction));

            List <string> notebits = new List <string>();

            foreach (List <float> floatlist in noteData)
            {
                List <string> fromfloats = new List <string>();
                foreach (float f in floatlist)
                {
                    fromfloats.Add(f.ToString());
                }
                string joinedfloats = String.Join(",", fromfloats.ToArray());
                notebits.Add(joinedfloats);
            }
            song.Notes = String.Join(";", notebits.ToArray());



            return(song);
        }