示例#1
0
        public float GetSpeedForMeteor()
        {
            VisualizationData vd = new VisualizationData();

            MediaPlayer.GetVisualizationData(vd);
            return(vd.Samples.Max() * 3);
        }
    public void SendVisualization()
    {
        VisualizationData v = new VisualizationData();
        Sensor            s = GameObject.Find("SensorController").GetComponent <SensorController>().ActiveSensorObject;

        v.visualization = GameObject.Find("VisualizationSelection").GetComponentInChildren <Text>().text.ToLower();
        v.values        = s.ReadingsArray();
        udp.SendString(JsonUtility.ToJson(v));
    }
示例#3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            noArt = Content.Load <Texture2D>(@"Textures\NoArt");
            font  = Content.Load <SpriteFont>(@"Fonts\Arial");

            visualizationData = new VisualizationData();

            MediaPlayer.IsVisualizationEnabled = true;

            if (MediaPlayer.State == MediaState.Playing)
            {
                //the user is playing their own music - don't reset it
                //just retreive the current playing song and artist and art
                MediaPlayer_ActiveSongChanged(this, null);

                return;
            }

            ICollection <MediaSource> mediaSources = MediaSource.GetAvailableMediaSources();
            MediaLibrary mediaLib = null;

            foreach (MediaSource ms in mediaSources)
            {
                mediaLib = new MediaLibrary(ms);
            }

            if (mediaLib != null)
            {
                for (int i = 0; i < mediaLib.Playlists.Count; i++)
                {
                    if (mediaLib.Playlists[i].Name == "Zune Gems")
                    {
                        playlist = mediaLib.Playlists[i];
                        break;
                    }
                }

                if (playlist == null)
                {
                    playlist = mediaLib.Playlists[0]; // just grab first one
                }
            }

            //If can't find the playlist, just exit.
            if (playlist == null)
            {
                Exit();
            }

            //Assumes at least one song is actually in the playlist
            MediaPlayer.Play(playlist.Songs);
        }
        public int GetAverage(Point Between, VisualizationData visData)
        {
            int average = 0;

            for (int i = Between.X; i < Between.Y; i++)
            {
                average += Convert.ToInt32(visData.Frequencies[i]);
            }
            int diff = Between.Y - Between.X + 1;

            return(average / diff);
        }
示例#5
0
        public void GetVisualization_CorrectParameters_ReturnsCorrectVisualization(VisualizationData visualizationData)
        {
            // Arrange
            CellVisualizationManager instanceUnderTest = new();

            // Act
            CellVisualization visualization = instanceUnderTest.GetVisualization(visualizationData.CellStatusType, visualizationData.AdjacentMineCount);

            // Assert
            visualization.Content.Should().Be(visualizationData.ExpectedContent);
            visualization.CssClass.Should().NotBeNull();
        }
示例#6
0
 protected override void LoadContent()
 {
     this._visualizationData            = new VisualizationData();
     this._referencePosition            = new Vector2Int((int)this._player.Position.X - this._visualizationData.Frequencies.Count / 2, (int)this._player.Position.Z);
     MediaPlayer.Volume                 = 1f;
     MediaPlayer.IsVisualizationEnabled = true;
     new Thread(VisualizationReader)
     {
         IsBackground = true
     }.Start();
     this._song = Game.Content.Load <Song>("Mozart");
     MediaPlayer.Play(this._song);
 }
示例#7
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            player  = new Player();
            plLives = new PlayerLives();
            minimap = new Sprite();
            bgTL    = new Sprite();
            bgTR    = new Sprite();
            bgBL    = new Sprite();
            bgBR    = new Sprite();
            pipeT1  = new PipeT1[5];
            pipeT2  = new PipeT2[5];
            pipeT3  = new PipeT3[5];
            pipeT4  = new PipeT4[5];
            cogs    = new Cog[12];
            viz     = new VisualizationData();
            MediaPlayer.IsVisualizationEnabled = true;
            MediaPlayer.IsRepeating            = true;

            int i = 0;

            for (i = 0; i < pipeT1.Length; i++)
            {
                pipeT1[i] = new PipeT1();
            }
            for (i = 0; i < pipeT2.Length; i++)
            {
                pipeT2[i] = new PipeT2();
            }
            for (i = 0; i < pipeT3.Length; i++)
            {
                pipeT3[i] = new PipeT3();
            }
            for (i = 0; i < pipeT4.Length; i++)
            {
                pipeT4[i] = new PipeT4();
            }

            for (i = 0; i < cogs.Length; i++)
            {
                cogs[i] = new Cog();
            }

            base.Initialize();
        }
