Ejemplo n.º 1
0
        //=============================================

        public static bool OpenAudio(AudioLibrary audioLibrary, string asioDevice)
        {
            if (_usedLibrary != AudioLibrary.Null || (_playbackDevice != null && _playbackDevice.PlaybackState == PlaybackState.Playing))
            {
                return(false);
            }

            _usedLibrary = audioLibrary;

            if (_usedLibrary == AudioLibrary.NAudio)
            {
                // NAUDIO
                _mixer32 = new RecordableMixerStream32 {
                    AutoStop = false
                };

                // remove this comments if you wanna hear the sounds, but then only realtime recording is possible
                //
                //if (asioDevice != null) {
                //	playbackDevice = new AsioOut(asioDevice);
                //}

                //// if failed, try normal wave out
                //if (playbackDevice == null) playbackDevice = new WaveOut();
                //if (playbackDevice == null) return false;
                //playbackDevice.Init(Mixer32);

                //=============================================
            }
            return(true);
        }
Ejemplo n.º 2
0
    //-------------------------------------------
    //  Nut Collision
    private void HandleNutCollision(Collision c)
    {
        //  Dont deal damage if dashing //
        if (m_dashAttackActive)
        {
            float forceFactor = 35.0F;
            c.gameObject.GetComponent <NutController>().AddForce(Vector3.up * forceFactor + m_rigidbody.velocity * forceFactor);
            m_audioPlayer.PlayOneShot(AudioLibrary.Get().buttStompHit01);
            return;
        }

        float fixedCollisionMagnitude = c.impulse.magnitude + m_rigidbody.velocity.magnitude * 4f;
        float nutVelocityThreshold    = 10.0f;
        float collisionForce          = 100f;
        float collisionThreshold      = 68f;
        float nutStunTime             = 0.3f;

        //  If the nut's velocity is below nutVelocityThreshold then it will not do damamge  //
        if (fixedCollisionMagnitude < collisionThreshold || c.rigidbody.velocity.magnitude < nutVelocityThreshold)
        {
            return;
        }

        //  Apply an upward force if grounded  //
        if (IsGrounded())
        {
            m_rigidbody.AddForce(Vector3.up * collisionForce);
        }

        // TODO: Apply proper force
        Stun(nutStunTime, Vector3.zero);
        m_rigidbody.AddForce((-1 * Vector3.Normalize(transform.position - (transform.position - Vector3.down))) * collisionForce * m_rigidbody.velocity.magnitude);
        m_audioPlayer.PlayOneShot(AudioLibrary.Get().buttStompHit01);
    }
Ejemplo n.º 3
0
 private void Start()
 {
     audioSource  = GetComponent <AudioSource>();
     audioLibrary = GetComponent <AudioLibrary>();
     audioListPanel.SetActive(false);
     PopulateAudioList();
 }
Ejemplo n.º 4
0
    void Awake()
    {
        if (sInstance != null)
        {
            Destroy(gameObject);
        }
        else
        {
            sInstance = this;
            DontDestroyOnLoad(gameObject);

            audioLib = GetComponent <AudioLibrary>();

            musicSources = new AudioSource[2];
            for (int i = 0; i < 2; i++)
            {
                GameObject newMusicSource = new GameObject("Music Source " + (i + 1));
                newMusicSource.transform.parent = this.transform;
                musicSources[i] = newMusicSource.AddComponent <AudioSource>();
            }
            GameObject newSfx2DSource = new GameObject("SFX 2D Source");
            newSfx2DSource.transform.parent = this.transform;
            sfx2DSources = newSfx2DSource.AddComponent <AudioSource>();

            LoadVolumeFormPrefs();

            var target = FindObjectOfType <Player>();
            if (target != null)
            {
                audioListenerTarget = target.transform;
            }
        }
    }
Ejemplo n.º 5
0
        async void AlbumPage_Loaded(object sender, RoutedEventArgs e)
        {
            var    loader = new Windows.ApplicationModel.Resources.ResourceLoader();
            string track  = loader.GetString("Track");
            string tracks = loader.GetString("Tracks");

            ConnectionManager.ManageSystemTray(true);
            Filter filter = new Filter {
                Field = "album", Operator = "is", value = GlobalVariables.CurrentAlbum.Title
            };
            Sort sort = new Sort {
                Method = "track", Order = "ascending", IgnoreArticle = true
            };

            songsInAlbum = await AudioLibrary.GetSongs(filter : filter, sort : sort);

            SongsListView.ItemsSource = songsInAlbum;

            TrackCountTextBlock.Text = songsInAlbum.Count.ToString();
            TracksTextBlock.Text     = songsInAlbum.Count > 1 ? tracks : track;

            currentAlbum = await AudioLibrary.GetAlbumDetails(GlobalVariables.CurrentAlbum.AlbumId);

            AlbumInfoGrid.DataContext = currentAlbum;
            ConnectionManager.ManageSystemTray(false);
        }
Ejemplo n.º 6
0
        private async void ReloadAll()
        {
            var loadSartTime = DateTime.Now;

            ConnectionManager.ManageSystemTray(true);
            allArtists = await AudioLibrary.GetArtists();

            var groupedAllArtists = GroupingHelper.GroupList(allArtists, (Artist a) => { return(a.Label); }, true);

            ArtistsCVS.Source = groupedAllArtists;

            allAlbums = await AudioLibrary.GetAlbums();

            var groupedAllAlbums = GroupingHelper.GroupList(allAlbums, (Album a) => { return(a.Label); }, true);

            AlbumsCVS.Source = groupedAllAlbums;

            allSongs = await AudioLibrary.GetAllSongs();

            var groupedAllSongs = GroupingHelper.GroupList(allSongs, (Song s) => { return(s.Label); }, true);

            SongsCVS.Source = groupedAllSongs;
            ConnectionManager.ManageSystemTray(false);

            GlobalVariables.CurrentTracker.SendTiming((DateTime.Now.Subtract(loadSartTime)), TimingCategories.LoadTime, "AllMusic", "AllMusic");
        }
Ejemplo n.º 7
0
    void Awake()
    {
        if (instance != null)
        {
            Destroy(gameObject);
        }
        else
        {
            instance = this;
            DontDestroyOnLoad(gameObject);
            library = GetComponent <AudioLibrary>();

            musicSources = new AudioSource[2];
            for (int i = 0; i < 2; i++)
            {
                GameObject newMusicSource = new GameObject("Music source " + (i + 1));
                musicSources[i] = newMusicSource.AddComponent <AudioSource>();
                newMusicSource.transform.parent = transform;
            }
            GameObject newSFX2DSource = new GameObject("2D SFX source");
            sfx2DSource = newSFX2DSource.AddComponent <AudioSource>();
            newSFX2DSource.transform.parent = transform;


            audioListener = FindObjectOfType <AudioListener>().transform;
            if (FindObjectOfType <CameraScript>())
            {
                playerT = FindObjectOfType <CameraScript>().transform;
            }
            masterVolume = PlayerPrefs.GetFloat("Master volume", 0);
            sfxVolume    = PlayerPrefs.GetFloat("SFX volume", 0);
            musicVolume  = PlayerPrefs.GetFloat("Music volume", 0);
            PlayerPrefs.Save();
        }
    }
        public static void Dispose()
        {
            if (mp3Channel != null)
            {
                mp3Channel.Dispose();
            }
            DisposeVST();

            if (UsedLibrary == AudioLibrary.NAudio)
            {
                //NAUDIO
                Samples.Clear();
                if (playbackDevice != null)
                {
                    playbackDevice.Stop();
                    playbackDevice.Dispose();
                    playbackDevice = null;
                }

                if (Mixer32 != null)
                {
                    Mixer32.Dispose(); Mixer32 = null;
                }
            }
            UsedLibrary = AudioLibrary.Null;
        }
