コード例 #1
0
        public void Initialize()
        {
            Game.InitializeAssetDatabase();

            defaultEngine = new AudioEngine();

            using (var monoStream = AssetManager.FileProvider.OpenStream("EffectBip", VirtualFileMode.Open, VirtualFileAccess.Read))
            {
                monoSoundEffect = SoundEffect.Load(defaultEngine, monoStream);
            }
            using (var stereoStream = AssetManager.FileProvider.OpenStream("EffectStereo", VirtualFileMode.Open, VirtualFileAccess.Read))
            {
                stereoSoundEffect = SoundEffect.Load(defaultEngine, stereoStream);
            }
            using (var contStream = AssetManager.FileProvider.OpenStream("EffectToneA", VirtualFileMode.Open, VirtualFileAccess.Read))
            {
                continousMonoSoundEffect = SoundEffect.Load(defaultEngine, contStream);
            }
            using (var contStream = AssetManager.FileProvider.OpenStream("EffectToneAE", VirtualFileMode.Open, VirtualFileAccess.Read))
            {
                continousStereoSoundEffect = SoundEffect.Load(defaultEngine, contStream);
            }
            using (var monoStream = AssetManager.FileProvider.OpenStream("Effect44100Hz", VirtualFileMode.Open, VirtualFileAccess.Read))
            {
                laugherMono = SoundEffect.Load(defaultEngine, monoStream);
            }

            monoInstance = monoSoundEffect.CreateInstance();
            stereoInstance = stereoSoundEffect.CreateInstance();
        }
コード例 #2
0
        public void Init()
        {
            SparkleSparkEffect = mod.GetSound("Sounds/Custom/SparkleSpark");

            SparkleSparkInstance = SparkleSparkEffect?.CreateInstance();

            SparkleSparkInstance.IsLooped = true;
        }
コード例 #3
0
ファイル: CrateScript.cs プロジェクト: Beefr/xenko-wd
        public override void Start()
        {
            base.Start();

            triggeredEvent = (Trigger != null) ? new EventReceiver <bool>(Trigger.TriggerEvent) : null;

            sfxInstance = SoundEffect?.CreateInstance();
            sfxInstance?.Stop();
        }
コード例 #4
0
        public void Play(bool loop = false)
        {
            if (stopFlag == true)
            {
                return;
            }
            var instance = Audio?.CreateInstance();

            instance.IsLooped = loop;
            instances.Add(instance);
        }
コード例 #5
0
        public static void loadSoundEffect(Sounds soundKey)
        {
            SoundEffect newSound = null;

            try
            {
                newSound = Game1.INSTANCE.Content.Load <SoundEffect>(soundNames[soundKey]);
            }
            catch
            {
                Console.WriteLine(soundKey + " Not Found");
            }
            allSoundsList.Add(soundKey, newSound?.CreateInstance());
            allOriginalSounds.Add(soundKey, newSound);
        }
コード例 #6
0
 /// <summary>
 /// Initializes the sounds the Stand would use.
 /// Sounds are checked for in the JoJoStands Sounds directory.
 /// This method checks in Sounds/BattleCries/ for the sound.
 /// </summary>
 public void InitializeSounds()
 {
     if (JoJoStands.SoundsLoaded)
     {
         if (beginningSoundInstance == null)
         {
             SoundEffect sound = JoJoStands.JoJoStandsSounds.GetSound("Sounds/BattleCries/" + punchSoundName + "_Beginning");
             if (sound != null)
             {
                 beginningSoundInstance        = sound.CreateInstance();
                 beginningSoundInstance.Volume = MyPlayer.soundVolume;
             }
         }
         if (punchingSoundInstance == null)
         {
             SoundEffect sound = JoJoStands.JoJoStandsSounds.GetSound("Sounds/BattleCries/" + punchSoundName);
             punchingSoundInstance        = sound.CreateInstance();
             punchingSoundInstance.Volume = MyPlayer.soundVolume;
         }
     }
 }
