Example #1
0
        public static bool Init()
        {
            graphics = new GraphicsContext();
            SampleDraw.Init(graphics);

            int sx = (graphics.Screen.Width / 2) - ((96 * 2) + (16 * 2));
            int sy = (graphics.Screen.Height / 2) - (96 / 2);

            playButton   = new SampleButton(sx + 0, sy - 24, 96, 48);
            stopButton   = new SampleButton(sx + 112, sy - 24, 96, 48);
            pauseButton  = new SampleButton(sx + 224, sy - 24, 96, 48);
            resumeButton = new SampleButton(sx + 336, sy - 24, 96, 48);
            volumeSlider = new SampleSlider(sx + 88, sy + 96, 256, 48);

            volTextPosX = (sx + 88) - 96;
            volTextPosY = (sy + 96) + 12;

            playButton.SetText("Play");
            stopButton.SetText("Stop");
            pauseButton.SetText("Pause");
            resumeButton.SetText("Resume");

            bgm       = new Bgm("/Application/Sample/Audio/BgmPlayerSample/GAME_BGM_01.mp3");
            bgmPlayer = bgm.CreatePlayer();

            return(true);
        }
Example #2
0
 /// <summary>
 /// 建立音乐播放器
 /// </summary>
 public void CreatMusicPlayer(Bgm music)
 {
     MusicPlayer        = music.CreatePlayer();
     MusicPlayer.Volume = 0;
     MusicPlayer.Loop   = musicLoop;
     MusicPlayer.Play();
 }
Example #3
0
        public TitleScene()
        {
            this.Camera.SetViewFromViewport();
            m_texture = new Texture2D("Application/images/title.png", false);
            m_ti      = new TextureInfo(m_texture);
            SpriteUV titleScreen = new SpriteUV(m_ti);

            titleScreen.Scale    = m_ti.TextureSizef;
            titleScreen.Pivot    = new Vector2(0.5f, 0.5f);
            titleScreen.Position = new Vector2(Director.Instance.GL.Context.GetViewport().Width / 2.0f,
                                               Director.Instance.GL.Context.GetViewport().Height / 2.0f);
            this.AddChild(titleScreen);

            Vector4 origColor = titleScreen.Color;

            titleScreen.Color = new Vector4(0, 0, 0, 0);
            var tintAction = new TintTo(origColor, 10.0f);

            ActionManager.Instance.AddAction(tintAction, titleScreen);
            tintAction.Run();

            m_titleSong = new Bgm("/Application/audio/titlesong.mp3");

            if (m_songPlayer != null)
            {
                m_songPlayer.Dispose();
            }
            m_songPlayer = m_titleSong.CreatePlayer();

            Scheduler.Instance.ScheduleUpdateForTarget(this, 0, false);

            // Clear any queued clicks so we dont immediately exit if coming in from the menu
            Touch.GetData(0).Clear();
        }
Example #4
0
        //Resets the game in order to make a fresh, new game
        public static void NewGame()
        {
            //Disposes of menu music, and plays game music
            bgmplay.Dispose();
            Bgm bgm2 = new Bgm("/Application/Sounds/RomanticFall.mp3");

            bgmplay2      = bgm2.CreatePlayer();
            bgmplay2.Loop = true;
            bgmplay2.Play();
            background       = new Background(graphics, backTex);
            backplanets      = new BackgroundPlanets(graphics);
            enemyTimeCounter = 0;
            weapons          = new List <Weapon> ();
            enemies          = new List <Enemy> ();
            pickups          = new List <Pickup> ();
            ebullets         = new List <EnemyBullet> ();
            p             = new Player(graphics, 100, 100, pTex);
            counter       = -1;
            currentWeapon = GameWeapons.Missles;
            enemyCounter  = enemies.Count;
            timeDelta     = 0;
            hasLaser      = false;
            hasMissle     = true;
            hasSpread     = false;
            p1            = new Pickup(graphics, powTex, gen.Next(100, 700), gen.Next(100, 500));
            pickups.Add(p1);
            p2 = new Pickup(graphics, powTex, gen.Next(100, 700), gen.Next(100, 500));
            pickups.Add(p2);
            spreadNext   = false;
            laserNext    = false;
            playerScore  = 0;
            enterName    = "";
            newHighScore = false;
        }
Example #5
0
        public InGameScene()
        {
            InitializeUI();

            scene = new Sce.PlayStation.HighLevel.GameEngine2D.Scene();
            scene.Camera.SetViewFromViewport();

            textureInfo       = new TextureInfo("/Application/Assets/stone2.png");
            background        = new SpriteUV(textureInfo);
            background.Quad.S = textureInfo.TextureSizef;
            scene.AddChild(background);
            numTanks = 5;
            //tank = new Tank(scene);
            //tankSpawner = new Spawner(tank);
            tankList = new Tank[numTanks];
            for (int i = 0; i < numTanks; i++)
            {
                tankList[i] = new Tank(scene);
            }

            player = new Player(scene);

            ScoreManager.Instance.startTime();
            alive = true;

            bgSound       = new Bgm("/Application/Audio/BenHill.mp3");
            bgSoundPlayer = bgSound.CreatePlayer();
            //Fix when it plays

            //bgSoundPlayer.Dispose();
        }
        public EndGameScene()
        {
            scene = new Sce.PlayStation.HighLevel.GameEngine2D.Scene();
            scene.Camera.SetViewFromViewport();

            textureInfo       = new TextureInfo("/Application/Assets/endBackground.png");
            background        = new SpriteUV(textureInfo);
            background.Quad.S = textureInfo.TextureSizef;
            scene.AddChild(background);
            timer = 0.0f;

            scoreTxt          = new Label();
            scoreTxt.Text     = "Score: " + ScoreManager.Instance.getScore();
            scoreTxt.Scale    = new Vector2(5.0f, 5.0f);
            scoreTxt.Position = new Vector2(Director.Instance.GL.Context.GetViewport().Width / 2 - 150, Director.Instance.GL.Context.GetViewport().Height *0.1f);
            scoreTxt.Color    = new Vector4(0.0f, 1.0f, 0.0f, 1.0f);

            Bgm hahaSound = new Bgm("/Application/Audio/Haha.mp3");

            hahaSoundPlayer = hahaSound.CreatePlayer();
            //Fix when it plays
            hahaSoundPlayer.Play();



            scene.AddChild(scoreTxt);

            ScoreManager.Instance.reset();
        }
Example #7
0
        public TitleScene()
        {
            this.Camera.SetViewFromViewport();
            _texture = new Texture2D("Application/images/title.png",false);
            _ti = new TextureInfo(_texture);
            SpriteUV titleScreen = new SpriteUV(_ti);
            titleScreen.Scale = _ti.TextureSizef;
            titleScreen.Pivot = new Vector2(0.5f,0.5f);
            titleScreen.Position = new Vector2(Director.Instance.GL.Context.GetViewport().Width/2,
                                              Director.Instance.GL.Context.GetViewport().Height/2);
            this.AddChild(titleScreen);

            Vector4 origColor = titleScreen.Color;
            titleScreen.Color = new Vector4(0,0,0,0);
            var tintAction = new TintTo(origColor,10.0f);
            ActionManager.Instance.AddAction(tintAction,titleScreen);
            tintAction.Run();

            _titleSong = new Bgm("/Application/audio/titlesong.mp3");

            if(_songPlayer != null)
            _songPlayer.Dispose();
            _songPlayer = _titleSong.CreatePlayer();

            Scheduler.Instance.ScheduleUpdateForTarget(this,0,false);

            // Clear any queued clicks so we dont immediately exit if coming in from the menu
            Touch.GetData(0).Clear();
        }
