Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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));
        }