コード例 #7
0
ファイル: Game1.cs プロジェクト: zws3mb/retribution
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            Content.RootDirectory = "Content";
            InfoCard.texture      = Content.Load <Texture2D>("blank");
            transitionScreen      = Content.Load <Texture2D>("blank");
            transitionText        = Content.Load <SpriteFont>("Times New Roman");
            info.txt = Content.Load <SpriteFont>("Times New Roman");
            mBar.txt = Content.Load <SpriteFont>("Times New Roman");
            //loadMan.loadContent(this.Content);
            loadMan.load(this.Content, ModelManager.player);
            loadMan.load(this.Content, ModelManager.artificial);
            gui.LoadContent(this.Content);
            healthChecker.clink = Content.Load <SoundEffect>("coins.wav");
            mBar.horn           = Content.Load <SoundEffect>("horn.wav");
            player = Content.Load <SoundEffect>("back.wav");
            SoundEffectInstance instance = player.CreateInstance();

            instance.IsLooped = true;
            instance.Play();
            // TODO: use this.Content to load your game content here
        }
コード例 #8
0
        public void getaudio()
        {
            Deployment.Current.Dispatcher.BeginInvoke(() => { textBlock1.Text += "Entering thread"; });
            newstream.IncomingRTPPacketBuffer.InitialPacketQueueMinimumSize = 4;
            newstream.IncomingRTPPacketBuffer.PacketSizeShiftMax            = 10;
            int nMsTook = 0;

            byte[] data = newstream.WaitNextPacketSample(true, 10000, out nMsTook);
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                textBlock1.Text += nMsTook;
                foreach (byte b in data)
                {
                    textBlock1.Text += (char)b;
                }
                SoundEffect test       = new SoundEffect(data, Microphone.Default.SampleRate, Microsoft.Xna.Framework.Audio.AudioChannels.Mono);
                SoundEffectInstance sm = test.CreateInstance();
                sm.Play();
                textBlock1.Text += "Exiting";
            });
        }
コード例 #9
0
        //*************************************************************************
        public static void PlaySound(string soundFileName)
        {
            SoundEffect retVal = GetSound(soundFileName);

            if ((curSoundEffect != null) && (curSoundEffect.IsDisposed))
            {
                curSoundEffect.CreateInstance();
            }
            if (retVal != null)
            {
                if (true) //soundFileName == "Content/Embrace The Martian" || soundFileName == "Content/The Arrival")
                {
                    retVal.Play(.5f, 0f, 0f);
                }
                else
                {
                    retVal.Play(.7f, 0f, 0f);
                }
            }
            curSoundEffect = retVal;
        }
コード例 #10
0
ファイル: Game1.cs プロジェクト: StarGate01/Creatures_Legacy
        //Loads all the textures, fonts and sounds
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            //Load font
            normalFont = Content.Load <SpriteFont>("font\\normal_font");

            //Load and play music
            music                  = Content.Load <SoundEffect>("sound\\clean_soul");
            musicInstance          = music.CreateInstance();
            musicInstance.IsLooped = true;
            if (currentSettings.PlayMusic)
            {
                musicInstance.Play();
            }

            //Load textures
            Managers.CreatureManager.LoadContent(this.Content, GraphicsDevice);
            Managers.FoodManager.LoadContent(this.Content);
            Managers.PoisonManager.LoadContent(this.Content);
        }
コード例 #11
0
        public AmbiencePlayer(Ambience amb)
        {
            if (amb.Loop)
            {
                byte[] data   = new XAFile(FSO.Content.Content.Get().GetPath(amb.Path)).DecompressedData;
                var    stream = new MemoryStream(data);
                sfx = SoundEffect.FromStream(stream);
                stream.Close();

                inst          = sfx.CreateInstance();
                inst.IsLooped = true;
                inst.Play();
                fscMode = false;
            }
            else
            {
                fsc = HITVM.Get().PlayFSC(FSO.Content.Content.Get().GetPath(amb.Path));
                fsc.SetVolume(0.33f); //may need tweaking
                fscMode = true;
            }
        }
コード例 #12
0
        protected override void LoadContent()
        {
            spritebatch    = new SpriteBatch(GraphicsDevice);
            spriteFont     = content.Load <SpriteFont>(@"Fonts/Menu/MenuFont");
            menuComponents = new MenuItemComponents(spriteFont, menuItems);
            soundEffect    = content.Load <SoundEffect>(@"Music/DarkusRisingIntro");
            //Position of the Menu Items
            Vector2 menuPosition = new Vector2(
                (Game.Window.ClientBounds.Width) - 582,
                (Game.Window.ClientBounds.Height) - 512);

            menuComponents.SetPosition(menuPosition);
            background = new Background(content.Load <Texture2D>(@"Backgrounds/bkg_title")); //TODO: Change Background

            soundEffectInstance          = soundEffect.CreateInstance();
            soundEffectInstance.IsLooped = true;
            soundEffectInstance.Volume   = 0.0005f;
            soundEffectInstance.Pitch    = 0.5f;
            soundEffectInstance.Play();
            base.LoadContent();
        }