Example #8
0
        public static void InitSound()
        {
            stage1 = new Bgm("/Application/resourses/stage1.mp3");
            stage1boss = new Bgm("/Application/resourses/stage1boss.mp3");
            title = new Bgm("/Application/resourses/title.mp3");
            gameover = new Bgm("/Application/resourses/gameover.mp3");

            bgmPlayer = stage1.CreatePlayer();

            sound = new Sound("/Application/resourses/shot.wav");
            shot = sound.CreatePlayer();
            sound = new Sound("/Application/resourses/hidan.wav");
            hidan = sound.CreatePlayer();
            sound = new Sound("/Application/resourses/siren.wav");
            siren = sound.CreatePlayer();
            sound = new Sound("/Application/resourses/stageClear.wav");
            stageClear = sound.CreatePlayer();
            sound = new Sound("/Application/resourses/system1.wav");
            ok = sound.CreatePlayer();
            sound = new Sound("/Application/resourses/system2.wav");
            cancel = sound.CreatePlayer();
            sound = new Sound("/Application/resourses/damage.wav");
            tekihidan = sound.CreatePlayer();
            sound = new Sound("/Application/resourses/skillSE1.wav");
            skill1 = sound.CreatePlayer();
            sound = new Sound("/Application/resourses/skillSE2.wav");
            skill2 = sound.CreatePlayer();
            sound = new Sound("/Application/resourses/stageClear.wav");
            stageClear = sound.CreatePlayer();
            sound = new Sound("/Application/resourses/tick.wav");
            ticktuck = sound.CreatePlayer();
        }
Example #9
0
 public MainScene()
 {
     InitializeWidget();
     InitializeButtonEvents();
     bgm = new Bgm("/Application/assets/GAME_BGM_01.mp3");
     bp = bgm.CreatePlayer();
     bp.Loop = true;
 }
Example #10
0
        public static void init()
        {
            if(sounds != null) return;

            bgm = new Bgm("/Application/assets/music/music.mp3");
            bgmPlayer = bgm.CreatePlayer();
            bgmPlayer.Loop = true;

            sounds = new Dictionary<string, SoundTuple>();
        }
Example #11
0
        public void Play(string name)
        {
            StopAll();

            var music  = new Bgm(AssetsPrefix + name);
            var player = music.CreatePlayer();

            MusicDatabase [name] = player;

            MusicDatabase [name].Play();
            MusicDatabase [name].Loop   = true;
            MusicDatabase [name].Volume = 0.5f;
        }
Example #12
0
        public override void OnEnter()
        {
            BaseScene.SetUpScene(this, "assets/backdrop/dungeon-colour.png", ref sprite,
                                 550f, new Vector2(0, 0), new Vector2i(1, 1));

            music = new Bgm("assets/Music/creepyloop.mp3");

            player = music.CreatePlayer();

            player.Play();

            base.OnEnter();
        }
Example #13
0
        public AudioManager()
        {
            System.Diagnostics.Debug.WriteLine("Audio manager constructor");
            _titleSong = new Bgm("/Application/audio/titlesong.mp3");
            _mainSong = new Bgm("/Application/audio/wikistep.mp3");

            if(_songPlayer != null) {
                _songPlayer.Dispose();
            }
            _songPlayer = _titleSong.CreatePlayer();
            _songPlayer.Loop = true;
            _songPlayer.Play ();
        }
Example #14
0
 internal void Play()
 {
     if (_currentSong != this) //If needed switch up the current song
     {
         if (_bgmPlayer != null)
         {
             _bgmPlayer.Stop();
             _bgmPlayer.Dispose();
         }
         _bgmPlayer   = _bgm.CreatePlayer();
         _currentSong = this;
     }
     _bgmPlayer.Play();
 }
Example #15
0
        public override void OnEnter()
        {
            BaseScene.SetUpScene(this, "assets/backdrop/good town.png", ref sprite,
                                 550f, new Vector2(0, 0), new Vector2i(1, 1));
            music = new Bgm("assets/Music/sappypianointerlude.mp3");

            player = music.CreatePlayer();

            player.Play();



            base.OnEnter();
        }
Example #16
0
        //Background Music
        private static void MusicPlay(string music)
        {
            try
            {
                bgmp.Dispose();
            }
            catch {}

            Bgm bgm = new Bgm(music);

            bgmp      = bgm.CreatePlayer();
            bgmp.Loop = true;
            bgmp.Play();
        }
Example #17
0
        public override void OnEnter()
        {
            BaseScene.SetUpScene(this, "assets/Test/Black.png", ref sprite,
                                 16f, new Vector2(0, 0), this.Camera2D.CalcBounds().Size, new Vector2i(1, 1));

            music = new Bgm("assets/Music/dirgeloop.mp3");

            player = music.CreatePlayer();

            player.Play();


            this.RegisterDisposeOnExitRecursive();
            base.OnEnter();
        }
Example #18
0
        public override void OnEnter()
        {
            BaseScene.SetUpScene(this, "assets/backdrop/fortress-01.png", ref sprite,
                                 550f, new Vector2(0, 0), new Vector2i(1, 1));

            music = new Bgm("assets/Music/dirgeloop.mp3");

            player = music.CreatePlayer();

            player.Play();



            base.OnEnter();
        }
Example #19
0
        public static void Initialize()
        {
            // Set up the graphics system
            graphics = new GraphicsContext();

            //Background and Foreground
            background = new BackGround(graphics);
            foreground = new Foreground(graphics);

            //added stopwatch
            clock = new Stopwatch();
            clock.Start();


            //Name the Characters
            character1        = "GoodGuy";
            character2        = "GoodGuy2";
            character3        = "Villain";
            character4        = "Villain2";
            characterName1    = "Stuper Man";
            characterName2    = "BafMan";
            characterName3    = "Lexus Luthor";
            characterName4    = "Trickster";
            isPC1             = true;
            isPC2             = true;
            isPC3             = false;
            isPC4             = false;
            UniqueIDChar1     = 0;
            UniqueIDChar2     = 1;
            UniqueIDChar3     = 0;
            UniqueIDChar4     = 1;
            totalCharacterNum = 4;

            //background Music
            Bgm bgm = new Bgm("/Application/Assets/fight.mp3");

            bgmp      = bgm.CreatePlayer();
            bgmp.Loop = true;
            bgmp.Play();


            //Creating image for Menu Screen
            imageMenu  = new Texture2D("/Application/Assets/Menu Screen.png", false);
            menuScreen = new Sprite(graphics, imageMenu);

            //setting state to Menu.
            currentState = GameState.Menu;
        }