示例#8
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            graphics.PreferredBackBufferWidth  = 800; //1920;
            graphics.PreferredBackBufferHeight = 600; //1080;
            graphics.ApplyChanges();

            frameCounter     = 0;
            currentFrameRate = 0;
            frameTime        = 0;

            InitializeEffect();
            InitializeLists();

            visualizationData = new VisualizationData();
            songs             = new Song[2];

            Player1 = new PlayerInput(PlayerIndex.One);

            base.Initialize();
        }
示例#9
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            visData     = new VisualizationData();

            songs     = new Song[5];
            songs[0]  = Content.Load <Song>(@"BG");
            songs[1]  = Content.Load <Song>(@"Bass");
            songs[2]  = Content.Load <Song>(@"Lead");
            songs[3]  = Content.Load <Song>(@"Other");
            songs[4]  = Content.Load <Song>(@"Vox");
            songIndex = 0;

            tw = new StreamWriter(songs[songIndex] + ".txt");

            MediaPlayer.IsVisualizationEnabled = true;
            //MediaPlayer.Volume = 0.0f;
            MediaPlayer.Stop();

            soundData   = "";
            soundBuffer = "";
            prevMin     = 0;
            splitvalue  = 16;
        }
示例#10
0
        public void Update(Microsoft.Xna.Framework.GameTime gametime)
        {
            VisualizationData vd = new VisualizationData();

            MediaPlayer.GetVisualizationData(vd);
            TextureLoader.Std.Parameters[0].SetValue(((vd.Samples.Average() < 0) ? 0 : vd.Samples.Average()) + vd.Samples.Max());

            /*for (int i = 0; i < 256; i++)
             * {
             *  (MainController.Instance.GetByName("ParticleController") as ParticleController).Beat(new Vector2(5 * i, 100), vd.Samples[i]);
             *  (MainController.Instance.GetByName("ParticleController") as ParticleController).Beat(new Vector2(5 * i, 300), vd.Frequencies[i]);
             * }*/
            for (int a = 52; a < 180; a++)
            {
                if (vd.Frequencies[a] > BEAT_REACTION && accomulator[a - 52] > ACCOMULATOR_REACTION)
                {
                    var meteor = ObjectContainer.Instance.TryGet(typeof(Meteor)) as Meteor;
                    if (meteor == null)
                    {
                        ObjectContainer.Instance.Add(new Meteor());
                    }
                    else
                    {
                        meteor.Reuse();
                    }
                    accomulator[a - 52] -= BEAT_COST; // убавляем аккумулятор
                }
            }
            for (int a = 52; a < 180; a++)
            {
                if (accomulator[a - 52] < 1.0f)
                {
                    accomulator[a - 52] += ACCUMULATE_SPEED;
                }
            }
        }
 public static VisualizationDataWithBrokers FromVisualizationData(VisualizationData data)
 {
     return(new VisualizationDataWithBrokers(new VisualizationDataWithBroker(data, "default"),
                                             new[] { new VisualizationBrokerInfo("default", "Default", 0), }));
 }
 public VisualizationDataWithBroker(VisualizationData data, string brokerId)
 {
     BrokerId = brokerId;
     Data     = data;
 }