コード例 #13
0
        protected override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            Ship       = Content.Load <Texture2D>("blueships1");
            Background = Content.Load <Texture2D>("background");
            Shot       = Content.Load <Texture2D>("shot");

            Font = Content.Load <SpriteFont>("defaultFont");

            shootingSound          = Content.Load <SoundEffect>("laser-cannon-chopped");
            soundFxInstance        = shootingSound.CreateInstance();
            soundFxInstance.Volume = .3f;

            mainTheme          = Content.Load <Song>("battleThemeA");
            MediaPlayer.Volume = .2f;
            MediaPlayer.Play(mainTheme);

            ShotOffset  = new Vector2(Ship.Width / 2, Ship.Height / 2);
            ShotOffset += new Vector2(60, -24f);
        }
コード例 #14
0
        public void LoadAllAudio(ContentManager content)
        {
            soundEffect.Add(content.Load <SoundEffect>("Audio\\Attack Hit Sound"));
            soundEffect.Add(content.Load <SoundEffect>("Audio\\Discovery Jingle"));
            soundEffect.Add(content.Load <SoundEffect>("Audio\\Dying"));
            soundEffect.Add(content.Load <SoundEffect>("Audio\\Item Jingle"));
            soundEffect.Add(content.Load <SoundEffect>("Audio\\Pick Up Bow"));
            soundEffect.Add(content.Load <SoundEffect>("Audio\\Pick Up Item"));
            soundEffect.Add(content.Load <SoundEffect>("Audio\\Pick Up Rupee"));
            soundEffect.Add(content.Load <SoundEffect>("Audio\\Secret Jingle"));
            soundEffect.Add(content.Load <SoundEffect>("Audio\\Text Drawing"));
            soundEffect.Add(content.Load <SoundEffect>("Audio\\Triforce Pickup"));
            soundEffect.Add(content.Load <SoundEffect>("Audio\\Unlock Door"));
            soundEffect.Add(content.Load <SoundEffect>("Audio\\Wallmaster Sound"));
            soundEffect.Add(content.Load <SoundEffect>("Audio\\Bomb"));
            soundEffect.Add(content.Load <SoundEffect>("Audio\\Bow"));

            titleBGM             = content.Load <SoundEffect>("Audio\\Title BGM");
            dungeonBGM           = content.Load <SoundEffect>("Audio\\Underworld BGM");
            SEInstanceDungeonBGM = dungeonBGM.CreateInstance();
        }
コード例 #15
0
        public Mine(Texture2D spriteTexture, Vector2 position)
            : base(spriteTexture, position, 0.2f)
        {
            // set sourcerectangle
            SourceRectangle = new Rectangle(0, 0, 16, 16);

            Frames.Add(new Rectangle(0, 0, 16, 16));
            Frames.Add(new Rectangle(16, 0, 16, 16));


            Delay = 500;
            Loop  = true;

            Origin = new Vector2(16, 16);

            explosionSoundEffect                = AudioHandler.Instance.LoadSoundEffect(AudioHandler.TypeOfSound.Explosion);
            explosionSoundEffectInstance        = explosionSoundEffect.CreateInstance();
            explosionSoundEffectInstance.Volume = 0.4f;

            CollisionHandler.Instance.register(this);
        }
コード例 #16
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(graphics.GraphicsDevice);

            // load sprite font
            font1        = Content.Load <SpriteFont>("fonts\\Arial20");
            gameoverfont = Content.Load <SpriteFont>("fonts\\Arial100");

            ballBounceSound             = Content.Load <SoundEffect>("sounds\\ballbounce");
            themeSound                  = Content.Load <SoundEffect>("sounds\\soundtheme");
            crowdSound                  = Content.Load <SoundEffect>("sounds\\crowd");
            soundThemeInstance          = themeSound.CreateInstance();
            soundThemeInstance.IsLooped = true;
            soundThemeInstance.Volume   = GameConstants.MUSIC_VOL;

            background       = Content.Load <Texture2D>("image\\bground");
            backgroundborder = Content.Load <Texture2D>("image\\bgborder");
            backgroundsky    = Content.Load <Texture2D>("image\\sky");
            mainFrame        = new Rectangle(0, 0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height);
        }