Ejemplo n.º 9
0
        public static string UpdateVolume(Message message)
        {
            if (message.Volume < 0)
            {
                message.Volume = 0;
            }

            if (message.Volume > 100)
            {
                message.Volume = 100;
            }

            if (message.ProcessId != 0)
            {
                //loop through all active audio processes
                foreach (var ctl in AudioLibrary.EnumerateApplications())
                {
                    ctl.GetProcessId(out UInt32 pId);
                    //Find required audio process and adjust volume
                    if (pId == message.ProcessId)
                    {
                        AudioLibrary.SetApplicationVolume(ctl, message.Volume);
                        break;
                    }
                }
            }
            else
            {
                AudioLibrary.SetMasterVolume(message.Volume);
            }

            return(message.Volume.ToString());
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Trigger the Interactable.
 /// </summary>
 public override void onInteract()
 {
     ToggleSecurityDoors();
     AudioLibrary.PlayNormalSwitchSound();
     if (alertFlashOnInteract)
     {
         AlertFlash.inst.PlayAlertFlash();
     }
     if (_activatables.Length == 0)
     {
         return;
     }
     foreach (GameObject activatable in _activatables)
     {
         if (activatable.GetComponent <IActivatable>() != null)
         {
             activatable.GetComponent <IActivatable>().onActivate();
         }
     }
     _sprite.sprite = _pressedSprite;
     if (_reusable)
     {
         StartCoroutine(spriteTimer(0.4f));
     }
 }
        //=============================================

        public static bool OpenAudio(AudioLibrary AL, int sampleRate, int channels)
        {
            if (UsedLibrary != AudioLibrary.Null || (playbackDevice != null && playbackDevice.PlaybackState == PlaybackState.Playing))
            {
                return(false);
            }

            UsedLibrary = AL;

            if (UsedLibrary == AudioLibrary.NAudio)
            {
                //NAUDIO
                Mixer32          = new RecordableMixerStream32(sampleRate, channels);
                Mixer32.AutoStop = false;

                // try asio
                playbackDevice = new AsioOut(0);

                // if failed, try normal wave out
                if (playbackDevice == null)
                {
                    playbackDevice = new WaveOut();
                }
                if (playbackDevice == null)
                {
                    return(false);
                }
                playbackDevice.Init(Mixer32);

                //=============================================
            }
            return(true);
        }
Ejemplo n.º 12
0
        private async void SearchAndReload(string query)
        {
            ConnectionManager.ManageSystemTray(true);

            Filter artistFilter = new Filter {
                Field = "artist", Operator = "contains", value = query
            };
            Sort artistSort = new Sort {
                Method = "artist", Order = "ascending", IgnoreArticle = true
            };

            ArtistSearchListView.ItemsSource = await AudioLibrary.GetArtists(artistFilter, sort : artistSort);

            Filter albumFilter = new Filter {
                Field = "album", Operator = "contains", value = query
            };
            Sort albumSort = new Sort {
                Method = "album", Order = "ascending", IgnoreArticle = true
            };

            AlbumSearchGridView.ItemsSource = await AudioLibrary.GetAlbums(albumFilter, sort : albumSort);

            Filter songFilter = new Filter {
                Field = "title", Operator = "contains", value = query
            };
            Sort songSort = new Sort {
                Method = "title", Order = "ascending", IgnoreArticle = true
            };

            SongsSearchListView.ItemsSource = await AudioLibrary.GetSongs(songFilter, sort : songSort);

            ConnectionManager.ManageSystemTray(false);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Default Constructor
        public AttributeBoard(Game game, Texture2D background, ContentManager Content)
            : base(game)
        {
            centerX = game.GraphicsDevice.Viewport.TitleSafeArea.Center.X;
            centerY = game.GraphicsDevice.Viewport.TitleSafeArea.Center.Y + 50;

            this.Content = Content;
            Components.Add(new ImageComponent(game, background,
                                            ImageComponent.DrawMode.Stretch));

            // Get the current spritebatch
            spriteBatch = (SpriteBatch)Game.Services.GetService(
                                            typeof(SpriteBatch));

            // Get the audio library
            audio = (AudioLibrary)
                Game.Services.GetService(typeof(AudioLibrary));

            // for the mouse or touch
            cursor = new Cursor(game, spriteBatch);
            cursor.targetToLock = null;
            //Components.Add(cursor);

            UnassignedPtsBar = Content.Load<Texture2D>("Image/AttributeBoardTextures/UnassignedPtsBarNew");
            statsFont = IngamePresentation.statsFont;
            menuLarge = IngamePresentation.largeFont;
            speedTexture = Content.Load<Texture2D>("Image/AttributeBoardTextures/speed");
            hitpointTexture = Content.Load<Texture2D>("Image/AttributeBoardTextures/hit_point");
            shootrateTexture = Content.Load<Texture2D>("Image/AttributeBoardTextures/shooting_rate");
            bulletStrengthTexture = Content.Load<Texture2D>("Image/AttributeBoardTextures/strength");

            this.game = game;
        }
Ejemplo n.º 14
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (albums == null)
            {
                albums = await AudioLibrary.GetRecentlyAddedAlbums(new Limits { Start = 0, End = 12 });

                MusicLLS.ItemsSource = albums;
            }

            if (episodes == null)
            {
                episodes = await VideoLibrary.GetRecentlyAddedEpisodes(new Limits { Start = 0, End = 10 });

                TVShowsLLS.ItemsSource = episodes;
            }

            if (movies == null)
            {
                movies = await VideoLibrary.GetRecentlyAddedMovies(new Limits { Start = 0, End = 15 });

                MoviesLLS.ItemsSource = movies;
            }

            base.OnNavigatedTo(e);
        }
Ejemplo n.º 15
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;

            Console.WriteLine("--- Majora Terminal ---\n\n");
            string path = "";

            while (true)
            {
                Console.WriteLine("Please write the path to your file!");

                AudioLibrary library;
                while (true)
                {
                    path = ValidateFile();
                    try
                    {
                        library = AudioLibrary.CheckFile(path);
                        break;
                    }
                    catch (Exception e)
                    {
                        AudioLibrary.LogError(e);
                    }
                }

                if (!AudioLibrary.supported[Path.GetExtension(path)[1..]])
Ejemplo n.º 16
0
    private void Awake()
    {
        if (instance != null)
        {
            Destroy(gameObject);
        }
        else
        {
            instance = this;
            DontDestroyOnLoad(gameObject);

            musicSources = new AudioSource[2];
            for (int i = 0; i < 2; i++)
            {
                GameObject newMusicSource = new GameObject("Music source " + (i + 1));
                musicSources[i] = newMusicSource.AddComponent <AudioSource>();
                newMusicSource.transform.parent = transform;
            }

            GameObject newSfx2DSource = new GameObject("2D sfx source");
            sfx2DSource = newSfx2DSource.AddComponent <AudioSource>();
            newSfx2DSource.transform.parent = transform;

            audioListener = FindObjectOfType <AudioListener>().transform;

            library = GetComponent <AudioLibrary>();

            masterVolumePercent = PlayerPrefs.GetFloat("master vol", 1);
            sfxVolumePercent    = PlayerPrefs.GetFloat("sfx vol", 1);
            musicVolumePercent  = PlayerPrefs.GetFloat("music vol", 1);
        }
    }
Ejemplo n.º 17
0
    public void CreatePoint()
    {
        if (LevelStateManager.canCreateTetherPoint())
        {
            //Debug.Log("Create tether point");
            //CreateTimeTetherIndicator(GameManager.GetPlayer().transform.position, LevelStateManager.curState + 1);
            LevelStateManager.createTetherPoint();

            GameManager.GetPlayerScript().setPlaceAnchorAnim();

            AudioLibrary.PlayTetherPlacementSound();
            // Timeline arrow
            SetArrowTarget(LevelStateManager.curState, false, true);

            if (LevelStateManager.curState < tetherUICreateParticles.Length && tetherUICreateParticles[LevelStateManager.curState] != null)
            {
                tetherUICreateParticles[LevelStateManager.curState].Play();
            }
        }
        else
        {
            if (!GlobalAudio.ClipIsPlaying(AudioLibrary.inst.tetherError))
            {
                AudioLibrary.PlayTetherErrorSound();
            }
            Debug.Log("Can't create tether point right now");
        }
    }
Ejemplo n.º 18
0
        private async void ReloadAll()
        {
            ConnectionManager.ManageSystemTray(true);
            allArtists = await AudioLibrary.GetArtists();

            var groupedAllArtists = GroupingHelper.GroupList(allArtists, (Artist a) => a.Label, true);

            ArtistsCVS.Source = groupedAllArtists;
            (ArtistsSemanticZoom.ZoomedOutView as ListViewBase).ItemsSource = ArtistsCVS.View.CollectionGroups;

            Sort sort = new Sort {
                Method = "label", Order = "ascending", IgnoreArticle = true
            };

            allAlbums = await AudioLibrary.GetAlbums(sort : sort);

            var groupedAllAlbums = GroupingHelper.GroupList(allAlbums, (Album a) => a.Label, true);

            AlbumsCVS.Source = groupedAllAlbums;
            (AlbumsSemanticZoom.ZoomedOutView as ListViewBase).ItemsSource = AlbumsCVS.View.CollectionGroups;

            allSongs = await AudioLibrary.GetSongs(sort : sort);

            var groupedAllSongs = GroupingHelper.GroupList(allSongs, (Song s) => s.Label, true);

            SongsCVS.Source = groupedAllSongs;
            (SongsSemanticZoom.ZoomedOutView as ListViewBase).ItemsSource = SongsCVS.View.CollectionGroups;

            ConnectionManager.ManageSystemTray(false);
        }
Ejemplo n.º 19
0
 public void OnEnable()
 {
     _target           = target as AudioLibrary;
     _list             = new AudioLibraryList(_target, serializedObject, serializedObject.FindProperty("_items"));
     _propertyIsMaster = serializedObject.FindProperty("_isMaster");
     _propertyMaster   = serializedObject.FindProperty("_parent");
 }
Ejemplo n.º 20
0
        /// <summary>
        /// Default constructor
        /// </summary>
        /// <param name="game">the main game object</param>
        /// <param name="normalFont">Font to regular items</param>
        /// <param name="selectedFont">Font to selected item</param>
        public TextMenuComponent(Game game, SpriteFont normalFont,
            SpriteFont selectedFont)
            : base(game)
        {
            regularFont = normalFont;
            this.selectedFont = selectedFont;
            menuItems = new List<string>();
            rectMenuItems = new List<Rectangle>();

            // Get the current spritebatch
            spriteBatch = (SpriteBatch)
                Game.Services.GetService(typeof(SpriteBatch));

            // Get the audio library
            audio = (AudioLibrary)
                Game.Services.GetService(typeof(AudioLibrary));

            float widthScale = (float)game.Window.ClientBounds.Width / 1440;
            float heightScale = (float)game.Window.ClientBounds.Height / 900;

            textScale = widthScale * heightScale;
            if (textScale > 1) textScale = 1;

            textScale = (float)System.Math.Sqrt((double)(textScale));
        }
Ejemplo n.º 21
0
 void OnDestroy()
 {
     if (this == instance)
     {
         instance = null;
     }
 }
Ejemplo n.º 22
0
        /// <summary>
        /// Default Constructor
        public LevelObjectiveScene(Game game, Texture2D background, ContentManager Content, PlayGameScene playgamescene)
            : base(game)
        {
            this.Content = Content;
            Components.Add(new ImageComponent(game, background,
                                            ImageComponent.DrawMode.Stretch));

            // Get the current spritebatch
            spriteBatch = (SpriteBatch)Game.Services.GetService(
                                            typeof(SpriteBatch));

            // Get the audio library
            audio = (AudioLibrary)
                Game.Services.GetService(typeof(AudioLibrary));

            // for the mouse or touch
            //cursor = new Cursor(game, spriteBatch);
            //Components.Add(cursor);

            levelObjFont = IngamePresentation.facilityFont;//Content.Load<SpriteFont>("Fonts/levelObj");
            objectiveBox = Content.Load<Texture2D>("Image/Miscellaneous/levelObjectiveBox");
            achievedBox = Content.Load<Texture2D>("Image/Miscellaneous/achievedObjectiveBox");
            this.playgamescene = playgamescene;
            this.game = game;
        }
Ejemplo n.º 23
0
 public void PlayStep()
 {
     if (IsGrounded())
     {
         AudioLibrary.Play(AudioName.Footstep);
     }
 }
Ejemplo n.º 24
0
 void OnStasisCollected()
 {
     Debug.Log("Stasis ability collected");
     //GameManager.inst.canUseStasis = true;
     StasisUIPanel.inst.UpdateStasisPanelActive(true, true);
     AudioLibrary.PlayCodePickupSound();
     GameObject.Instantiate(pickupParticlesPrefab, transform.position, Quaternion.identity);
 }
Ejemplo n.º 25
0
 public void prev()
 {
     if (count > 0)
     {
         loadStep(--count);
         AudioLibrary.CompletionStepSFX();
     }
 }
Ejemplo n.º 26
0
        public AudioLibraryList(AudioLibrary library, SerializedObject obj, SerializedProperty property) : base(obj, property, true, true, true, true)
        {
            _library = library;

            base.drawHeaderCallback    += OnDrawHeader;
            base.drawElementCallback   += OnDrawElement;
            base.elementHeightCallback += OnElementHeight;
        }
Ejemplo n.º 27
0
 public void next()
 {
     if (index + 1 < steps.Length)
     {
         text.text = steps[++index];
         AudioLibrary.CompletionStepSFX();
     }
 }
Ejemplo n.º 28
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.tag == "Player")
     {
         AudioLibrary.PlayAlarmShort();
         this.gameObject.GetComponent <BoxCollider2D>().enabled = false;
     }
 }