Example #20
0
        public static void UpdateDead()
        {
            var gamePadData = GamePad.GetData(0);

            if ((gamePadData.ButtonsDown & GamePadButtons.Start) != 0)
            {
                currentState = GameState.HighScore;
                //Disposes of game music and plays menu music
                bgmplay2.Dispose();
                Bgm bgm = new Bgm("/Application/Sounds/gamebgm.mp3");
                bgmplay      = bgm.CreatePlayer();
                bgmplay.Loop = true;
                bgmplay.Play();
            }
            updateScore = true;
        }
Example #21
0
        public FireNode()
        {
            fireBgm = new Bgm ("/Application/Assets/sound/fire.mp3");
            fireBgmPlayer = fireBgm.CreatePlayer();
            this.RegisterDisposeOnExit (fireBgm);
            this.RegisterDisposeOnExit (fireBgmPlayer);

            fireBgmPlayer.Loop = true;
            fireBgmPlayer.Play ();

            generateFirewallSprite ();
            generateSprite(spriteWidth, 0);
            AddChild(sprite);

            ScheduleUpdate();
        }
Example #22
0
        public SplashScene()
        {
            scene = new Sce.PlayStation.HighLevel.GameEngine2D.Scene();
            scene.Camera.SetViewFromViewport();

            textureInfo       = new TextureInfo("/Application/Assets/Splashscreen1.png");
            background        = new SpriteUV(textureInfo);
            background.Quad.S = textureInfo.TextureSizef;
            scene.AddChild(background);
            splatScale     = new Vector2(10.0f, 10.0f);
            titleScale     = new Vector2(15.0f, 15.0f);
            splatTex       = new TextureInfo("/Application/Assets/splat.png");
            titleTex       = new TextureInfo("/Application/Assets/splattxt.png");
            splat          = new SpriteUV(splatTex);
            splat.Quad.S   = splatTex.TextureSizef;
            splat.Position = new Vector2(Director.Instance.GL.Context.GetViewport().Width / 3, Director.Instance.GL.Context.GetViewport().Height / 7);
            title          = new SpriteUV(titleTex);
            title.Quad.S   = titleTex.TextureSizef;
            title.Position = new Vector2(Director.Instance.GL.Context.GetViewport().Width / 3.3f, Director.Instance.GL.Context.GetViewport().Height / 2.8f);

            logoTex       = new TextureInfo("/Application/Assets/logo.png");
            logo          = new SpriteUV(logoTex);
            logo.Quad.S   = logoTex.TextureSizef;
            logo.Scale    = new Vector2(0.5f, 0.5f);
            logo.Position = new Vector2(Director.Instance.GL.Context.GetViewport().Width / 2 - 375, Director.Instance.GL.Context.GetViewport().Height / 2 - 230);
            logo.Color    = new Vector4(1.0f, 1.0f, 1.0f, 0.0f);

            scene.AddChild(splat);
            scene.AddChild(title);
            scene.AddChild(logo);
            splat.Scale = splatScale;
            title.Scale = titleScale;
            splat.Color = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
            title.Color = new Vector4(1.0f, 1.0f, 1.0f, 0.0f);
            speed       = 1.0f;

            playing     = false;
            splatSound  = new Bgm("/Application/Audio/Splat.mp3");
            SoundPlayer = splatSound.CreatePlayer();

            metalPlaying = false;
            metalSound   = new Bgm("/Application/Audio/Metal.mp3");
        }
Example #23
0
        public static bool Init()
        {
            decodeStream = File.OpenRead("/Application/apple.psmvideo");

            graphics = new GraphicsContext();
            SampleDraw.Init(graphics);
            bgm       = new Bgm("/Application/apple.mp3");
            bgmPlayer = bgm.CreatePlayer();
            FrameImg  = new Image(ImageMode.Rgba, new ImageSize(480, 360), new ImageColor(0, 0, 0, 255));

            tex = createTexture(FrameImg);
            spr = new SampleSprite(tex, ((960 / 2) - 480), ((544 / 2) - 360));

            timer = new Stopwatch();
            bgmPlayer.Play();


            return(true);
        }
Example #24
0
        public override void OnEnter()
        {
            worldmap = new SpriteUV();

            currentx = 0f;
            currenty = 0f;
            height   = 320f;

            SetUpWorldMap(this, "assets/WorldMap/DemoWorldMapWalls.png", ref worldmap,
                          height, new Vector2(currentx, currenty),
                          new Vector2i(1, 1));

            SetUpMapPieces(minePieces, mineDrillPieces, lumberMillPieces, strongHoldPieces, ref mineSheetTextureInfo, ref lumbermillSheetTextureInfo, ref strongHoldAndMineSheetTextureInfo);

            SetMineDrillPiecesInMineDrillList(mineSheetTextureInfo, ref mineDrillList, ref mineDrillPieces, .059f);

            SetLumberMillPiecesInLumberMillList(lumbermillSheetTextureInfo, ref lumberMillList, ref lumberMillPieces, .059f);

            SetMinePiecesInMineList(strongHoldAndMineSheetTextureInfo, ref mineAndStrongHoldList, ref minePieces, .059f);

            SetStrongHoldPiecesInStrongHoldList(strongHoldAndMineSheetTextureInfo, ref mineAndStrongHoldList, ref strongHoldPieces, .059f);

            music   = new Bgm("assets/Music/loop.mp3");
            boombox = music.CreatePlayer();
            boombox.Play();



            this.AddChild(mineAndStrongHoldList);

            this.AddChild(lumberMillList);

            this.AddChild(mineDrillList);

            this.ScheduleUpdate();
            this.RegisterDisposeOnExitRecursive();


            base.OnEnter();
        }
Example #25
0
    public virtual int PlayMusic(String path, int flags)
    {
        StopMusic();

        _music = BBPsmGame.PsmGame().LoadBgm(path);
        if (_music == null)
        {
            return(-1);
        }

        _musicPlayer = _music.CreatePlayer();
        if (_musicPlayer == null)
        {
            _music = null;
            return(-1);
        }

        _musicPlayer.Loop   = (flags & 1) != 0;
        _musicPlayer.Volume = _musicVolume;
        _musicPlayer.Play();

        return(-1);
    }