コード例 #17
0
        /// <summary>
        /// Update subprogram for GameScreen
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values</param>
        public void Update(GameTime gameTime)
        {
            // Updating player and world
            Player.Update(gameTime, Camera.Position);
            World.Update(gameTime);

            // Updating the offset of the camera and moving camera if appropraite
            cameraOffset = Player.Center.ToVector2() - Camera.Center;
            if (Math.Abs(cameraOffset.X) > SharedData.SCREEN_WIDTH / 6)
            {
                Camera.Position += (cameraOffset.X > 0 ? 1 : -1) * new Vector2(Math.Abs(cameraOffset.X) - SharedData.SCREEN_WIDTH / 6, 0);
            }
            if (Math.Abs(cameraOffset.Y) > SharedData.SCREEN_HEIGHT / 6)
            {
                Camera.Position += (cameraOffset.Y > 0 ? 1 : -1) * new Vector2(0, Math.Abs(cameraOffset.Y) - SharedData.SCREEN_HEIGHT / 6);
            }

            // Showing/unshowing statistics as desired
            if (KeyboardHelper.NewKeyStroke(SettingsScreen.Instance.Statistics))
            {
                showStatistics = !showStatistics;
            }

            // Updating logic for minimap camera
            miniMapCamera.Position = -World.WorldBoundsRect.Location.ToVector2() / Chunk.SIZE + adjustmentVector;
            miniMapCamera.Origin   = miniMapCamera.Position - World.WorldBoundsRect.Location.ToVector2() / Chunk.SIZE * miniMapCamera.OrthographicSize / 2.0f;

            // Switchint back to main menu if player dies or player goes back to screen
            if (Player.Health <= 0)
            {
                Player = null;
                World  = null;
                deathSoundEffect.CreateInstance().Play();
                Main.CurrentScreen = ScreenMode.MainMenu;
            }
            else if (KeyboardHelper.NewKeyStroke(SettingsScreen.Instance.Pause))
            {
                Main.CurrentScreen = ScreenMode.MainMenu;
            }
        }
コード例 #18
0
ファイル: Game1.cs プロジェクト: ZachPeterson/Spectrum
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            mScoreFont        = Content.Load <SpriteFont>("scoreFont");
            mTextboxFont      = Content.Load <SpriteFont>("textboxFont");
            mDescriptionFont  = Content.Load <SpriteFont>("detailFont");
            mDescription2Font = Content.Load <SpriteFont>("detailFont2");

            mMusicMenu     = Content.Load <SoundEffect>("Music_Menu");
            mMusicGameplay = Content.Load <SoundEffect>("Music_Gameplay");

            mExplosion  = Content.Load <SoundEffect>("Explosion77");
            mShootSound = Content.Load <SoundEffect>("Laser_Shoot14");
            mHitSound   = Content.Load <SoundEffect>("Hit_Hurt33");

            mBulletSpamSound        = Content.Load <SoundEffect>("BulletSpam");
            mDualWieldSound         = Content.Load <SoundEffect>("DualWield");
            mMissileFlurrySound     = Content.Load <SoundEffect>("MissileFlurry");
            mOverchargeEnginesSound = Content.Load <SoundEffect>("OverchargeEngines");
            mQuickFixSound          = Content.Load <SoundEffect>("QuickFix");
            mQuickTurnSound         = Content.Load <SoundEffect>("QuickTurn");
            mSatelliteSound         = Content.Load <SoundEffect>("Satellite");
            mSiegeModeSound         = Content.Load <SoundEffect>("SiegeMode");
            mTankShieldSound        = Content.Load <SoundEffect>("TankShield");
            mWarpDriveSound         = Content.Load <SoundEffect>("WarpDrive");
            mWaveBlastSound         = Content.Load <SoundEffect>("WaveBlast");
            mPickUpSound            = Content.Load <SoundEffect>("PickUpSound");
            mBombBeepSlow           = Content.Load <SoundEffect>("BombBeepSlow");
            mBombBeepFast           = Content.Load <SoundEffect>("BombBeepFast");
            mMineSound       = Content.Load <SoundEffect>("Mine");
            mAntiBulletSound = Content.Load <SoundEffect>("Antibullets");
            mTighterTurns    = Content.Load <SoundEffect>("TighterTurns");

            mMusicMenu_Instance              = mMusicMenu.CreateInstance();
            mMusicMenu_Instance.IsLooped     = true;
            mMusicGameplay_Instance          = mMusicGameplay.CreateInstance();
            mMusicGameplay_Instance.IsLooped = true;
            aaDisplay.LoadAssets();
        }