Ejemplo n.º 29
0
    private void Awake()
    {
        if (instance != null)
        {
            Destroy(gameObject);
        }
        else
        {
            instance = this;
            DontDestroyOnLoad(gameObject);
            audioLibrary      = GetComponent <AudioLibrary>();
            musicManager      = GetComponent <MusicManager>();
            musicListInstance = new Dictionary <string, AudioSource>();

            foreach (MusicManager.Track gm in musicManager.tracks)
            {
                try
                {
                    AudioSource stp = new GameObject(gm.clip.name).AddComponent <AudioSource>();

                    /*
                     * Esses objetos stp: abreviação para Song To Play
                     * não deverão ser destruídos quando trocar de cena;
                     * Eles são as instancias de AudioSource que terão o volume alterado
                     * de acordo com as opções do usuário
                     *
                     * Para isso será utilizado o método DontDestroyOnLoad() da Unity,
                     * que faz o trabalho de manter o objeto (GameObject) "Vivo" atravéz das cenas.
                     *
                     * */
                    DontDestroyOnLoad(stp);

                    stp.clip = gm.clip;

                    stp.volume = musicVol * masterVol;

                    musicListInstance.Add(gm.trackName, stp);
                }
                catch (Exception e)
                {
                    Debug.Log("Something horrible was happened!");
                    Debug.Log(e.Message);
                }
            }

            audioListener = FindObjectOfType <AudioListener>().transform;

            if (FindObjectOfType <PlayerController>() != null)
            {
                playerTransform = FindObjectOfType <PlayerController>().transform;
            }

            masterVol = PlayerPrefs.GetFloat("MasterVolume", 1);
            sfxVol    = PlayerPrefs.GetFloat("SfxVolume", 1);
            musicVol  = PlayerPrefs.GetFloat("MusicVolume", 1);
        }
    }