Example #26
0
        public static void Initialize()
        {
            graphics = new GraphicsContext();

            // Initialize UI Toolkit
            UISystem.Initialize(graphics);
            screenWidth  = UISystem.FramebufferWidth;
            screenHeight = UISystem.FramebufferHeight;

            // Create scene
            Scene scene = new Sce.PlayStation.HighLevel.UI.Scene();

            #region Big Bang - Fun with Flags - Intro sound


            #endregion
            #region Scotland Flag and sounds
            ImageBox scotlandFlag = new ImageBox();
            scotlandFlag.Image          = new ImageAsset("/Application/flags/scotland.png");
            scotlandFlag.ImageScaleType = ImageScaleType.AspectInside;

            scotlandFlag.Width  = scotlandFlag.Image.Width / 2;
            scotlandFlag.Height = scotlandFlag.Image.Height / 2;

            scotlandFlag.X = screenWidth * 0.25f - (scotlandFlag.Width / 2);
            scotlandFlag.Y = screenHeight * 0.25f - (scotlandFlag.Height / 2);

            scotlandRect = new Rectangle(scotlandFlag.X, scotlandFlag.Y, scotlandFlag.Width, scotlandFlag.Height);
            /***********************sounds***************************/


            #endregion
            scene.RootWidget.AddChildLast(scotlandFlag);

            #region England Flag
            ImageBox englandFlag = new ImageBox();
            englandFlag.Image          = new ImageAsset("/Application/flags/england.png");
            englandFlag.ImageScaleType = ImageScaleType.AspectInside;

            englandFlag.Width  = englandFlag.Image.Width / 2;
            englandFlag.Height = englandFlag.Image.Height / 2;

            englandFlag.X = screenWidth * 0.75f - (englandFlag.Width / 2);
            englandFlag.Y = screenHeight * 0.25f - (englandFlag.Height / 2);

            englandRect = new Rectangle(englandFlag.X, englandFlag.Y, englandFlag.Width, englandFlag.Height);

            #endregion
            scene.RootWidget.AddChildLast(englandFlag);

            #region Northern Ireland Flag
            ImageBox n_irelandFlag = new ImageBox();
            n_irelandFlag.Image          = new ImageAsset("/Application/flags/n_ireland.png");
            n_irelandFlag.ImageScaleType = ImageScaleType.AspectInside;

            n_irelandFlag.Width  = n_irelandFlag.Image.Width / 2;
            n_irelandFlag.Height = n_irelandFlag.Image.Height / 2;

            n_irelandFlag.X = screenWidth * 0.25f - (n_irelandFlag.Width / 2);
            n_irelandFlag.Y = screenHeight * 0.75f - (n_irelandFlag.Height / 2);

            n_irelandRect = new Rectangle(n_irelandFlag.X, n_irelandFlag.Y, n_irelandFlag.Width, n_irelandFlag.Height);

            #endregion
            scene.RootWidget.AddChildLast(n_irelandFlag);

            #region Wales Flag
            ImageBox walesFlag = new ImageBox();
            walesFlag.Image          = new ImageAsset("/Application/flags/wales.png");
            walesFlag.ImageScaleType = ImageScaleType.AspectInside;

            walesFlag.Width  = walesFlag.Image.Width / 2;
            walesFlag.Height = walesFlag.Image.Height / 2;

            walesFlag.X = screenWidth * 0.75f - (walesFlag.Width / 2);
            walesFlag.Y = screenHeight * 0.75f - (walesFlag.Height / 2);

            walesRect = new Rectangle(walesFlag.X, walesFlag.Y, walesFlag.Width, walesFlag.Height);
            #endregion
            scene.RootWidget.AddChildLast(walesFlag);
            // Set scene
            UISystem.SetScene(scene, null);

            #region Instantiate and Setup audio
            Bgm funWithFlags = new Bgm("/Application/sounds/funWithFlags.mp3");
            mp3Player = funWithFlags.CreatePlayer();
            #endregion
            /*************Play starting mp3 - funWithFlag s***********/
            mp3Player.Play();
        }