コード例 #19
0
        protected void DeleteLines()
        {
            linesClearedSimultaneously = 0;
            for (int i = 0; i < 40; i++)
            {
                if (board[0, i] != null && board[1, i] != null && board[2, i] != null && board[3, i] != null && board[4, i] != null && board[5, i] != null && board[6, i] != null && board[7, i] != null && board[8, i] != null && board[9, i] != null)
                {
                    for (int j = 0; j < 10; j++)
                    {
                        board[j, i] = null;
                    }

                    for (int k = i; k > 0; k--)
                    {
                        for (int j = 0; j < 10; j++)
                        {
                            board[j, k] = board[j, k - 1];
                        }
                    }
                    linesClearedSimultaneously++;
                    linesCleared++;
                }
            }
            if (linesClearedSimultaneously == 1)
            {
                singleCleared++; AddScore("single"); LineclearSFX.CreateInstance().Play();
            }
            if (linesClearedSimultaneously == 2)
            {
                doublesCleared++; AddScore("double"); LineclearSFX.CreateInstance().Play();
            }
            if (linesClearedSimultaneously == 3)
            {
                tripleCleared++; AddScore("triple"); LineclearSFX.CreateInstance().Play();
            }
            if (linesClearedSimultaneously == 4)
            {
                tetrisCleared++; AddScore("tetris"); TetrisSFX.CreateInstance().Play();
            }
        }
コード例 #20
0
        public void PlaySound(string _soundName, Vector3 _position,
                              Vector3 _forward, Vector3 _up, Vector3 _velocity,
                              float _randomVolumeRange = 0.0f, float _randomPitchRange = 0.0f)
        {
            SoundEffect soundEffect = Mgr <CatProject> .Singleton.contentManger.Load <SoundEffect>
                                          (_soundName);

            // get from limit
            if (!GetSoundFromLimit(_soundName))
            {
                return;
            }

            SoundEffectInstance soundEffectInstance = soundEffect.CreateInstance();

            soundEffectInstance.Pitch =
                _randomPitchRange * 2.0f * ((float)m_random.NextDouble() - 0.5f);

            soundEffectInstance.Volume = 1.0f -
                                         _randomVolumeRange * (float)m_random.NextDouble();
            AudioEmitter  audioEmitter  = new AudioEmitter();
            AudioListener audioListener = new AudioListener();

            audioListener.Position    = Mgr <Camera> .Singleton.CameraPosition;
            audioListener.Forward     = Mgr <Camera> .Singleton.Forward;
            audioListener.Up          = Mgr <Camera> .Singleton.Up;
            audioListener.Velocity    = Mgr <Camera> .Singleton.Velocity;
            audioEmitter.DopplerScale = 10.0f;
            audioEmitter.Position     = _position;
            audioEmitter.Forward      = _forward;
            audioEmitter.Up           = _up;
            audioEmitter.Velocity     = _velocity;
            soundEffectInstance.Apply3D(audioListener, audioEmitter);
            SoundEffectPack soundEffectPack =
                new SoundEffectPack(_soundName, soundEffectInstance,
                                    audioEmitter, audioListener);

            m_soundBank.Add(soundEffectPack);
            soundEffectInstance.Play();
        }