Ejemplo n.º 30
0
 //Knock out any enemy that you crash into
 public static void KnockOutEnemies(BoundingSphere boundingSphere, Vector3 Position, int MaxRangeX, int MaxRangeZ, BaseEnemy[] enemies, ref int enemiesAmount, SwimmingObject[] fishes, int fishAmount, AudioLibrary audio, GameMode gameMode)
 {
     for (int i = 0; i < enemiesAmount; i++)
     {
         if (boundingSphere.Intersects(enemies[i].BoundingSphere))
         {
             PoseidonGame.audio.bodyHit.Play();
             float healthiness = HydroBot.currentEnergy / GameConstants.PlayerStartingEnergy;
             if (healthiness > 1) healthiness = 1.0f;
             Vector3 oldPosition = enemies[i].Position;
             Vector3 pushVector = enemies[i].Position - Position;
             pushVector.Normalize();
             //can't stun a submarine
             if (!(enemies[i] is Submarine))
             {
                 enemies[i].stunned = true;
                 enemies[i].stunnedStartTime = PoseidonGame.playTime.TotalSeconds;
                 if (HydroBot.sonicHipnotiseMode)
                 {
                     enemies[i].setHypnotise();
                 }
             }
             enemies[i].Position += (pushVector * GameConstants.ThorPushFactor);
             enemies[i].Position.X = MathHelper.Clamp(enemies[i].Position.X, -MaxRangeX, MaxRangeX);
             enemies[i].Position.Z = MathHelper.Clamp(enemies[i].Position.Z, -MaxRangeZ, MaxRangeZ);
             enemies[i].BoundingSphere.Center = enemies[i].Position;
             if (Collision.isBarrierVsBarrierCollision(enemies[i], enemies[i].BoundingSphere, fishes, fishAmount)
                 || Collision.isBarrierVsBarrierCollision(enemies[i], enemies[i].BoundingSphere, enemies, enemiesAmount))
             {
                 enemies[i].Position = oldPosition;
                 enemies[i].BoundingSphere.Center = oldPosition;
             }
             int healthloss = (int)(GameConstants.HermesDamage * healthiness * HydroBot.speed * HydroBot.speedUp * HydroBot.sandalPower);
             enemies[i].health -= healthloss;
             //audio.Shooting.Play();
             //if (enemies[i].health <= 0)
             //{
             //    if (enemies[i].isBigBoss == true) PlayGameScene.isBossKilled = true;
             //    for (int k = i + 1; k < enemiesAmount; k++)
             //    {
             //        enemies[k - 1] = enemies[k];
             //    }
             //    enemies[--enemiesAmount] = null;
             //    i--;
             //}
             Point point = new Point();
             String point_string = "-" + healthloss.ToString() + "HP";
             point.LoadContent(PoseidonGame.contentManager, point_string, enemies[i].Position, Color.DarkRed);
             if (gameMode == GameMode.ShipWreck)
                 ShipWreckScene.points.Add(point);
             else if (gameMode == GameMode.MainGame)
                 PlayGameScene.points.Add(point);
             else if (gameMode == GameMode.SurvivalMode)
                 SurvivalGameScene.points.Add(point);
         }
     }
 }
Ejemplo n.º 31
0
 public BulletManager(Game game)
     : base(game)
 {
     justShot = 0;
     bullets  = new List <Bullet>();
     // Get the audio library
     audio = (AudioLibrary)
             Game.Services.GetService(typeof(AudioLibrary));
 }
Ejemplo n.º 32
0
 void Start()
 {
     instance    = this;
     voiceSource = gameObject.AddComponent <AudioSource>();
     for (int i = 0; i < lastPlayed.Length; i++)
     {
         lastPlayed[i] = -1;
     }
 }
Ejemplo n.º 33
0
    //---------------------------------------------------------------------------------- -
    //  On Jump Event Reaction
    //---------------------------------------------------------------------------------- -
    private void OnJump()
    {
        //TODO: Fix bools to triggers
        m_animator.SetBool("Jumping", true);

        m_audioPlayer.PlayOneShot(AudioLibrary.Get().jump01);

        //This is for the animation system
        Invoke("DisableJumpAnim", 0.5f);
    }
Ejemplo n.º 34
0
    private void AddClipToList(AudioLibrary AudioLib, AudioClip audioClip)
    {
        //data.foldSettings.Add(false);
        //data._3DSettings.Add(false);
        //data._2DSettings.Add(false);
        AudioSample sample = new AudioSample();

        sample.Clip = audioClip;
        AudioLib.Samples.Add(sample);
    }
Ejemplo n.º 35
0
        public CreditScene(Game game, SpriteFont smallFont, SpriteFont largeFont, Texture2D background, Texture2D elements)
            : base(game)
        {
            _elements = elements;
            _spriteBatch = (SpriteBatch)Game.Services.GetService(typeof(SpriteBatch));
            _audio = (AudioLibrary)Game.Services.GetService(typeof(AudioLibrary));

            Components.Add(new ImageComponent(game, background, ImageComponent.DrawMode.Center));
            _font = largeFont;
        }