Example #27
0
        public static void Update()
        {
            var gamePadData = GamePad.GetData(0);

            //tester.Position.X = dat.X;
            //tester.Position.Y = dat.Y;

            //Menu Handling
            if (start || directions || enterscore || highscore || end)
            {
                menuBuffer++;
                if (start)
                {
                    if ((gamePadData.Buttons & GamePadButtons.Square) != 0 &&                //need != 0?
                        menuBuffer >= MENU_INPUT_BUFFER)
                    {
                        start      = false;
                        directions = true;
                        menuBuffer = 0;
                    }
                    if ((gamePadData.Buttons & GamePadButtons.Cross) != 0 &&
                        menuBuffer >= MENU_INPUT_BUFFER)
                    {
                        start = false;
                        game  = true;

                        menuBuffer = 0;
                        score      = 0;
                        difficulty = 0;
                        player     = new Player(graphics);
                        died       = false;
                        paused     = false;
                        for (int i = enemies.Count - 1; i >= 0; i--)
                        {
                            enemies.RemoveAt(i);
                        }
                        for (int i = projectiles.Count - 1; i >= 0; i--)
                        {
                            projectiles.RemoveAt(i);
                        }
                        gotFlame = false;
                        gotLazer = false;
                        wpn      = new WeaponBasic(graphics);

                        if (!gameMusic)
                        {
                            bgmp.Dispose();
                            Bgm bgm1 = new Bgm("/Application/Assets/playstate.mp3");
                            bgmp1      = bgm1.CreatePlayer();
                            bgmp1.Loop = true;
                            bgmp1.Play();
                            gameMusic = true;
                        }
                    }
                    if ((gamePadData.Buttons & GamePadButtons.Circle) != 0 &&
                        menuBuffer >= MENU_INPUT_BUFFER)
                    {
                        start      = false;
                        highscore  = true;
                        menuBuffer = 0;
                        UISystem.SetScene(sceneScores, null);
                    }
                    if ((gamePadData.Buttons & GamePadButtons.Start) != 0 &&
                        menuBuffer >= MENU_INPUT_BUFFER)
                    {
                        start      = false;
                        end        = true;
                        menuBuffer = 0;
                    }
                }
                if (directions)
                {
                    if ((gamePadData.Buttons & GamePadButtons.Square) != 0 &&
                        menuBuffer >= MENU_INPUT_BUFFER)
                    {
                        directions = false;
                        start      = true;
                        menuBuffer = 0;
                    }
                }
                if (highscore)
                {
                    if ((gamePadData.Buttons & GamePadButtons.Square) != 0 &&
                        menuBuffer >= MENU_INPUT_BUFFER)
                    {
                        highscore  = false;
                        start      = true;
                        menuBuffer = 0;
                        UISystem.SetScene(sceneGame, null);
                    }
                    if ((gamePadData.Buttons & GamePadButtons.Start) != 0 &&
                        menuBuffer >= MENU_INPUT_BUFFER)
                    {
                        highscore  = false;
                        end        = true;
                        menuBuffer = 0;
                        UISystem.SetScene(sceneGame, null);
                    }
                }
                if (enterscore)
                {
                    if ((gamePadData.Buttons & GamePadButtons.Up) != 0 &&
                        menuBuffer >= MENU_INPUT_BUFFER - 22)
                    {
                        if (label4.Text.Length == 1)
                        {
                            if (!label4.Text.Equals("z", StringComparison.OrdinalIgnoreCase))                            //look into why the oridinal ignore case
                            {
                                label4.Text = ((char)(label4.Text.ToCharArray()[0] + 1)).ToString().ToUpper();
                            }
                            else
                            {
                                label4.Text = "A";
                            }
                        }
                        else
                        if (label4.Text.Length == 2)
                        {
                            if (!label4.Text.Substring(1).Equals("z", StringComparison.OrdinalIgnoreCase))
                            {
                                label4.Text = label4.Text.Substring(0, 1) + ((char)(label4.Text.ToCharArray()[1] + 1)).ToString().ToUpper();
                            }
                            else
                            {
                                label4.Text = label4.Text.Substring(0, 1) + "A";
                            }
                        }
                        else
                        if (label4.Text.Length == 3)
                        {
                            if (!label4.Text.Substring(2).Equals("z", StringComparison.OrdinalIgnoreCase))
                            {
                                label4.Text = label4.Text.Substring(0, 2) + ((char)(label4.Text.ToCharArray()[2] + 1)).ToString().ToUpper();
                            }
                            else
                            {
                                label4.Text = label4.Text.Substring(0, 2) + "A";
                            }
                        }
                        menuBuffer = 0;
                    }
                    if ((gamePadData.Buttons & GamePadButtons.Down) != 0 &&
                        menuBuffer >= MENU_INPUT_BUFFER - 22)
                    {
                        if (label4.Text.Length == 1)
                        {
                            if (!label4.Text.Equals("a", StringComparison.OrdinalIgnoreCase))
                            {
                                label4.Text = ((char)(label4.Text.ToCharArray()[0] - 1)).ToString().ToUpper();
                            }
                            else
                            {
                                label4.Text = "Z";
                            }
                        }
                        if (label4.Text.Length == 2)
                        {
                            if (!label4.Text.Substring(1).Equals("a", StringComparison.OrdinalIgnoreCase))
                            {
                                label4.Text = label4.Text.Substring(0, 1) + ((char)(label4.Text.ToCharArray()[1] - 1)).ToString().ToUpper();
                            }
                            else
                            {
                                label4.Text = label4.Text.Substring(0, 1) + "Z";
                            }
                        }
                        if (label4.Text.Length == 3)
                        {
                            if (!label4.Text.Substring(2).Equals("a", StringComparison.OrdinalIgnoreCase))
                            {
                                label4.Text = label4.Text.Substring(0, 2) + ((char)(label4.Text.ToCharArray()[2] - 1)).ToString().ToUpper();
                            }
                            else
                            {
                                label4.Text = label4.Text.Substring(0, 2) + "Z";
                            }
                        }
                        menuBuffer = 0;
                    }
                    if ((gamePadData.Buttons & GamePadButtons.Cross) != 0 &&
                        menuBuffer >= MENU_INPUT_BUFFER - 20)
                    {
                        if (hiScore == (score - score % .01))
                        {
                            highscore  = true;
                            enterscore = false;
                            UISystem.SetScene(sceneScores);

                            try
                            {
                                StreamReader sr    = new StreamReader("/Documents/highscores.txt");
                                string       tempS = sr.ReadLine();
                                hiScore     = Double.Parse(tempS.Substring(3));
                                label3.Text = tempS.Substring(0, 3) + ": " + hiScore;
                                sr.Close();
                            }
                            catch (FileNotFoundException)
                            {
                                label3.Text = "File Not Found!";
                            }

                            label4.Text       = "A";
                            label4.Font.Size += 15;
                        }
                        if (label4.Text.Length < 3)
                        {
                            label4.Text += "A";
                        }
                        else
                        {
                            try
                            {
                                StreamWriter sw = new StreamWriter("/Documents/highscores.txt");
                                sw.WriteLine(label4.Text + (score - score % .01));
                                hiScore = score - score % .01;
                                sw.Close();
                                label4.Font.Size -= 15;
                                label4.Text       = "Entered! Press (s)";
                            }
                            catch (FileNotFoundException)
                            {
                                label4.Font.Size -= 10;
                                label4.Text       = "File not Found! Highscore not saved!";
                            }
                        }
                        menuBuffer = 0;
                    }
                }
                if (end)
                {
                    if ((gamePadData.Buttons & GamePadButtons.Start) != 0 &&
                        menuBuffer >= MENU_INPUT_BUFFER)
                    {
                        exit       = true;
                        menuBuffer = 0;
                    }
                }
            }             //end menu
            else
            {
                //Keeps you from pause spamming via 25-frame buffer
                pauseFrameBuffer++;

                if ((gamePadData.Buttons & GamePadButtons.Select) != 0 &&
                    pauseFrameBuffer >= 25)
                {
                    pauseFrameBuffer = 0;

                    if (paused == false)
                    {
                        paused = true;
                    }
                    else
                    {
                        paused = false;
                    }
                }

                if ((gamePadData.Buttons & GamePadButtons.Start) != 0)
                {
                    end = true;
                }

                if (died && !paused)
                {
                    start = true;
                }

                if (paused)
                {
                    if (label1.Font.Size < initialL1FontSize + 30)                    //font constants
                    {
                        label1.Font.Size += 3;
                    }

                    if (label1.Height < initialL1Height + 18)
                    {
                        label1.Height += 1.8f;
                    }

                    if (label2.Font.Size < initialL2FontSize + 30)
                    {
                        label2.Font.Size += 3;
                    }

                    if (label2.Height < initialL2Height + 18)
                    {
                        label2.Height += 1.8f;
                    }

                    if (label2.Y > initialL2Y - 24)
                    {
                        label2.Y -= 2.4f;
                    }
                }


                if (game && !paused)
                {
                    //Add Time Score
                    score += deltaTime / 500.0;
                    //Increase Difficulty and recaculate spawn times
                    difficulty += 0.5;
                    if (DESpawnRate > 150)
                    {
                        DESpawnRate = -0.2642 * difficulty + 755.9524;
                    }
                    if (LOSpawnRate > 300)
                    {
                        LOSpawnRate = -0.4628 * difficulty + 3000.5714;
                    }
                    if (SESpawnRate > 300)
                    {
                        SESpawnRate = -0.9358 * difficulty + 6907.1429;
                    }
                    if (BESpawnRate > 12500)
                    {
                        BESpawnRate = -0.9643 * difficulty + 34285.7143;
                    }


                    //Checks for picking up the Flamethrower
                    if (!gotFlame && distanceSquared(player.X + player.Area.Width / 2, flameBox.Position.X + flameBox.Width / 2,
                                                     player.Y + player.Area.Height / 2, flameBox.Position.Y + flameBox.Height / 2)
                        < Math.Pow(player.HitBox + flameBox.Height / 2, 2))
                    {
                        gotFlame = true;
                        score   += 1000;
                    }                     //etc
                    if (!gotLazer && distanceSquared(player.X + player.Area.Width / 2, lazerBox.Position.X + lazerBox.Width / 2,
                                                     player.Y + player.Area.Height / 2, lazerBox.Position.Y + lazerBox.Height / 2)
                        < Math.Pow(player.HitBox + lazerBox.Height / 2, 2))
                    {
                        gotLazer = true;
                        score   += 1000;
                    }

                    //Check for weapon change
                    changeWeapons(gamePadData);

                    //Spawn Enemies
                    createEnemies();

                    //Update Player
                    player.Update(gamePadData, deltaTime);

                    //Update Weapon in use
                    wpn.Update(player.X, player.Y, (int)player.Direction, gamePadData, deltaTime);

                    //This handles the creation of projectiles from the weapon.
                    if (wpn.MakeShot && distanceSquared(player.X + player.Area.Width / 2, shine.Position.X + shine.Width / 2,
                                                        player.Y + player.Area.Height / 2, shine.Position.Y + shine.Height / 2)
                        > Math.Pow(player.HitBox + shine.Height / 2, 2))
                    {
                        if (wpn is WeaponBasic)
                        {
                            projectiles.Add(new ProjectileBasic(graphics, wpn.X, wpn.Y, wpn.Direction, projBTex));
                        }
                        if (wpn is WeaponFlame)
                        {
                            projectiles.Add(new ProjectileFlame(graphics, wpn.X, wpn.Y, wpn.Direction, projFTex));
                        }
                        if (wpn is WeaponLazer)
                        {
                            projectiles.Add(new ProjectileLazer(graphics, wpn.X, wpn.Y, wpn.Direction, projLTex));
                        }

                        wpn.MakeShot = false;
                    }

                    //Collision checking
                    checkForCollisions();

                    //Handle enemy updates and deletes
                    updateLists();

                    //Label updates and normalization
                    label1.Text = "Score: " + (score - score % 1);

                    if (label1.Font.Size > initialL1FontSize)
                    {
                        label1.Font.Size -= 3;
                    }

                    if (label1.Height > initialL1Height)
                    {
                        label1.Height -= 1.8f;
                    }

                    label2.Text = "Health: " + player.Health;

                    if (label2.Font.Size > initialL2FontSize)
                    {
                        label2.Font.Size -= 3;
                    }

                    if (label2.Height > initialL2Height)
                    {
                        label2.Height -= 1.8f;
                    }

                    if (label2.Y < initialL2Y)
                    {
                        label2.Y += 2.4f;
                    }
                }

                //When paused, show more detailed score
                if (paused)
                {
                    label1.Text = "Score: " + (score - score % .01);
                }

                //End of Game Scenario
                if (player.Delete)
                {
                    paused = true;
                    if (score > hiScore)
                    {
                        enterscore  = true;
                        label1.Text = "Final Score: " + (score - score % .01);
                        label2.Text = "You got the High Score! (z) to Enter Initials!";
                        UISystem.SetScene(sceneHiScore, null);
                    }
                    else
                    {
                        died        = true;
                        label1.Text = "Final Score: " + (score - score % .01);
                        label2.Text = "You have died! (z) to Main Menu.";
                    }
                }
            }
        }