コード例 #21
0
        private void LoadMusicFiles()
        {
            DirectoryInfo songFolder = new DirectoryInfo(MUSIC_FOLDER_NAME);

            foreach (FileInfo file in songFolder.GetFiles())
            {
                string      name   = Path.GetFileNameWithoutExtension(file.Name);
                SoundEffect effect = null;

                using (Stream waveFileStream = File.OpenRead(file.FullName))
                {
                    switch (file.Extension)
                    {
                    case ".wav":
                        effect = SoundEffect.FromStream(waveFileStream);
                        break;

                    case ".mp3":
                        using (Mp3FileReader reader = new Mp3FileReader(waveFileStream))
                            using (WaveStream pcmStream = WaveFormatConversionStream.CreatePcmStream(reader))
                            {
                                string tempPath = Path.Combine(songFolder.FullName, $"{name}.wav");

                                WaveFileWriter.CreateWaveFile(tempPath, pcmStream);
                                using (Stream tempStream = File.OpenRead(tempPath))
                                    effect = SoundEffect.FromStream(tempStream);
                                File.Delete(tempPath);
                            }
                        break;

                    default:
                        CommunityMod.ModMonitor.Log($"Unsupported file extension {file.Extension}.", LogLevel.Warn);
                        break;
                    }
                }

                SoundEffectInstance instance = effect.CreateInstance();
                this._songs.Add(name, instance);
            }
        }
コード例 #22
0
        internal SoundEmitter(SoundEffect sound, bool looped, float pitch, float volumeFactor, bool paused, Vector3?position)
        {
            this.SM            = ServiceHelper.Get <ISoundManager>();
            this.EngineState   = ServiceHelper.Get <IEngineStateManager>();
            this.CameraManager = ServiceHelper.Get <IDefaultCameraManager>();
            ILevelManager levelManager = ServiceHelper.Get <ILevelManager>();

            this.VolumeLevel  = this.SM.GetVolumeLevelFor(sound.Name);
            this.VolumeMaster = this.EngineState.DotLoading ? 0.0f : 1f;
            this.FadeDistance = 10f;
            this.AxisMask     = Vector3.One;
            this.VolumeFactor = volumeFactor;
            this.position     = position;
            if (SoundManager.NoMoreSounds)
            {
                return;
            }
            try
            {
                this.Cue          = sound.CreateInstance(levelManager.LowPass);
                this.Pitch        = pitch;
                this.Cue.IsLooped = looped;
                if (!paused)
                {
                    this.Cue.Volume = volumeFactor * this.VolumeLevel;
                    this.Cue.Play();
                    this.Update();
                }
                else
                {
                    this.Cue.Volume = 0.0f;
                    this.Cue.Play();
                    this.Cue.Pause();
                }
            }
            catch (InstancePlayLimitException ex)
            {
                Logger.Log("SoundEmitter", LogSeverity.Warning, "Couldn't create sound instance (too many instances)");
            }
        }
コード例 #23
0
ファイル: LevelScreen.cs プロジェクト: CodeEdelmann/HideOut
        public override void LoadContent(GraphicsDevice gd, ContentManager cm)
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(gd);

            //testing for text display

            // http://www.newgrounds.com/audio/listen/568885
            victorySound = cm.Load <SoundEffect>("victory.wav");

            // http://www.newgrounds.com/audio/listen/135985
            failureSound = cm.Load <SoundEffect>("police.wav");//failure.wav");

            gameSound = cm.Load <SoundEffect>("ambience.wav");


            mainMusic = gameSound.CreateInstance();

            mainMusic.IsLooped = true;

            //mainMusic
            // TODO: use this.Content to load your game content here
            //.LoadContent(GraphicsDevice, Content);
            displayController.LoadContent(cm);
            npcController.LoadContent(cm);
            obstacleController.LoadContent(cm);
            playerController.LoadContent(cm);
            itemController.LoadContent(cm);

            bgTexture = cm.Load <Texture2D>("bg.png");

            //Initialization for basicEffect
            basicEffect = new BasicEffect(gd);
            basicEffect.VertexColorEnabled = true;
            basicEffect.LightingEnabled    = false;
            //displayController.addDisplay(10, 100, "Hello world 1");


            //_fontRenderer = new FontRenderer(fontFile, <Texture2D>("player.png"));
        }
