Example #1
0
        public override void Start(Game game)
        {
            /*test plugin loading
             *
             * Assembly testAssembly = Utils.PluginLoader.LoadPlugin(Path.Combine(chartPath, "script.dll"));
             * SongScript testScript = null;
             * foreach(Type type in testAssembly.GetTypes())
             * {
             *  if(typeof(SongScript).IsAssignableFrom(type))
             *  {
             *      testScript = Activator.CreateInstance(type) as SongScript;
             *
             *  }
             * }
             * testScript.runScript();
             */

            instance             = this;
            Arrow.movementAmount = 75; //static amount
            this.components      = new List <Component>();
            type = objType.nonvisual;

            approachBeat = (float)Game.approachSpeed * ((float)(chartInfo.bpm) / 60000);
            scoreTime    = (float)Game.scoringTime * ((float)(chartInfo.bpm) / 60000);
            missTime     = (float)Game.missTime * ((float)(chartInfo.bpm) / 60000);
            //Console.WriteLine(Path.Combine(chartPath, chartInfo.songPath));
            List <NoteInfo> tempL = new List <NoteInfo>();
            List <NoteInfo> tempR = new List <NoteInfo>();
            List <NoteInfo> tempU = new List <NoteInfo>();
            List <NoteInfo> tempD = new List <NoteInfo>();

            foreach (var item in chartInfo.notes)
            {
                switch (item.collumn)
                {
                case collumn.Left:
                    tempL.Add(item);
                    break;

                case collumn.Down:
                    tempD.Add(item);
                    break;

                case collumn.Up:
                    tempU.Add(item);
                    break;

                case collumn.Right:
                    tempR.Add(item);
                    break;

                default:
                    break;
                }
            }
            Receiver[] receiverss = new Receiver[4];
            receiverss[0] = new Receiver(collumn.Left, tempL, this);
            receiverss[3] = new Receiver(collumn.Right, tempR, this);
            receiverss[2] = new Receiver(collumn.Up, tempU, this);
            receiverss[1] = new Receiver(collumn.Down, tempD, this);


            game.addGameObject(receiverss[0]);
            game.addGameObject(receiverss[1]);
            game.addGameObject(receiverss[2]);
            game.addGameObject(receiverss[3]);

            chartEventHandler = new ChartEventHandler(this, receiverss, new List <EventInfo>(chartInfo.events));

            foreach (NoteInfo noteI in chartInfo.notes)
            {
                //float notems = (float)Math.Ceiling(noteI.time / ((float)chartInfo.bpm / 60000));
                //msNotes.Add()
            }

            //check if theres a video
            if (chartInfo.video.videoPath != null)
            {
                game.addGameObject(new VideoPlayer(Path.Combine(chartPath, chartInfo.video.videoPath), chartPath, Path.Combine(chartPath, "ChartInfo.json"), chartInfo.video, this));
            }

            scoreHandler = new ScoreHandler(this, chartInfo.notes.Length);
            game.addGameObject(scoreHandler);
            game.addGameObject(chartEventHandler);
            firstBPM = chartInfo.bpm;
            song     = game.audioManager.addTrack(Path.Combine(chartPath, chartInfo.songPath));
            double tempbeat = beatstoADD + (((TimeConverterFactory.Instance.GetTimeConverterForSource(song.sampleSource).ToTimeSpan(song.sampleSource.WaveFormat, song.sampleSource.Length).TotalMilliseconds) * ((float)(firstBPM) / 60000)));

            VideoPlayer.LastBeat = (float)Math.Round(tempbeat, 2);
            //debug obj
            game.addGameObject(new ChartDebug(this));



            //song.sampleSource.SetPosition(TimeSpan.FromMilliseconds(startBeat / ((float)(chartInfo.bpm) / 60000)));
        }