示例#13
0
        public void SetupGameplay()
        {
            ClearGameObjects();
            m_UIStack.Clear();
            m_UIGameplay = new UI.UIGameplay(m_Game.Content);
            m_UIStack.Push(m_UIGameplay);

            m_bPaused = false;
            GraphicsManager.Get().ResetProjection();

            m_Timer.RemoveAll();

            //Reset all gameplay variables
            Multiplier = 1;
            Combo      = 0;
            Score      = 0;
            HitNotes   = 0;
            MultMult   = 1;
            Shield     = 0;



            // Set grid dimensions and player movement limit
            GraphicsManager.Get().SetGridDimensions(m_GridWidth, m_GridHeight);

            if (!DanceMode)
            {
                m_Player = new Objects.Player(m_Game);
                SpawnGameObject(m_Player);
                m_Camera.FollowObject = m_Player;
                m_Player.setPlayerMovementLimitations(m_GridWidth / 3.0f, m_GridHeight / 3.0f);
            }

            ParseFile(m_SongFile);


            foreach (Objects.BeatPlane b in m_BeatPlanes.Values)
            {
                RemoveBeatPlane(b);
            }
            m_BeatPlanes.Clear();
            m_CurrentSong = m_Songs[0];

            Health     = m_iHealthMax / 2;
            TotalNotes = 0;

            SetState(eGameState.Gameplay);
            createTestBeatPlanes();

            MediaPlayer.Stop();
            MediaPlayer.IsVisualizationEnabled = true;
            m_CurrentSongAudio = m_Game.Content.Load <Song>(m_SongFile.Replace(".txt", ""));

            m_VisualData = new VisualizationData();
            MediaPlayer.Play(m_CurrentSongAudio);

            m_CurrentBeat = 0.0f;

            // Get the beatplane at the beat
            Objects.BeatPlane beatplaneAtCurrentBeat = (Objects.BeatPlane)m_BeatPlanes[m_CurrentBeat];
            if (beatplaneAtCurrentBeat != null)
            {
                // Set it active
                beatplaneAtCurrentBeat.SetActive(m_CurrentSong, Objects.BeatPlane.TunnelDirection.straight);
            }
        }
示例#14
0
        private void DrawSpectrogram(VisualizationData data, CanvasDrawingSession ds, bool bDrawLeftChannel, bool bDrawRightChannel, Vector2 barSize, Vector2 offset)
        {
            int bars = 50;
            // Draw grid
            float   verticalSpacing = 50;
            float   width           = bars * barSize.X;
            Vector2 vLeftOffset     = offset;
            Vector2 vRightOffset    = offset + (bDrawLeftChannel ? new Vector2(0, verticalSpacing + barSize.Y) : Vector2.Zero);


            if (bDrawLeftChannel)
            {
                ds.DrawRectangle(vLeftOffset.X, vLeftOffset.Y, width, barSize.Y, Colors.Gray);
            }
            if (bDrawRightChannel)
            {
                ds.DrawRectangle(vRightOffset.X, vRightOffset.Y, width, barSize.Y, Colors.Gray);
            }

            for (float x = 0; x < width; x += barSize.X)
            {
                if (bDrawLeftChannel)
                {
                    ds.DrawLine(x + vLeftOffset.X, vLeftOffset.Y, x + vLeftOffset.X, vLeftOffset.Y + barSize.Y, Colors.LightGray);
                }
                if (bDrawRightChannel)
                {
                    ds.DrawLine(x + vRightOffset.X, vRightOffset.Y, x + vRightOffset.X, vRightOffset.Y + barSize.Y, Colors.LightGray);
                }
            }

            for (float y = 0; y < barSize.Y; y += (barSize.Y / 10))
            {
                if (bDrawLeftChannel)
                {
                    ds.DrawLine(vLeftOffset.X, vLeftOffset.Y + y, vLeftOffset.X + width, vLeftOffset.Y + y, Colors.LightGray);
                }
                if (bDrawRightChannel)
                {
                    ds.DrawLine(vRightOffset.X, vRightOffset.Y + y, vRightOffset.X + width, vRightOffset.Y + y, Colors.LightGray);
                }
            }

            if (data == null)
            {
                return;
            }

            if (data.Length != 112)
            {
                return;
            }

            float scaleFactor = barSize.Y / 100;

            // Draw 50 bars
            for (uint index = 0; index < 50; index++)
            {
                float xPos = index * barSize.X;
                if (bDrawLeftChannel)
                {
                    float leftHeight = scaleFactor * data[data.GetChannelOffset(0) + index] + barSize.Y;
                    ds.FillRectangle(xPos + vLeftOffset.X, vLeftOffset.Y + barSize.Y - leftHeight, barSize.X, leftHeight, Colors.Orange);
                }
                if (bDrawRightChannel)
                {
                    float rightHeight = scaleFactor * data[data.GetChannelOffset(1) + index] + barSize.Y;
                    ds.FillRectangle(xPos + vRightOffset.X, vRightOffset.Y, barSize.X, rightHeight, Colors.LimeGreen);
                }
            }
        }