コード例 #24
0
        protected override void Update(GameTime gameTime)
        {
            Time.Update(gameTime);
            InputManager.Update();

            transforms[0].Rotate(Vector3.UnitY, Time.ElapsedGameTime);

            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            Ray ray = camera.ScreenPointToWorldRay(InputManager.GetMousePosition());

            foreach (Collider collider in colliders)
            {
                if (collider.Intersects(ray) != null)
                {
                    effect.Parameters["DiffuseColor"].SetValue(Color.Red.ToVector3());
                    (model.Meshes[0].Effects[0] as BasicEffect).DiffuseColor = Color.Blue.ToVector3();

                    if (InputManager.IsMousePressed(0))
                    {
                        {
                            SoundEffectInstance instance = gunSound.CreateInstance();
                            instance.IsLooped = false;
                            instance.Volume   = 0.4f;
                            instance.Pitch    = 0.99f;
                            instance.Play();
                        }
                    }
                }
                else
                {
                    effect.Parameters["DiffuseColor"].SetValue(Color.Blue.ToVector3());
                    (model.Meshes[0].Effects[0] as BasicEffect).DiffuseColor = Color.Red.ToVector3();
                }
            }
            base.Update(gameTime);
        }
コード例 #25
0
        public static void PlaySoundInstance(string name, float pitch = 0)
        {
            if (_sounds.ContainsKey(name))
            {
                if (_sounds[name] != null)
                {
                    int lastInstance = _lastInstance[name];
                    lastInstance++;
                    lastInstance %= SoundEffectInstances;
                    _soundInstances[name][lastInstance].Stop(true);
                    _soundInstances[name][lastInstance].Pitch = pitch;
                    _soundInstances[name][lastInstance].Play();
                    _lastInstance[name] = lastInstance;
                }
            }
            else
            {
                try
                {
                    SoundEffect eff = _content.Load <SoundEffect>(name);
                    _sounds.Add(name, eff);
                    SoundEffectInstance[] instances = new SoundEffectInstance[SoundEffectInstances];
                    for (int x = 0; x < SoundEffectInstances; x++)
                    {
                        instances[x] = eff.CreateInstance();
                    }
                    _soundInstances.Add(name, instances);
                    _lastInstance.Add(name, 0);

                    if (_sounds[name] != null)
                    {
                        _sounds[name].Play(1, pitch, 0);
                    }
                }
                catch (ContentLoadException cle)
                {
                    _sounds.Add(name, null);
                }
            }
        }
コード例 #26
0
ファイル: SoundManager.cs プロジェクト: Rod995/dwarfcorp
        public static SoundEffectInstance PlaySound(string name, float volume = 1.0f, float pitch = 0.0f)
        {
            if (!HasAudioDevice)
            {
                return(null);
            }
            // TODO: Remove this block once the SoundManager is initialized in a better location.
            if (Content == null)
            {
                return(null);
            }

            SoundEffect effect = null;

            if (!EffectLibrary.ContainsKey(name))
            {
                effect = Content.Load <SoundEffect>(AssetManager.ResolveContentPath(name));
                EffectLibrary[name] = effect;
            }
            else
            {
                effect = EffectLibrary[name];
                if (effect.IsDisposed)
                {
                    effect = Content.Load <SoundEffect>(AssetManager.ResolveContentPath(name));
                    EffectLibrary[name] = effect;
                }
            }
            SFXMixer.Levels     levels   = Mixer.GetOrCreateLevels(name);
            SoundEffectInstance instance = effect.CreateInstance();

            instance.Volume = GameSettings.Default.MasterVolume * GameSettings.Default.SoundEffectVolume * volume * levels.Volume;
            instance.Pitch  = pitch;
            instance.Play();
            instance.Volume = GameSettings.Default.MasterVolume * GameSettings.Default.SoundEffectVolume * volume * levels.Volume;
            instance.Pitch  = pitch;

            ActiveSounds2D.Add(instance);
            return(instance);
        }