Ejemplo n.º 36
0
 public TextMenuComponent(Game game, SpriteFont normalFont, SpriteFont selectedFont)
     : base(game)
 {
     regularFont = normalFont;
     this.selectedFont = selectedFont;
     menuItems = new List<string>();
     spriteBatch = (SpriteBatch) Game.Services.GetService(typeof (SpriteBatch));
     audio = (AudioLibrary) Game.Services.GetService(typeof (AudioLibrary));
     oldKeyboardState = Keyboard.GetState();
     oldGamePadState = GamePad.GetState(PlayerIndex.One);
 }
        public StartScene(Game game, SpriteFont smallFont, SpriteFont largeFont, Texture2D background, Texture2D elements)
            : base(game)
        {
            this._elements = elements;
            Components.Add(new ImageComponent(game, background, ImageComponent.DrawMode.Center));

            string[] items = Enum.GetValues(typeof(MenuItems)).Cast<MenuItems>().Select(s => s.GetDisplayOrName()).ToArray();
            this._menu = new TextMenuComponent(game, smallFont, largeFont);
            this._menu.SetMenuItems(items);
            Components.Add(this._menu);

            this._spriteBatch = (SpriteBatch)Game.Services.GetService(typeof(SpriteBatch));
            this._audio = (AudioLibrary)Game.Services.GetService(typeof(AudioLibrary));
        }
Ejemplo n.º 38
0
        public StartScene(Game game, SpriteFont smallFont, SpriteFont largeFont, Texture2D background, Texture2D elements)
            : base(game)
        {
            this.elements = elements;
            Components.Add(new ImageComponent(game, background, ImageComponent.DrawMode.Center));

            string[] items = {"One Player", "Two Players", "Help", "Credits", "Quit"};
            menu = new TextMenuComponent(game, smallFont, largeFont);
            menu.SetMenuItems(items);
            Components.Add(menu);

            spriteBatch = (SpriteBatch) Game.Services.GetService(typeof (SpriteBatch));
            audio = (AudioLibrary) Game.Services.GetService(typeof (AudioLibrary));
        }
Ejemplo n.º 39
0
    // Use this for initialization
    void Start()
    {
        if (_instance == null) {
            _instance = this;
            audioSource = GetComponent<AudioSource>();
            audioSource.clip = backingTracks[0];
            audioSource.Play();
            effectsLibrary = GetComponent<AudioLibrary>();
        }
        else if (this != _instance)
            Destroy (this);

        DontDestroyOnLoad (this);
        initVol = audioSource.volume;
        if (PlayerPrefs.GetInt("MusicOn") == 0)
            audioSource.volume = 0;
    }
Ejemplo n.º 40
0
        /// <summary>
        /// Default Constructor
        public QuizzGameScene(Game game, Texture2D background, ContentManager Content, GraphicsDevice graphicsDevice)
            : base(game)
        {
            this.Content = Content;
            this.graphicsDevice = graphicsDevice;
            Components.Add(new ImageComponent(game, background,
                                            ImageComponent.DrawMode.Stretch));

            // Get the current spritebatch
            spriteBatch = (SpriteBatch)Game.Services.GetService(
                                            typeof(SpriteBatch));

            // Get the audio library
            audio = (AudioLibrary)
                Game.Services.GetService(typeof(AudioLibrary));

            //statsFont = Content.Load<SpriteFont>("Fonts/StatsFont");
            quizFont = Content.Load<SpriteFont>("Fonts/quiz");

            nextButtonTexture = Content.Load<Texture2D>("Image/MinigameTextures/NextButton");
            buttonTexture = Content.Load<Texture2D>("Image/MinigameTextures/quizButton");
            selectedButtonTexture = Content.Load<Texture2D>("Image/MinigameTextures/quizButtonSelected");
            introductionTexture = Content.Load<Texture2D>("Image/MinigameTextures/QuizGameIntro");

            this.game = game;

            quizzesLibrary = new QuizzesLibrary();
            questionID = random.Next(quizzesLibrary.quizzesList.Count);

            positionQs = new Vector2(graphicsDevice.Viewport.TitleSafeArea.Left + 300, graphicsDevice.Viewport.TitleSafeArea.Top + 105);
            positionA = new Vector2(graphicsDevice.Viewport.TitleSafeArea.Left + 100, graphicsDevice.Viewport.TitleSafeArea.Center.Y);
            positionB = new Vector2(graphicsDevice.Viewport.TitleSafeArea.Left + 100, graphicsDevice.Viewport.TitleSafeArea.Center.Y+100);
            positionC = new Vector2(graphicsDevice.Viewport.TitleSafeArea.Left + 100, graphicsDevice.Viewport.TitleSafeArea.Center.Y+200);
            positionD = new Vector2(graphicsDevice.Viewport.TitleSafeArea.Left + 100, graphicsDevice.Viewport.TitleSafeArea.Center.Y+300);
            positionAns = new Vector2 (graphicsDevice.Viewport.TitleSafeArea.Center.X, graphicsDevice.Viewport.TitleSafeArea.Bottom - 50);
            rectA = new Rectangle((int)positionA.X, (int)positionA.Y, 60, 60);
            rectB = new Rectangle((int)positionB.X, (int)positionB.Y, 60, 60);
            rectC = new Rectangle((int)positionC.X, (int)positionC.Y, 60, 60);
            rectD = new Rectangle((int)positionD.X, (int)positionD.Y, 60, 60);
            nextButtonRect = new Rectangle(graphicsDevice.Viewport.TitleSafeArea.Right - 220, graphicsDevice.Viewport.TitleSafeArea.Bottom - 100, 200, 80);

            cursor = new Cursor(game, spriteBatch);
            cursor.targetToLock = null;
            //Components.Add(cursor);
        }
Ejemplo n.º 41
0
        public static void Dispose()
        {
            if (mp3Channel != null) mp3Channel.Dispose();
            DisposeVST();

            if (UsedLibrary == AudioLibrary.NAudio)
            {
                //NAUDIO
                Samples.Clear();
                if (playbackDevice != null)
                {
                    playbackDevice.Stop();
                    playbackDevice.Dispose();
                    playbackDevice = null;
                }

                if (Mixer32 != null) { Mixer32.Dispose(); Mixer32 = null; }
            }
            UsedLibrary = AudioLibrary.Null;
        }
Ejemplo n.º 42
0
        public CreditScene(Game game, Texture2D textureBack, Texture2D[] creditForgroundTextures, Texture2D textureNextButton, SpriteBatch spriteBatch, GraphicsDevice graphicsDevice)
            : base(game)
        {
            this.spriteBatch = spriteBatch;
            backgroundTexture = textureBack;
            this.textureNextButton = textureNextButton;
            this.graphicsDevice = graphicsDevice;
            // Get the audio library
            audio = (AudioLibrary)
                Game.Services.GetService(typeof(AudioLibrary));
            cursor = new Cursor(game, spriteBatch);
            this.creditForgroundTextures = creditForgroundTextures;

            int creditSceneWidth = (int)(graphicsDevice.Viewport.TitleSafeArea.Width * 0.65);
            int creditSceneHeight = (int)(graphicsDevice.Viewport.TitleSafeArea.Height * 0.75);
            textureFrontRectangle = new Rectangle(graphicsDevice.Viewport.TitleSafeArea.Center.X - creditSceneWidth/2, graphicsDevice.Viewport.TitleSafeArea.Center.Y - creditSceneHeight/2, creditSceneWidth, creditSceneHeight);

            int nextRectangleWidth = (int)(graphicsDevice.Viewport.TitleSafeArea.Width * 0.05);
            int nextRectangleHeight = (int)(graphicsDevice.Viewport.TitleSafeArea.Height * 0.0875);
            nextRectangle = new Rectangle(textureFrontRectangle.Center.X - nextRectangleWidth/2, textureFrontRectangle.Bottom - nextRectangleHeight, nextRectangleWidth, nextRectangleHeight);
            nextPressed = false;
        }