Example #28
0
        private static void Initialize()
        {
            graphics = new GraphicsContext();

            //Initialize textures only once for their load
            bossTex  = new Texture2D("Application/Assets/Boss.png", false);
            dumbTex  = new Texture2D("Application/Assets/Fire_Ball.png", false);
            lockTex  = new Texture2D("Application/Assets/Copter.png", false);
            sent1Tex = new Texture2D("Application/Assets/Sentry.png", false);
            sent3Tex = new Texture2D("Application/Assets/sentryexclaimation.png", false);
            projBTex = new Texture2D("Application/Assets/basicproj.png", false);
            projFTex = new Texture2D("Application/Assets/flameproj.png", false);
            projLTex = new Texture2D("Application/Assets/lazerproj.png", false);
            wpnBTex  = new Texture2D("Application/Assets/Pistol.png", false);
            wpnFTex  = new Texture2D("Application/Assets/Flamethrower2.png", false);
            wpnLTex  = new Texture2D("Application/Assets/LaserBeam.png", false);

            rand = new Random();

            //Screens
            startScr      = new Sprite(graphics, new Texture2D("Application/Assets/startscreen.png", false));
            directionsScr = new Sprite(graphics, new Texture2D("Application/Assets/directionsscreen.png", false));
            endScr        = new Sprite(graphics, new Texture2D("Application/Assets/byescreen.png", false));
            highScr       = new Sprite(graphics, new Texture2D("Application/Assets/highscores.png", false));
            enterScr      = new Sprite(graphics, new Texture2D("Application/Assets/enterscorescreen.png", false));

            //Sounds
            Bgm bgm = new Bgm("/Application/Assets/intro.mp3");

            bgmp      = bgm.CreatePlayer();
            bgmp.Loop = true;
            bgmp.Play();

            //Major components
            player      = new Player(graphics);
            wpn         = new WeaponBasic(graphics);
            enemies     = new List <Enemy>();
            projectiles = new List <Projectile>();
            testers     = new List <Sprite>();        //*x for visually testing hitboxes

            //Create portal
            Texture2D t = new Texture2D("Application/Assets/portal.png", false);

            portal            = new Sprite(graphics, t);
            portal.Position.X = (graphics.Screen.Rectangle.Width / 2)
                                - (portal.Width / 2);
            portal.Position.Y = (graphics.Screen.Rectangle.Height / 2)
                                - (portal.Height / 2);

            //Create portal projectile shield
            t                = new Texture2D("Application/Assets/shine.png", false);
            shine            = new Sprite(graphics, t);
            shine.Position.X = (graphics.Screen.Rectangle.Width / 2)
                               - (shine.Width / 2);
            shine.Position.Y = (graphics.Screen.Rectangle.Height / 2)
                               - (shine.Height / 2);

            //PausedScreen sprite setup
            pauseScr = new Sprite(graphics, new Texture2D("Application/Assets/pausedscreen.png", false));
            pauseScr.SetColor(1f, 1f, 1f, .4f);

            //Add Item pickups
            flamethrower            = new Sprite(graphics, wpnFTex);
            flamethrower.Position.X = (graphics.Screen.Rectangle.Width / 3)
                                      - (flamethrower.Width / 2);
            flamethrower.Position.Y = (graphics.Screen.Rectangle.Height / 3)
                                      - (flamethrower.Height / 2);
            flameBox = new Rectangle(flamethrower.Position.X, flamethrower.Position.Y, flamethrower.Width, flamethrower.Height);

            lazer            = new Sprite(graphics, wpnLTex);
            lazer.Position.X = (graphics.Screen.Rectangle.Width * 2 / 3) + rand.Next(-100, 101)
                               - (lazer.Width / 2);
            lazer.Position.Y = (graphics.Screen.Rectangle.Height * 2 / 3) + rand.Next(100, 101)
                               - (lazer.Height / 2);
            lazerBox = new Rectangle(lazer.Position.X, lazer.Position.Y, lazer.Width, lazer.Height);

            //Start clock
            clock = new Stopwatch();
            clock.Start();

            //Initialize UI
            UISystem.Initialize(graphics);
            sceneGame = new Scene();

            label1            = new Label();
            label1.X          = 20;
            label1.Y          = 10;
            label1.Width      = 1000;
            label1.Text       = "Score: " + score;
            initialL1FontSize = label1.Font.Size;
            initialL1Height   = label1.Height;
            label1.TextColor  = new UIColor(1f, .25f, .25f, 1f);
            sceneGame.RootWidget.AddChildLast(label1);

            label2            = new Label();
            label2.X          = 20;
            label2.Y          = graphics.Screen.Height - 40;
            label2.Width      = 800;
            label2.Text       = "Health: " + player.Health;
            initialL2FontSize = label2.Font.Size;
            initialL2Height   = label2.Height;
            initialL2Y        = label2.Y;
            label2.TextColor  = new UIColor(1f, .25f, .25f, 1f);
            sceneGame.RootWidget.AddChildLast(label2);

            sceneScores = new Scene();

            label3         = new Label();
            label3.X       = 333;
            label3.Y       = 400;
            label3.Width   = 600;
            label3.Height += 35;

            try
            {
                StreamReader sr    = new StreamReader("/Documents/highscores.txt");
                string       tempS = sr.ReadLine();
                if (tempS.Length > 0)
                {
                    hiScore     = Double.Parse(tempS.Substring(3));
                    label3.Text = tempS.Substring(0, 3) + ": " + hiScore;
                }
                else
                {
                    label3.Text = "No High Score, Yet!";
                }
                sr.Close();
            }
            catch (FileNotFoundException)
            {
                label3.Text = "File Not Found!";
            }

            label3.Font.Size += 30;
            label3.TextColor  = new UIColor(0f, 0f, 0f, 1f);
            sceneScores.RootWidget.AddChildLast(label3);

            sceneHiScore = new Scene();

            label4            = new Label();
            label4.X          = 550;
            label4.Y          = 400;
            label4.Width      = 500;
            label4.Height    += 18;
            label4.Font.Size += 30;
            label4.Text       = "A";
            label4.TextColor  = new UIColor(0f, 0f, 0f, 1f);
            sceneHiScore.RootWidget.AddChildLast(label4);

            UISystem.SetScene(sceneGame, null);

            //*x tester = new Sprite (graphics, projBTex);
        }