コード例 #27
0
ファイル: Espada.cs プロジェクト: Vannu/Monogame
        public override void Update(GameTime gameTime)
        {
            if (firstRun)
            {
                SoundEffect sonido = Game1.TheGame.Sounds[Game1.Sonidos.Disparo];
                sonido.CreateInstance();
                sonido.Play();
                firstRun = false;
            }

            #region coordenadas

            Rectangle = new Rectangle(Rectangle.X + Speed,
                                      Rectangle.Y,
                                      Rectangle.Width,
                                      Rectangle.Height);

            if (Rectangle.X > Game1.TheGame.GraphicsDevice.Viewport.Width ||
                Rectangle.X < 0)
            {
                Game1.TheGame.Actualizaciones.Add(this);
            }

            #endregion

            foreach (var item in Game1.TheGame.sprites)
            {
                Zombie zom = item as Zombie;
                if (zom != null /*item is Zombie*/)
                {
                    if (zom.Rectangle.Intersects(Rectangle))
                    {
                        zom.Health -= Energy;
                        xena.Score += 10;
                        Game1.TheGame.Actualizaciones.Add(this);
                        break;
                    }
                }
            }
        }
コード例 #28
0
ファイル: Game1.cs プロジェクト: typ0ninja/RaccoonWrangler
        /// <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);
            IsMouseVisible = true;
            Font1          = Content.Load <SpriteFont>("Impact");
            //drawBG1 = new Rectangle((int)0, (int)0, Grass1.Width/4, Grass1.Height/4);
            drawBG1     = new Rectangle((int)0, (int)0, (int)screenWidth * 4, (int)screenHeight * 4);
            drawBG2     = new Rectangle((int)Grass1.Width / 4, (int)0, Grass1.Width / 4, Grass1.Height / 4);
            winloseRect = new Rectangle((int)screenWidth / 2, (int)screenHeight / 2, (int)winScreen.Width, (int)winScreen.Height);
            updateFlock();
            musicBGinst          = musicBG.CreateInstance();
            musicBGinst.IsLooped = true;
            musicBGinst.Play();

            chitterInst = chitter.CreateInstance();
            chitterInst.Play();



            // TODO: use this.Content to load your game content here
        }
コード例 #29
0
 public override void Play(bool loop = false)
 {
     if (null == effect)
     {
         return;
     }
     if (loop)
     {
         // If looping, then get an instance of this sound effect so that it can be
         // stopped.
         sfxInstance          = effect.CreateInstance();
         sfxInstance.IsLooped = true;
     }
     if (sfxInstance != null)
     {
         sfxInstance.Play();
     }
     else
     {
         effect.Play();
     }
 }
コード例 #30
0
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            shipSprite     = Content.Load <Texture2D>("ship_new");
            asteroidSprite = Content.Load <Texture2D>("asteroid_new");
            spaceSprite    = Content.Load <Texture2D>("bakground_space");
            lifeIcon       = Content.Load <Texture2D>("heart-icon");

            collisionSound               = Content.Load <SoundEffect>("collisionSound");
            loseSound                    = Content.Load <SoundEffect>("loseSound");
            backgroundMusic              = Content.Load <SoundEffect>("background");
            soundEffectInstance          = backgroundMusic.CreateInstance();
            soundEffectInstance.IsLooped = true;
            soundEffectInstance.Play();



            gameFont = Content.Load <SpriteFont>("spaceFont");
            timeFont = Content.Load <SpriteFont>("timerFont");
        }
コード例 #31
0
ファイル: Player.cs プロジェクト: samdherron/Fireball_Dodger
        protected override void LoadContent()
        {
            base.LoadContent();
            spriteBatch = new SpriteBatch(GraphicsDevice);
            //sprite = content.Load<Texture2D>("warrior1");
            spriteSheet = content.Load <Texture2D>(@"Player\adventurerSheet");
            //spriteSheet = content.Load<Texture2D>("warriorsprites");
            spriteSheet_powerUp = content.Load <Texture2D>(@"Player\adventurerSheet_powerup2");
            //spriteSheet_powerUpLava = content.Load<Texture2D>("lava_Shield");
            font = content.Load <SpriteFont>("font");
            spriteSheet_death = content.Load <Texture2D>(@"Player\adventurerSheet_Death");
            landSound         = content.Load <SoundEffect>(@"Sound\landNoise");

            landInstance        = landSound.CreateInstance();
            landInstance.Volume = 0.05f;

            //for healthBar if wanted

            /*
             * p1HealthBar = content.Load<Texture2D>("healthbar");
             */
        }
コード例 #32
0
ファイル: LoopedSample.cs プロジェクト: Dahrkael/CoRe
 public LoopedSample(string Filename)
 {
     se = Cache.SE(Filename);
     sei = se.CreateInstance();
     sei.Volume = Sample.DefaultVolume;
 }