Ejemplo n.º 43
0
        public static void Dispose()
        {
            if (mp3Channel != null) mp3Channel.Dispose();
            if (GeneralSFZ != null) GeneralSFZ.Dispose();
            DisposeVST();

            if (UsedLibrary == AudioLibrary.NAudio)
            {
                //NAUDIO
                Samples.Clear();
                if (playbackDevice != null)
                {
                    playbackDevice.Stop();
                    playbackDevice.Dispose();
                    playbackDevice = null;
                }
                if (Mixer32 != null) { Mixer32.Dispose(); Mixer32 = null; }

                //=============================================
            }
            UsedLibrary = AudioLibrary.Null;
            //if (midiOut != null) midiOut.Close();
        }
Ejemplo n.º 44
0
		//=============================================

		public static bool OpenAudio(AudioLibrary AL, int sampleRate, int channels)
		{
			if (UsedLibrary != AudioLibrary.Null ||(playbackDevice != null && playbackDevice.PlaybackState == PlaybackState.Playing)) return false;

			UsedLibrary = AL;

			if (UsedLibrary == AudioLibrary.NAudio)
			{
				//NAUDIO
				Mixer32 = new RecordableMixerStream32(sampleRate, channels);
				Mixer32.AutoStop = false;
				
				// try asio
				playbackDevice = new AsioOut(0);
				
				// if failed, try normal wave out
				if (playbackDevice == null) playbackDevice = new WaveOut();
				if (playbackDevice == null) return false;
				playbackDevice.Init(Mixer32);

				//=============================================
			}
			return true;
		}
Ejemplo n.º 45
0
        /// <summary>
        /// Default Constructor
        public TipScene(Game game, Texture2D background, ContentManager Content)
            : base(game)
        {
            this.Content = Content;
            Components.Add(new ImageComponent(game, background,
                                            ImageComponent.DrawMode.Stretch));

            // Get the current spritebatch
            spriteBatch = (SpriteBatch)Game.Services.GetService(
                                            typeof(SpriteBatch));

            // Get the audio library
            audio = (AudioLibrary)
                Game.Services.GetService(typeof(AudioLibrary));

            // for the mouse or touch
            //cursor = new Cursor(game, spriteBatch);
            //Components.Add(cursor);

            tipFont = IngamePresentation.tipFont;//Content.Load<SpriteFont>("Fonts/tip");
            tipBox = Content.Load<Texture2D>("Image/Miscellaneous/tipBox");

            this.game = game;
        }
Ejemplo n.º 46
0
 void Start()
 {
     instance = this;
     voiceSource = gameObject.AddComponent<AudioSource>();
     for(int i = 0; i<lastPlayed.Length; i++) lastPlayed[i] = -1;
 }
Ejemplo n.º 47
0
 void OnDestroy()
 {
     if(this == instance) instance = null;
 }
Ejemplo n.º 48
0
        public void Load()
        {
            statsFont = IngamePresentation.statsFont;
            menuSmall = IngamePresentation.menuSmall;
            fishTalkFont = IngamePresentation.fishTalkFont;

            // Get the audio library
            audio = (AudioLibrary)
                Game.Services.GetService(typeof(AudioLibrary));

            terrain = new Terrain(Content);

            skillTextures = IngamePresentation.skillTextures;
            bulletTypeTextures = IngamePresentation.bulletTypeTextures;

            powerpacks = new List<Powerpack>();
            resources = new List<Resource>();

            powerpacks = new List<Powerpack>();
            resources = new List<Resource>();

            hydroBot.Load(Content);

            //prevTank.Load(Content);
            roundTimer = roundTime;

            PresentationParameters pp = graphics.GraphicsDevice.PresentationParameters;
            renderTarget = new RenderTarget2D(graphics.GraphicsDevice, pp.BackBufferWidth, pp.BackBufferHeight,
                false, graphics.GraphicsDevice.DisplayMode.Format, DepthFormat.Depth24Stencil8);
            afterEffectsAppliedRenderTarget = new RenderTarget2D(graphics.GraphicsDevice, pp.BackBufferWidth, pp.BackBufferHeight,
                false, graphics.GraphicsDevice.DisplayMode.Format, DepthFormat.Depth24Stencil8);

            //for edge detection effect
            normalDepthRenderTargetLow = new RenderTarget2D(graphics.GraphicsDevice,
                                                         pp.BackBufferWidth, pp.BackBufferHeight, false,
                                                         pp.BackBufferFormat, pp.DepthStencilFormat);
            normalDepthRenderTargetHigh = new RenderTarget2D(graphics.GraphicsDevice,
                                             pp.BackBufferWidth, pp.BackBufferHeight, false,
                                             pp.BackBufferFormat, pp.DepthStencilFormat);
            edgeDetectionRenderTarget = new RenderTarget2D(graphics.GraphicsDevice,
                                                         pp.BackBufferWidth, pp.BackBufferHeight, false,
                                                         pp.BackBufferFormat, pp.DepthStencilFormat);

            graphicEffect = new GraphicEffect(this, this.spriteBatch, fishTalkFont);
            // Construct our particle system components.
            particleManager = new ParticleManagement(this.game, GraphicDevice);

            // Load lower left pannel button
            factoryPanelTexture = IngamePresentation.factoryPanelTexture;
            // Load Font for displaying extra information on factory panel
            factoryPanelFont = IngamePresentation.factoryPanelFont;

            // Load textures for partid animation for factories
            biofactoryAnimationTextures = IngamePresentation.biofactoryAnimationTextures;
            nuclearFactoryAnimationTextures = IngamePresentation.nuclearFactoryAnimationTextures;

            // Load factory and research lab models
            plasticFactoryModelStates = new List<Model>();
            biodegradableFactoryModelStates = new List<Model>();
            radioactiveFactoryModelStates = new List<Model>();
            researchBuildingModelStates = new List<Model>();
            int totalStates = 4;
            for (int i = 0; i < totalStates; i++)
            {
                plasticFactoryModelStates.Add(Content.Load<Model>("Models/FactoryModels/PlasticFactory_stage" + i));
                biodegradableFactoryModelStates.Add(Content.Load<Model>("Models/FactoryModels/BiodegradableFactory_stage" + i));
                radioactiveFactoryModelStates.Add(Content.Load<Model>("Models/FactoryModels/NuclearFactory_stage" + i));
                researchBuildingModelStates.Add(Content.Load<Model>("Models/FactoryModels/ResearchFacility_stage" + i));
            }
            radioactiveFactoryModel = radioactiveFactoryModelStates[radioactiveFactoryModelStates.Count - 1];
            researchBuildingModel = researchBuildingModelStates[researchBuildingModelStates.Count - 1];
            biodegradableFactoryModel = biodegradableFactoryModelStates[biodegradableFactoryModelStates.Count - 1];
            plasticFactoryModel = plasticFactoryModelStates[plasticFactoryModelStates.Count - 1];

            // Factory level textures
            plasticFactoryLevelTextures = IngamePresentation.plasticFactoryLevelTextures;
            biodegradableFactoryLevelTextures = IngamePresentation.biodegradableFactoryLevelTextures;

            // Load Trash
            biodegradableTrash = Content.Load<Model>("Models/TrashModels/biodegradableTrashVer4");
            plasticTrash = Content.Load<Model>("Models/TrashModels/plasticTrashVer3");
            radioactiveTrash = Content.Load<Model>("Models/TrashModels/radioactiveTrash");

            //Load Powerpacks
            powerpackModels = new Model[5];
            powerpackModels[1] = Content.Load<Model>("Models/PowerpackResource/speedPowerPack");
            powerpackModels[2] = Content.Load<Model>("Models/PowerpackResource/strengthPowerPack");
            powerpackModels[3] = Content.Load<Model>("Models/PowerpackResource/shootratePowerPack");
            powerpackModels[4] = Content.Load<Model>("Models/PowerpackResource/healthPowerPack");

            //Load Resource
            resourceModel = Content.Load<Model>("Models/PowerpackResource/resource");

            //Load Strange Rock
            strangeRockModels = new Model[2];
            strangeRockModels[0] = Content.Load<Model>("Models/Miscellaneous/strangeRock1Ver2");
            strangeRockModels[1] = Content.Load<Model>("Models/Miscellaneous/strangeRock2Ver2");

            //golden key
            //goldenKey = Content.Load<Model>("Models/Miscellaneous/Goldenkey");

            //Initialize the game field
            InitializeGameField(Content);
        }