Example #29
0
        // 初期化
        public void Initialize()
        {
            // GameEngine2D 画面クリアー色の設定
            Director.Instance.GL.Context.SetClearColor (Colors.Grey20);

            // 画面解像度情報
            //			ScreenSize = new Vector2i (854, 480);
            ScreenSize = new Vector2i (960, 544);

            // 効果音の設定
            var soundObj = new Sound ("/Application/assets/se.wav");
            Sound = soundObj.CreatePlayer ();

            // BGMの設定
            bgm = new Bgm ("/Application/assets/bgm.mp3");
            player = bgm.CreatePlayer ();
            player.Loop = true; // リピート再生する
            // BGMの再生
            player.Play ();

            // シーン生成(ノードのルートになる)
            var scene = new Sce.PlayStation.HighLevel.GameEngine2D.Scene ();

            // 2Dゲーム向けにカメラを設定
            scene.Camera.SetViewFromViewport ();

            // GameEngine2Dを実行
            Director.Instance.RunWithScene (scene, true);

            Pause = false;

            World = new Node ();
            //	Interface = new Node ();
            // シーンにWorldを追加する
            scene.AddChild (World);
            // シーンにInterface(UIで利用する)を追加する
            //	scene.AddChild (Interface);

            // 背景登録
            for (int y = 0; y < 7; y++) {
                for (int x = 0; x < 6; x++) {
                    var backGround = new BackGround (new Vector2 (x * 192, y * 128));
                    World.AddChild (backGround);
                }
            }

            // 自機(プレイヤー)登録
            Player = new Player (new Vector2 (Game.Instance.ScreenSize.X/2, 100));
            World.AddChild (Player);
            // 敵機(ボス)登録
            Boss = new Boss (new Vector2 (Game.Instance.ScreenSize.X/2, 250));
            World.AddChild (Boss);
            // UI登録
            UI = new UI ();
            //Interface.AddChild (UI);
            scene.AddChild (UI);
            // 当たり判定処理の生成
            HitTest = new HitTest ();
            // 登録キュー
            AddQueue = new List<GameEntity> ();
            // 削除キュー
            RemoveQueue = new List<GameEntity> ();
        }
Example #30
0
        public void setup()
        {
            Camera.SetViewFromViewport();

              Bgm bgm = new Bgm("/Application/assets/sounds/KIDSFUN.mp3");
              BgmPlayer bgmPlayer = bgm.CreatePlayer();
              bgmPlayer.Loop = true;
              bgmPlayer.Play();

              isRaining = false;
              itime = 0;
              rain = new List<SpriteTile>();

              var bg = Support.TiledSpriteFromFile("/Application/assets/Background_Object.png", 1, 1);
              bg.Position = new Vector2((Camera.CalcBounds().Max.X)/2,(Camera.CalcBounds().Max.Y)/2);
              bg.CenterSprite();
              bg.VertexZ = 0;
              this.AddChild(bg,0);

              rng = new Random();

              player = new Player(new Vector2(40,10));
              AddChild(player.sprite);
              Collider.Instance.add(player);

              var fencefront = Support.TiledSpriteFromFile("/Application/assets/Fence_Front.png", 1, 1);
              fencefront.Position = new Vector2((Camera.CalcBounds().Max.X)/2,(Camera.CalcBounds().Min.Y+50)/2);
              fencefront.CenterSprite();
              fencefront.VertexZ = 1;
              this.AddChild(fencefront,0);
              Console.WriteLine(fencefront.Position);

              var goal = new WinSection(new Vector2(Camera.CalcBounds().Max.X-100,Camera.CalcBounds().Max.Y-100));

              Collider.Instance.add(goal);
              goal.startNewGoal();

              var trash = new TrashCan(new Vector2(GameScene.Instance.Camera.CalcBounds().Min.X+90,GameScene.Instance.Camera.CalcBounds().Max.Y-100));
              GameScene.Instance.AddChild(trash.sprite);
              Collider.Instance.add(trash);
        }
Example #31
0
        public static void Initialize()
        {
            //Initializing variables
            graphics     = new GraphicsContext();
            eTex         = new Texture2D("/Application/Assets/enemyship.png", false);
            egreenTex    = new Texture2D("/Application/Assets/enemyshipgreen.png", false);
            eblueTex     = new Texture2D("/Application/Assets/enemyshipblue.png", false);
            pTex         = new Texture2D("/Application/Assets/starshipsmall.png", false);
            mTex         = new Texture2D("/Application/Assets/missle2.png", false);
            lTex         = new Texture2D("/Application/Assets/laser.png", false);
            sTex         = new Texture2D("/Application/Assets/laser.png", false);
            powTex       = new Texture2D("/Application/Assets/powerupspreadsmall.png", false);
            ebTex        = new Texture2D("/Application/Assets/enemybullet.png", false);
            menuTex      = new Texture2D("/Application/Assets/gamestart.png", false);
            backTex      = new Texture2D("/Application/Assets/game1back_2.png", false);
            instTex      = new Texture2D("/Application/Assets/instructions.png", false);
            scoreTex     = new Texture2D("/Application/Assets/highscores.png", false);
            creditsTex   = new Texture2D("/Application/Assets/credits.png", false);
            pauseTex     = new Texture2D("/Application/Assets/pause.png", false);
            deadTex      = new Texture2D("/Application/Assets/dead.png", false);
            running      = true;
            screenheight = graphics.Screen.Height;
            red          = new Vector4(1.0f, 1.0f, 1.0f, 1.0f);
            green        = new Vector4(0.0f, 1.0f, 0.0f, 1.0f);
            blue         = new Vector4(0.0f, 0.0f, 1.0f, 1.0f);
            gen          = new Random();
            timer        = new Stopwatch();
            timer.Start();
            startTime         = 0;
            stopTime          = 0;
            highscores        = new string[5];
            weaponOffset      = new Vector3(50, 10, 0);
            highScoreNums     = new List <int>();
            highScoreNames    = new List <string>();
            currentState      = GameState.Menu;
            menuBackground    = new Background(graphics, menuTex);
            instBackground    = new Background(graphics, instTex);
            scoreBackground   = new Background(graphics, scoreTex);
            creditsBackground = new Background(graphics, creditsTex);
            pauseBackground   = new Background(graphics, pauseTex);
            deadBackground    = new Background(graphics, deadTex);
            menuDisplay       = new MenuDisplay(graphics);
            updateScore       = false;
            updateScoreS      = false;
            alphabet          = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            currentChar       = alphabet[0];
            currentInd        = 0;
            Bgm bgm = new Bgm("/Application/Sounds/gamebgm.mp3");

            bgmplay      = bgm.CreatePlayer();
            bgmplay.Loop = true;
            bgmplay.Play();
            Sound missleSound;

            missleSound = new Sound("/Application/Sounds/misslelaunch.wav");
            missleSP    = missleSound.CreatePlayer();
            Sound explosionSound;
            Sound laserSound;

            explosionSound = new Sound("/Application/Sounds/explosion.wav");
            explosionSP    = explosionSound.CreatePlayer();
            laserSound     = new Sound("/Application/Sounds/se_tan00.wav");
            laserSP        = laserSound.CreatePlayer();
        }
