Exemplo n.º 1
0
 public ScaleDecider(MelodyPlayer.Note note, ScaleType scaleType)
 {
     currentScale = CreateScale(note, scaleType);
     currentScaleType = scaleType;
     towerUnderHP = false;
     inTransition = false;
     clickCounter = 0;
     random = new Random();
     SCALE_CHANGE_HP_TRESHOLD = (App.Instance.Model.Tower.MaxHealth - 100) * 0;
 }
        public TowerAudioEngine(BaseModel baseModel)
        {
          try
          {
            this.baseModel = baseModel;

            audioEngine = new AudioEngine("Content/8bit.xgs");
            audioEngine.Update();

            //setting the values in App.Instance.Music
            App.Instance.Model.Music.TimeSignature = new TimeSignature(4, 4);
            App.Instance.Model.Music.Tempo = 60;
            App.Instance.Model.Music.ClicksPerBeat = 4;

            //this is needed as the constructor does something magical which allows the sounds to play
            waveBanks = new LinkedList<WaveBank>();
            waveBanks.Add(new WaveBank(audioEngine, "Content/Drum Bank.xwb"));
            waveBanks.Add(new WaveBank(audioEngine, "Content/Effect Bank.xwb"));
            waveBanks.Add(new WaveBank(audioEngine, "Content/Eva Bank.xwb"));
            waveBanks.Add(new WaveBank(audioEngine, "Content/Simpleb Bank.xwb"));
            waveBanks.Add(new WaveBank(audioEngine, "Content/Spaceb Bank.xwb"));
            waveBanks.Add(new WaveBank(audioEngine, "Content/Weeping Bank.xwb"));

            drumPlayer = new DrumPlayer(audioEngine);
            melodyPlayer = new MelodyPlayer(audioEngine);
            effectPlayer = new EffectPlayer(audioEngine, this);

            App.Instance.Model.Music.Click += new EventHandler(OnClick);
            App.Instance.Model.Music.Beat += new EventHandler(OnBeat);
            App.Instance.Model.Music.Bar += new EventHandler(OnBar);
            App.Instance.Model.Update += new EventHandler<SurfaceTower.Model.EventArguments.UpdateArgs>(OnUpdate);
          }
          catch (InvalidOperationException)
          {
            Console.WriteLine("There is no audio device plugged in. AudioEngine will not be used.");
          }
        }
        public TowerAudioEngine(BaseModel baseModel)
        {
            try
            {
                this.baseModel = baseModel;

                audioEngine = new AudioEngine("Content/8bit.xgs");
                audioEngine.Update();

                //setting the values in App.Instance.Music
                App.Instance.Model.Music.TimeSignature = new TimeSignature(4, 4);
                App.Instance.Model.Music.Tempo         = 60;
                App.Instance.Model.Music.ClicksPerBeat = 4;

                //this is needed as the constructor does something magical which allows the sounds to play
                waveBanks = new LinkedList <WaveBank>();
                waveBanks.Add(new WaveBank(audioEngine, "Content/Drum Bank.xwb"));
                waveBanks.Add(new WaveBank(audioEngine, "Content/Effect Bank.xwb"));
                waveBanks.Add(new WaveBank(audioEngine, "Content/Eva Bank.xwb"));
                waveBanks.Add(new WaveBank(audioEngine, "Content/Simpleb Bank.xwb"));
                waveBanks.Add(new WaveBank(audioEngine, "Content/Spaceb Bank.xwb"));
                waveBanks.Add(new WaveBank(audioEngine, "Content/Weeping Bank.xwb"));

                drumPlayer   = new DrumPlayer(audioEngine);
                melodyPlayer = new MelodyPlayer(audioEngine);
                effectPlayer = new EffectPlayer(audioEngine, this);

                App.Instance.Model.Music.Click += new EventHandler(OnClick);
                App.Instance.Model.Music.Beat  += new EventHandler(OnBeat);
                App.Instance.Model.Music.Bar   += new EventHandler(OnBar);
                App.Instance.Model.Update      += new EventHandler <SurfaceTower.Model.EventArguments.UpdateArgs>(OnUpdate);
            }
            catch (InvalidOperationException)
            {
                Console.WriteLine("There is no audio device plugged in. AudioEngine will not be used.");
            }
        }
Exemplo n.º 4
0
        private Scale CreateScale(MelodyPlayer.Note note, ScaleType scaleType)
        {
            int scaleLength = scaleSignature[(int)scaleType].Length;
            int len = scaleLength * 4;

            int[] result = new int[len];
            result[0] = (int)note;
            for (int i = 0; i < len - 1; i++)
            {
                result[i + 1] = (result[i] + scaleSignature[(int)scaleType][i % scaleLength]);
                if (result[i + 1] > MelodyPlayer.SOUNDPACKSIZE)
                    result[i + 1] = (result[i + 1] % MelodyPlayer.SOUNDPACKSIZE);
            }

            return new Scale(result, scaleType);
        }