Ejemplo n.º 49
0
        /// <summary>
        /// Default Constructor
        public TypingGameScene(Game game, SpriteFont font, Texture2D boxBackground, Texture2D theme, ContentManager Content)
            : base(game)
        {
            this.game = game;
            content = Content;
            //timeBetweenUpdates = (float)game.TargetElapsedTime.TotalSeconds;
            timeInterval = 6f;
            elapsedSeconds = TimeSpan.FromSeconds(0);
            whichParagraph = random.Next(paragraphLib.paragraphLib.Count);

            displayBox = new Textbox(topLeftX + 10, height - 300, width - 20, 260, paragraphLib.paragraphLib[whichParagraph].content);
            typingBox = new WritingBox(topLeftX + 10, height - 80, width - 20, 20);

            isMatching = true;
            this.boxBackground = boxBackground;
            Components.Add(new ImageComponent(game, theme,
                            ImageComponent.DrawMode.Stretch));
            this.font = font;
            // Get the current spritebatch
            spriteBatch = (SpriteBatch)Game.Services.GetService(
                                            typeof(SpriteBatch));
            // Get the audio library
            audio = PoseidonGame.audio;
            Load();
        }
Ejemplo n.º 50
0
 private void RemoveSample(AudioLibrary AudioLib, int removeAt)
 {
     //data.foldSettings.RemoveAt(removeAt);
     //data._3DSettings.RemoveAt(removeAt);
     //data._2DSettings.RemoveAt(removeAt);
     AudioLib.Samples.RemoveAt(removeAt);
     RemoveSavedFoldout("2D", removeAt);
     RemoveSavedFoldout("3D", removeAt);
     RemoveSavedFoldout("base", removeAt);
 }
Ejemplo n.º 51
0
 private void AddClipToList(AudioLibrary AudioLib, AudioClip audioClip)
 {
     //data.foldSettings.Add(false);
     //data._3DSettings.Add(false);
     //data._2DSettings.Add(false);
     AudioSample sample = new AudioSample();
     sample.Clip = audioClip;
     AudioLib.Samples.Add(sample);
 }
Ejemplo n.º 52
0
        public StartScene(Game game, SpriteFont smallFont, SpriteFont largeFont,
            Texture2D background, Texture2D elements, Texture2D teamLogo, GraphicsDevice graphicDevice)
            : base(game)
        {
            this.elements = elements;
            this.teamLogo = teamLogo;
            this.game = game;
            this.graphicsDevice = graphicDevice;

            widthScale = (float)game.Window.ClientBounds.Width / 1440;
            heightScale = (float)game.Window.ClientBounds.Height / 900;

            //textScale = widthScale * heightScale;
            //if (textScale > 1) textScale = 1;

            GameConstants.generalTextScaleFactor = (float)Math.Sqrt((double)widthScale * (double)heightScale);

            if (GameConstants.generalTextScaleFactor > 1)
                GameConstants.generalTextScaleFactor = 1;

            titleLine1SrcRect = new Rectangle(0, 0, 588, 126);//Hydrobot (0,0, 588, 126)
            titleLine2SrcRect = new Rectangle(90, 169, 620, 126); //Adventure (90, 169, 620, 126)

            Components.Add(new ImageComponent(game, background,
                                            ImageComponent.DrawMode.Stretch));

            // Create the Menu
            if (File.Exists("SurvivalMode"))
            {
                string[] items = { "New Game", "New Game Plus", "Load Saved Level", "Guardian Mode", "Config", "Help", "Credits", "Quit" };
                menuItems = items;
            }
            else
            {
                string[] items = { "New Game", "Load Saved Level", "Config", "Help", "Credits", "Quit" };
                menuItems = items;
            }

            menu = new TextMenuComponent(game, smallFont, largeFont);

            //starting values
            resetMenuStartPosition();

            menu.Position = new Vector2((game.Window.ClientBounds.Width / 2) , titleLine2DestRect.Bottom);

            menu.SetMenuItems(menuItems);
            Components.Add(menu);

            // Get the current spritebatch
            spriteBatch = (SpriteBatch)Game.Services.GetService(
                                            typeof(SpriteBatch));

            // Get the audio library
            audio = (AudioLibrary)
                Game.Services.GetService(typeof(AudioLibrary));

            cursor = new Cursor(game, spriteBatch);
        }
Ejemplo n.º 53
0
        //private static MidiOut midiOut = null;
        //=============================================
        public static bool OpenAudio(AudioLibrary AL,AudioEffectChain General)
        {
            if (UsedLibrary != AudioLibrary.Null ||(playbackDevice != null && playbackDevice.PlaybackState == PlaybackState.Playing)) return false;

            UsedLibrary = AL;

            if (UsedLibrary == AudioLibrary.NAudio)
            {
                //if (midiOut != null) midiOut.Close();

                //NAUDIO
                Mixer32 = new RecordableMixerStream32();
                Mixer32.Chain = General;
                Mixer32.AutoStop = false;
                playbackDevice = new AsioOut(0);//new WaveOut();//
                if (playbackDevice == null) playbackDevice = new WaveOut();
                if (playbackDevice == null) return false;
                playbackDevice.Init(Mixer32);

                //=============================================
            }
            return true;
        }