Example #32
0
 public void AudioPlay()
 {
     bgm = new Bgm(OutputDir + "/" + fileName + ".mp3");
     bgmPlayer = bgm.CreatePlayer();
     bgmPlayer.Volume = 1.0F;
     bgmPlayer.Play();
 }
Example #33
0
            public void Play(string name)
            {
                StopAll();

                using (var music = new Bgm(AssetsPrefix + name) )
                {
                    var player = music.CreatePlayer();
                    MusicDatabase[name] = player;
                    MusicDatabase[name].Play();
                    MusicDatabase[name].Loop = true;
                    MusicDatabase[name].Volume = 0.5f;
                }
            }
Example #34
0
 public MP3Player(String path)
 {
     bgm              = new Bgm(path);
     bgmPlayer        = bgm.CreatePlayer();
     bgmPlayer.Volume = 0.2f;
 }
Example #35
0
 /// <summary>
 /// 建立音乐播放器
 /// </summary>
 public void CreatMusicPlayer(Bgm music)
 {
     MusicPlayer = music.CreatePlayer();
     MusicPlayer.Volume = 0;
     MusicPlayer.Loop = musicLoop;
     MusicPlayer.Play();
 }
Example #36
0
        public static void Update()
        {
            // Query gamepad for current state
            var gamePadData          = GamePad.GetData(0);
            List <TouchData> touches = Touch.GetData(0);

            foreach (TouchData data in touches)
            {
                currentTouchStatus = data.Status;
                float xPos = (data.X + 0.5f) * screenWidth;
                float yPos = (data.Y + 0.5f) * screenHeight;
                // Are we presing down on the touchpad?
                if (data.Status == TouchStatus.Down)
                {
                    // Check to see if we are intersecting a flag
                    if (InsideRect(xPos, yPos, scotlandRect))
                    {
                        if (mp3Player.Status == BgmStatus.Playing)
                        {
                            mp3Player.Stop();
                            mp3Player.Dispose();
                        }
                        Bgm scotlandVoice = new Bgm("/Application/sounds/scotlandVoice.mp3");
                        mp3Player = scotlandVoice.CreatePlayer();
                        mp3Player.Play();
                    }
                    if (InsideRect(xPos, yPos, englandRect))
                    {
                        if (mp3Player.Status == BgmStatus.Playing)
                        {
                            mp3Player.Stop();
                            mp3Player.Dispose();
                        }
                        Bgm englandVoice = new Bgm("/Application/sounds/englandVoice.mp3");
                        mp3Player = englandVoice.CreatePlayer();
                        mp3Player.Play();
                    }

                    if (InsideRect(xPos, yPos, n_irelandRect))
                    {
                        if (mp3Player.Status == BgmStatus.Playing)
                        {
                            mp3Player.Stop();
                            mp3Player.Dispose();
                        }
                        Bgm n_irelandVoice = new Bgm("/Application/sounds/n_irelandVoice.mp3");
                        mp3Player = n_irelandVoice.CreatePlayer();
                        mp3Player.Play();
                    }

                    if (InsideRect(xPos, yPos, walesRect))
                    {
                        if (mp3Player.Status == BgmStatus.Playing)
                        {
                            mp3Player.Stop();
                            mp3Player.Dispose();
                        }
                        Bgm walesVoice = new Bgm("/Application/sounds/walesVoice.mp3");
                        mp3Player = walesVoice.CreatePlayer();
                        mp3Player.Play();
                    }
                }

                previousTouchStatus = currentTouchStatus;

                /*
                 * Console.WriteLine("ID "+data.ID);
                 * Console.WriteLine("Status "+data.Status);
                 * Console.WriteLine("Xcoord "+(data.X + 0.5f) * screenWidth);
                 * Console.WriteLine("Ycoord "+(data.Y + 0.5f) * screenHeight);
                 */
            }
        }
Example #37
0
        public static void Initialize()
        {
            clock = new Stopwatch();
            clock.Start();

            backgroundMusic = new Bgm("/Application/assets/music.mp3");
            backgroundPlayer = backgroundMusic.CreatePlayer();
            backgroundPlayer.Loop = true;
            backgroundPlayer.Play();

            presentSound = new Sound("/Application/assets/jinglebell.wav");
            presentSoundPlayer = presentSound.CreatePlayer();

            isPlaying = true;

            // Set up the graphics system
            graphics = new GraphicsContext ();
            gen= new Random();

            NewGame(0);

            currentGameState = GameState.Menu;
            menuDisplay = new MenuDisplay(graphics);
        }
Example #38
0
        /// <summary>
        /// Sets the bgm.
        /// BGMをPlayerにセットする。
        /// BGMプレイヤーは同時に2つ以上存在できない
        /// </summary>
        /// <param name='bgmStr'>
        /// Bgm string.
        /// </param>
        public static void SetBgm(String bgmStr)
        {
            //BGMの初期化。
            EndBgm();
            Bgm = new Bgm(bgmStr);
            BgmPlayer = Bgm.CreatePlayer();
            Bgm.Dispose();
            Bgm=null;
            BgmPlayer.Loop = true;
            BgmOn = true;

            SetBgmMute();
        }
Example #39
0
        public static void Initialize()
        {
            // Set up the graphics system
            graphics = new GraphicsContext ();
            // Background.cs initialization.
            background = new Background(graphics);
            // Fore ground
            foreground = new Foreground (graphics);
            // Create clock from System.Dianogstic
            clock = new Stopwatch();
            clock.Start();

            rand = new Random(); // rand.Next(-100, 230); this will perform random calculation.

            // Music.
            Bgm bgm = new Bgm("/Application/Resources/bgm.mp3");
            // This will create a music based on the music file installed.
            bgmPlayer = bgm.CreatePlayer();
            /* For this lines I experiencing problems is because
             * the sound file I manually import is not working well
             * with PSM sdk. It is there with some standard that will
             * that more time in configuring it.
             * **********************************************************/
            Sound noise=new Sound("/Application/Resources/missile_shot.wav");
            FireShots = noise.CreatePlayer();
            Sound Explode=new Sound("/Application/Resources/explosion.wav");
            Explosion = Explode.CreatePlayer();
            /* Game start with game enumaration transition to states.
             * These lines below must be written after all of the initialization.
             * */
            currentState = GameStates.Menu;
            // New games starts ^^
            NewGame();
            // Menu displays. Only once in initialize.
            Menus = new MenuDisplays(graphics);
        }