Example #2
0
        public override void Start(Game game)
        {
            //script load/setup
            if (chartInfo.script != null)
            {
                Assembly   scriptAssembly = Utils.PluginLoader.LoadPlugin(Path.Combine(chartPath, chartInfo.script));
                SongScript script         = null;
                foreach (Type type in scriptAssembly.GetTypes())
                {
                    if (typeof(SongScript).IsAssignableFrom(type))
                    {
                        script = Activator.CreateInstance(type) as SongScript;
                    }
                }
                //you best have loaded one b o i
                scriptLoader = new ScriptLoader(script, this);
                game.addGameObject(scriptLoader);
            }



            instance        = this;
            this.Components = new List <Component>();
            GameObjectType  = objType.nonvisual;

            approachBeat = (float)Game.ApproachSpeed * ((float)(chartInfo.bpm) / 60000);
            scoreTime    = (float)Game.ScoringTime * ((float)(chartInfo.bpm) / 60000);
            missTime     = (float)Game.MissTime * ((float)(chartInfo.bpm) / 60000);
            //Console.WriteLine(Path.Combine(chartPath, chartInfo.songPath));
            List <NoteInfo> tempL = new List <NoteInfo>();
            List <NoteInfo> tempR = new List <NoteInfo>();
            List <NoteInfo> tempU = new List <NoteInfo>();
            List <NoteInfo> tempD = new List <NoteInfo>();

            foreach (var item in chartInfo.notes)
            {
                switch (item.collumn)
                {
                case collumn.Left:
                    tempL.Add(item);
                    break;

                case collumn.Down:
                    tempD.Add(item);
                    break;

                case collumn.Up:
                    tempU.Add(item);
                    break;

                case collumn.Right:
                    tempR.Add(item);
                    break;

                default:
                    break;
                }
            }
            receivers    = new Receiver[4];
            receivers[0] = new Receiver(collumn.Left, tempL, this);
            receivers[3] = new Receiver(collumn.Right, tempR, this);
            receivers[2] = new Receiver(collumn.Up, tempU, this);
            receivers[1] = new Receiver(collumn.Down, tempD, this);


            game.addGameObject(receivers[0]);
            game.addGameObject(receivers[1]);
            game.addGameObject(receivers[2]);
            game.addGameObject(receivers[3]);

            chartEventHandler = new ChartEventHandler(this, receivers, new List <EventInfo>(chartInfo.events));

            foreach (NoteInfo noteI in chartInfo.notes)
            {
                //float notems = (float)Math.Ceiling(noteI.time / ((float)chartInfo.bpm / 60000));
                //msNotes.Add()
            }

            //check if theres a video
            if (chartInfo.video.videoPath != null)
            {
                game.addGameObject(new VideoPlayer(Path.Combine(chartPath, chartInfo.video.videoPath), chartPath, Path.Combine(chartPath, "ChartInfo.json"), chartInfo.video, this));
            }

            scoreHandler = new ScoreHandler(this, chartInfo.notes.Length);
            game.addGameObject(scoreHandler);
            game.addGameObject(chartEventHandler);
            firstBPM = chartInfo.bpm;
            if (scriptLoader != null)
            {
                scriptLoader.songStart();
            }
            song = game.AudioManagerInstance.addTrack(Path.Combine(chartPath, chartInfo.songPath));
            double tempbeat = beatstoADD + (((TimeConverterFactory.Instance.GetTimeConverterForSource(song.sampleSource).ToTimeSpan(song.sampleSource.WaveFormat, song.sampleSource.Length).TotalMilliseconds) * ((float)(firstBPM) / 60000)));

            VideoPlayer.LastBeat = (float)Math.Round(tempbeat, 2);
            //debug obj
            game.addGameObject(new ChartDebug(this));
            game.DisplayInstance.windowManager.CenterWindow();


            //song.sampleSource.SetPosition(TimeSpan.FromMilliseconds(220 / ((float)(chartInfo.bpm) / 60000)));
        }