Ejemplo n.º 54
0
        ActionScene(Game game, Texture2D theTexture, Texture2D backgroundTexture, SpriteFont font)
            : base(game)
        {
            _audio = (AudioLibrary)Game.Services.GetService(typeof(AudioLibrary));
            _background = new ImageComponent(game, backgroundTexture, ImageComponent.DrawMode.Stretch);
            Components.Add(_background);

            _actionTexture = theTexture;

            _spriteBatch = (SpriteBatch) Game.Services.GetService(typeof (SpriteBatch));
            _meteors = new MeteorsManager(Game, ref _actionTexture);
            Components.Add(_meteors);

            _scoreFont = font;

            _scorePlayer1 = new Score(game, font, _player1FontColor) {Position = new Vector2(10, 10)};
            Components.Add(_scorePlayer1);

            _rumblePad = new SimpleRumblePad(game);
            Components.Add(_rumblePad);

            _powerSource = new PowerSource(game, ref _actionTexture);
            _powerSource.Initialize();
            Components.Add(_powerSource);

            _wrench = new Wrench(game, game.Content.Load<Texture2D>("wrench"));
            _wrench.Initialize();
            Components.Add(_wrench);

            #if DEBUG
            _positionDebugText=new TextComponent(game,_scoreFont,new Vector2(),Color.Red);
            Components.Add(_positionDebugText);
            #endif
        }
        ActionScene(
            Game game, Texture2D theTexture, Texture2D backgroundTexture, SpriteFont font, Vector2 gameoverPosition)
            : base(game)
        {
            this._audio = (AudioLibrary)Game.Services.GetService(typeof(AudioLibrary));
            this._background = new ImageComponent(game, backgroundTexture, ImageComponent.DrawMode.Stretch);
            Components.Add(this._background);
            this._actionTexture = theTexture;
            this._spriteBatch = (SpriteBatch)Game.Services.GetService(typeof(SpriteBatch));
            this._meteors = new MeteorsManager(Game, ref this._actionTexture);
            Components.Add(this._meteors);
            this._scoreFont = font;
            this._gameoverPosition = gameoverPosition;
            this._scorePlayer1 = new Score(game, font, Color.Blue) { Position = new Vector2(10, 10) };
            Components.Add(this._scorePlayer1);

            this._rumblePad = new SimpleRumblePad(game);
            Components.Add(this._rumblePad);
            this._powerSource = new PowerSource(game, ref this._actionTexture);
            Components.Add(this._powerSource);
            #if DEBUG
            this._positionDebugText = new TextComponent(game, this._scoreFont, new Vector2(), Color.Red);
            Components.Add(this._positionDebugText);
            #endif
        }
Ejemplo n.º 56
0
        public ConfigScene(Game game, SpriteFont smallFont, SpriteFont largeFont, SpriteFont numberFont,
            Texture2D background, Texture2D configTitle, Texture2D unselectedCheckbox, Texture2D selectedCheckBox, Texture2D slidebar, Texture2D dragbutton, Texture2D okButton,  GraphicsDevice graphicDevice)
            : base(game)
        {
            this.game = game;
            this.graphicsDevice = graphicDevice;
            regularFont = smallFont;
            selectedFont = largeFont;
            //widthScale = (float)game.Window.ClientBounds.Width / 1280;
            //heightScale = (float)game.Window.ClientBounds.Height / 800;
            textScale = GameConstants.generalTextScaleFactor;//(float)Math.Sqrt((double)(widthScale * heightScale));

            uncheckedBox = unselectedCheckbox;
            checkedBox = selectedCheckBox;
            this.okButton = okButton;
            this.slideBar = slidebar;
            this.dragButton = dragbutton;
            this.numberFont = numberFont;

            Components.Add(new ImageComponent(game, background,
                                            ImageComponent.DrawMode.Stretch));

            this.configTitle = configTitle;
            int titleWidth = (int)(330 * widthScale);
            int titleHeight = (int)(80 * heightScale);
            titleRect = new Rectangle(game.Window.ClientBounds.Center.X - titleWidth / 2, game.Window.ClientBounds.Top + titleHeight/3, titleWidth, titleHeight);

            string[] items = { "Music Volume", "Sound Volume", "Live Tutorial", "Special Effect", "Particle Level", "Fish School Size", "Difficulty" };
            menuItems = items;
            itemRectList = new List<Rectangle>(menuItems.Length);
            iconRectList = new List<Rectangle>(menuItems.Length);

            int x, y, width, height, maxItemWidth;
            maxItemWidth = findMaxWidth();
            x = game.Window.ClientBounds.Center.X - (int)( maxItemWidth * 0.7);
            y = titleRect.Bottom+titleHeight/4;
            height = (int)((regularFont.MeasureString(menuItems[0]).Y) * textScale);
            foreach (string menu in menuItems)
            {
                width = (int)(regularFont.MeasureString(menu).X * textScale);
                Rectangle itemRectangle = new Rectangle(x, y, width, height);
                itemRectList.Add(itemRectangle);

                y += (int)(regularFont.LineSpacing*1.2*textScale);
            }

            int iconPositionX = x + maxItemWidth + (int)(10 * widthScale);
            int barheight = (int)(20*heightScale), barwidth = (int)(200*widthScale);
            int checkBoxheight = (int)(30*heightScale) , checkboxWidth = (int)(30*widthScale);

            musicVolumeRect = new Rectangle(iconPositionX, itemRectList[0].Center.Y - barheight / 2, barwidth, barheight);
            iconRectList.Add(musicVolumeRect);
            soundVolumeRect = new Rectangle(iconPositionX, itemRectList[1].Center.Y - barheight / 2, barwidth, barheight);
            iconRectList.Add(soundVolumeRect);
            showLiveTipRect = new Rectangle(iconPositionX+ barwidth/2, itemRectList[2].Center.Y - checkBoxheight/2, checkboxWidth, checkBoxheight);
            iconRectList.Add(showLiveTipRect);
            specialEffectRect = new Rectangle(iconPositionX + barwidth/2, itemRectList[3].Center.Y - checkBoxheight / 2, checkboxWidth, checkBoxheight);
            iconRectList.Add(specialEffectRect);
            numParticleRect = new Rectangle(iconPositionX, itemRectList[4].Center.Y - barheight / 2, barwidth, barheight);
            iconRectList.Add(numParticleRect);
            schoolFishRect = new Rectangle(iconPositionX, itemRectList[5].Center.Y - barheight / 2, barwidth, barheight);
            iconRectList.Add(schoolFishRect);
            easyRect = new Rectangle(iconPositionX, itemRectList[6].Center.Y - checkBoxheight / 2, checkboxWidth, checkBoxheight);
            iconRectList.Add(easyRect);
            mediumRect = new Rectangle(iconPositionX + checkboxWidth * 3, itemRectList[6].Center.Y - checkBoxheight / 2, checkboxWidth, checkBoxheight);
            iconRectList.Add(mediumRect);
            hardRect = new Rectangle(iconPositionX + checkboxWidth * 6, itemRectList[6].Center.Y - checkBoxheight / 2, checkboxWidth, checkBoxheight);
            iconRectList.Add(hardRect);

            width = titleWidth/2;
            height = (int)(titleHeight*0.75);
            okBox = new Rectangle(game.Window.ClientBounds.Center.X - width / 2, game.Window.ClientBounds.Bottom - (int)(height * 1.5), width, height);

            // Get the current spritebatch
            spriteBatch = (SpriteBatch)Game.Services.GetService(
                                            typeof(SpriteBatch));

            // Get the audio library
            audio = (AudioLibrary)
                Game.Services.GetService(typeof(AudioLibrary));

            cursor = new Cursor(game, spriteBatch);

            selectedIndex = -1;
        }