Beispiel #1
0
        protected override void Explode()
        {

            if (Config.Level == LevelSelect.Five)
            {
                int rand = Config.Rand.Next(1000);
                if (rand >= Config.timeDropChance)
                {
                    PowerupSlowAll slowAll = new PowerupSlowAll(Config.PowerupSlowAllSpriteSheet);
                    slowAll.Position = this.Position;
                }
            }

            int random = Config.Rand.Next(1000);

            //if (random == 1)
            //{
            //    PowerupHealth health = new PowerupHealth(Config.PowerupHealthSpriteSheet);
            //    health.Position = this.Position;
            //}

            if (random <= Config.shieldDropChance)
            {
                PowerupShields shields = new PowerupShields(Config.PowerupShieldsSpriteSheet);
                shields.Position = this.Position;
            }
            else if (random <= Config.projectileDropChance)
            {
                PowerupAddBullet addProjectile = new PowerupAddBullet(Config.PowerupAddProjectileSpriteSheet);
                addProjectile.Position = this.Position;
            }
            else if (random <= Config.missileDropChance)
            {
                PowerupMissiles Missiles = new PowerupMissiles(Config.PowerupMissileSpriteSheet);
                Missiles.Position = this.Position;
            }
            else if (random <= Config.firerateDropChance)
            {
                PowerupShotSpeed shotSpeed = new PowerupShotSpeed(Config.PowerupProjectileSpeedSpriteSheet);
                shotSpeed.Position = this.Position;
            }
            else if (random <= Config.laserDropChance)
            {
                PowerupLaserDefence laserDefence = new PowerupLaserDefence(Config.PowerupLaserDefenceSpriteSheet);
                laserDefence.Position = this.Position;
            }
            //else if (random >= 19 && random <= 28)

            //else if (random >= 29 && random <= 33)

            //if (random >= 29)
            //{
            //    //if (Config.Level == LevelSelect.Six)
            //    //{
            //        PowerupMissiles Missiles = new PowerupMissiles(Config.PowerupMissileSpriteSheet);
            //        Missiles.Position = this.Position;
            //    //}
            //}

            //else if (random > 20)
            //{
            //    PowerupAddBulletEnemy enemyPowerup = new PowerupAddBulletEnemy(Config.PowerupAddProjectileSpriteSheet);
            //    enemyPowerup.Position = this.Position;
            //}
            //else if (random == 6)
            //{
            //    PowerupDamageAll Lightning = new PowerupDamageAll(Config.PowerupLightningSpriteSheet);
            //    Lightning.Position = this.Position;
            //}

            //else if (random == 3)
            //{
            //    PowerupDoubleShot doubleShot = new PowerupDoubleShot(Config.MissilePowerupSheet);
            //    doubleShot.Position = this.Position;
            //}
            //else if (random == 4)
            //{
            //    PowerupTripleShot tripleShot = new PowerupTripleShot(Config.MissilePowerupSheet);
            //    tripleShot.Position = this.Position;
            //}
            //else if (random == 5)
            //{
            //    PowerupMissiles Missiles = new PowerupMissiles(Config.MissilePowerupSheet);
            //    Missiles.Position = this.Position;
            //}

            base.Explode();
        }
        /// <summary>
        /// Allows the page to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        private void OnUpdate(object sender, GameTimerEventArgs e)
        {
            if (fpscounterOn)
            {
                elapsedTime += e.ElapsedTime;

                if (elapsedTime > TimeSpan.FromSeconds(1))
                {
                    elapsedTime -= TimeSpan.FromSeconds(1);
                    FPS = numOfFrames;
                    numOfFrames = 0;
                }
            }

            VirtualThumbsticks.Update();
            //Player.ProcessInput(_theAccelerometer);
            Player.ProcessInput();

            switch (gameState)
            {
                case GameStates.IntroScreen:
                    //if (Config.Level == LevelSelect.Practise)
                    //{
                    //    if (VirtualThumbsticks.RightThumbstickCenter.HasValue || VirtualThumbsticks.LeftThumbstickCenter.HasValue)
                    //        gameState = GameStates.Playing;
                    //}
                    //else
                    gameState = GameStates.Playing;
                    break;

                case GameStates.Playing:
                    //FloatingScore.Score = "+" + ((int)(25 * Config.Multi)).ToString();
                    Node.UpdateNodes(e.ElapsedTime);
                    Node.RemoveDead();

                    if (Player.Ship != null)
                    {
                        if (boostShieldsUpActive && Player.Ship.Health <= (Config.ShipHealth / 2))
                        {
                            Config.boostShieldsUp--;
                            boostShieldsUpActive = false;

                            PowerupShields shields = new PowerupShields(Config.PowerupShieldsSpriteSheet);
                            shields.Position = Player.Ship.Position;
                        }
                        if (boostLastStandActive && Player.Ship.Health <= (Config.ShipHealth / 5))
                        {
                            Config.boostLastStand--;
                            boostLastStandActive = false;

                            PowerupAddBullet addProjectile = new PowerupAddBullet(Config.PowerupAddProjectileSpriteSheet);
                            addProjectile.Position = Player.Ship.Position;

                            PowerupShotSpeed shotSpeed = new PowerupShotSpeed(Config.PowerupProjectileSpeedSpriteSheet);
                            shotSpeed.Position = Player.Ship.Position;

                            PowerupLaserDefence laserDefence = new PowerupLaserDefence(Config.PowerupLaserDefenceSpriteSheet);
                            laserDefence.Position = Player.Ship.Position;
                        }
                    }

                    if (Config.Level == LevelSelect.Six)
                    {
                        if (Config.KillStreakBuildpoints >= 400)
                        {
                            playerAbilityUses += 1;
                            Config.KillStreakBuildpoints = Config.KillStreakBuildpoints - 400;
                        }
                        KillStreakBar.Percent = Config.KillStreakBuildpoints / 400;
                    }
                    else
                    {
                        if (Config.KillStreakBuildpoints >= 200)
                        {
                            playerAbilityUses += 1;
                            Config.KillStreakBuildpoints = Config.KillStreakBuildpoints - 200;
                        }
                        KillStreakBar.Percent = Config.KillStreakBuildpoints / 200;
                    }

                    switch (Config.Level)
                    {
                        case LevelSelect.One:
                            break;
                        case LevelSelect.Two:
                            levelTime -=  e.ElapsedTime.TotalSeconds;
                            levelTimeSpan = TimeSpan.FromSeconds(levelTime);
                            levelTimeText = string.Format("{0:D2}m:{1:D2}s", levelTimeSpan.Minutes, levelTimeSpan.Seconds);
                            if (levelTime <= 0d)
                                gameState = GameStates.GameOver;
                            break;
                        case LevelSelect.Three:
                            break;
                        case LevelSelect.Four:
                            levelTime -= e.ElapsedTime.TotalSeconds;
                            levelTimeSpan = TimeSpan.FromSeconds(levelTime);
                            levelTimeText = string.Format("{0:D2}m:{1:D2}s", levelTimeSpan.Minutes, levelTimeSpan.Seconds);
                            if (levelTime <= 0d)
                                gameState = GameStates.GameOver;
                            break;
                        case LevelSelect.Five:
                            levelTime -= e.ElapsedTime.TotalSeconds;
                            levelTimeSpan = TimeSpan.FromSeconds(levelTime);
                            levelTimeText = string.Format("{0:D2}m:{1:D2}s", levelTimeSpan.Minutes, levelTimeSpan.Seconds);
                            if (levelTime <= 0d)
                                gameState = GameStates.GameOver;
                            break;
                        case LevelSelect.Six:
                            break;
                        case LevelSelect.Practise:
                            break;
                    }

                    switch (Config.Level)
                    {
                        case LevelSelect.One:
                            level1.Update(e.ElapsedTime);
                            break;
                        case LevelSelect.Two:
                            level2.Update(e.ElapsedTime);
                            break;
                        case LevelSelect.Three:
                            level3.Update(e.ElapsedTime);
                            if ((int)Config.Score - (int)Config.AIScore >= 0)
                            {
                                AlterEgoScoreColor = Color.Green;
                                AlterEgoScoreText = "+" + ((int)Config.Score - (int)Config.AIScore).ToString();
                            }
                            else
                            {
                                AlterEgoScoreColor = Color.Red;
                                AlterEgoScoreText = ((int)Config.Score - (int)Config.AIScore).ToString();
                            }
                            break;
                        case LevelSelect.Four:
                            level4.Update(e.ElapsedTime);
                            if ((int)Config.Score - (int)Config.AIScore >= 0)
                            {
                                AlterEgoScoreColor = Color.Green;
                                AlterEgoScoreText = "+" + ((int)Config.Score - (int)Config.AIScore).ToString();
                            }
                            else
                            {
                                AlterEgoScoreColor = Color.Red;
                                AlterEgoScoreText = ((int)Config.Score - (int)Config.AIScore).ToString();
                            }
                            break;
                        case LevelSelect.Five:
                            level5.Update(e.ElapsedTime);
                            break;
                        case LevelSelect.Six:
                            level6.Update(e.ElapsedTime);
                            break;
                        case LevelSelect.Practise:
                            practise.Update(e.ElapsedTime);
                            break;
                    }

                    if (Player.Ship == null)
                        gameState = GameStates.PlayerDead;
                    break;

                case GameStates.PlayerDead:
                    if (playerLives > 1)
                    {
                        if (Player.Ship == null)
                        {
                            //if (Player.EnemyPlayer != null)
                            //    cam.Pos = Player.EnemyPlayer.Position;

                            switch (Config.Level)
                            {
                                case LevelSelect.Three:
                                    Node.UpdateNodes(e.ElapsedTime);
                                    Node.RemoveDead();
                                    level3.Update(e.ElapsedTime);
                                    if ((int)Config.Score - (int)Config.AIScore >= 0)
                                    {
                                        AlterEgoScoreColor = Color.Green;
                                        AlterEgoScoreText = "+" + ((int)Config.Score - (int)Config.AIScore).ToString();
                                    }
                                    else
                                    {
                                        AlterEgoScoreColor = Color.Red;
                                        AlterEgoScoreText = ((int)Config.Score - (int)Config.AIScore).ToString();
                                    }
                                    break;
                                case LevelSelect.Four:
                                    Node.UpdateNodes(e.ElapsedTime);
                                    Node.RemoveDead();
                                    level4.Update(e.ElapsedTime);
                                    if ((int)Config.Score - (int)Config.AIScore >= 0)
                                    {
                                        AlterEgoScoreColor = Color.Green;
                                        AlterEgoScoreText = "+" + ((int)Config.Score - (int)Config.AIScore).ToString();
                                    }
                                    else
                                    {
                                        AlterEgoScoreColor = Color.Red;
                                        AlterEgoScoreText = ((int)Config.Score - (int)Config.AIScore).ToString();
                                    }
                                    break;
                            }

                            respawnTime -= TimeSpan.FromSeconds(e.ElapsedTime.TotalSeconds);
                            if (respawnTime <= TimeSpan.FromSeconds(0))
                            {
                                Player.SpawnShip();
                                gameState = GameStates.Playing;
                                playerLives--;
                                respawnTime = TimeSpan.FromSeconds(5);
                            }
                            //if (VirtualThumbsticks.RightThumbstickCenter.HasValue)
                            //{
                            //    Player.SpawnShip();
                            //    gameState = GameStates.Playing;
                            //    playerLives--;
                            //    //gameState = GameStates.Playing;
                            //}
                        }
                    }
                    else
                        gameState = GameStates.GameOver;
                    break;

                case GameStates.GameOver:

                    gameState = GameStates.Exiting;

                    Config.Coins += Config.CoinsCollected;

                    switch (Config.Level)
                    {
                        case LevelSelect.One:
                            Config.RampageScores.Add((float)(Math.Round(Config.Score - Config.AIScore)));
                            Config.RampageScores.Sort();
                            Config.RampageScores.Reverse();
                            while (Config.RampageScores.Count > 6) Config.RampageScores.RemoveAt(Config.RampageScores.Count - 1);
                            Config.RampageScores.Capacity = Config.RampageScores.Count;
                            Config.RampageScores.TrimExcess();


                            //ScreenManager.SubmitScore((float)(Math.Round(Config.Score - Config.AIScore)), 1);
                            //SKApplication.Instance.GameManager.SinglePlayerTools.EndPractice((int)(Math.Round(Config.Score - Config.AIScore)), 0, null);

                            SKApplication.Instance.GameManager.ReportScore("Rampage", (float)(Math.Round(Config.Score - Config.AIScore)), new SKListener<SKReportScoreResponse>(OnSuccess, OnFailure));
                            if (MainPage.tournamentId != null && MainPage.tournamentGameId != null)
                            {
                                //MainPage.myGame.GameManager.SinglePlayerTools.EndTournamentGame(MainPage.tourId, MainPage.tourGameId, (int)(Math.Round(Config.Score - Config.AIScore)), 0, null);
                                SKApplication.Instance.GameManager.SinglePlayerTools.EndTournamentGame(MainPage.tournamentId, MainPage.tournamentGameId, (int)(Math.Round(Config.Score - Config.AIScore)), 0, new SKListener<SKEndTournamentGameResponse>(OnTournamentEndSuccess, OnTournamentEndFailure));
                                MainPage.tournamentId = null;
                                MainPage.tournamentGameId = null;
                            }

                            //SKApplication.Instance.GameManager.UnlockAchievement("10211", new SKListener<SKStatusResponse>(OnAchievementUnlockSuccess, OnAchievementUnlockFailure));
                            if ((int)(Math.Round(Config.Score - Config.AIScore)) >= 5000)
                            {
                                //MainPage.myGame.GameManager.UnlockAchievement(10139, null);
                                SKApplication.Instance.GameManager.UnlockAchievement("10139", new SKListener<SKStatusResponse>(OnAchievementUnlockSuccess, OnAchievementUnlockFailure));
                            }
                            break;
                        case LevelSelect.Two:
                            //timeBonus = 1 + ((300 - levelTime) / 300);
                            //tempScore = (Config.Score - Config.AIScore);
                            //tempScore = tempScore * timeBonus;

                            Config.RampageTimedScores.Add((float)(Math.Round(Config.Score - Config.AIScore)));
                            Config.RampageTimedScores.Sort();
                            Config.RampageTimedScores.Reverse();
                            while (Config.RampageTimedScores.Count > 6) Config.RampageTimedScores.RemoveAt(Config.RampageTimedScores.Count - 1);
                            Config.RampageTimedScores.Capacity = Config.RampageTimedScores.Count;
                            Config.RampageTimedScores.TrimExcess();
                            //ScreenManager.SubmitScore((float)(Math.Round(Config.Score - Config.AIScore)), 2);

                            SKApplication.Instance.GameManager.ReportScore("RampageTimed", (float)(Math.Round(Config.Score - Config.AIScore)), new SKListener<SKReportScoreResponse>(OnSuccess, OnFailure));
                            break;
                        case LevelSelect.Three:
                            Config.AlterEgoScores.Add((float)(Math.Round(Config.Score - Config.AIScore)));
                            Config.AlterEgoScores.Sort();
                            Config.AlterEgoScores.Reverse();
                            while (Config.AlterEgoScores.Count > 6) Config.AlterEgoScores.RemoveAt(Config.AlterEgoScores.Count - 1);
                            Config.AlterEgoScores.Capacity = Config.AlterEgoScores.Count;
                            Config.AlterEgoScores.TrimExcess();
                            //ScreenManager.SubmitScore((float)(Math.Round(Config.Score - Config.AIScore)), 3);
                            SKApplication.Instance.GameManager.ReportScore("AlterEgo", (float)(Math.Round(Config.Score - Config.AIScore)), new SKListener<SKReportScoreResponse>(OnSuccess, OnFailure));
                            break;
                        case LevelSelect.Four:
                            //timeBonus = 1 + ((300 - levelTime) / 300);
                            //tempScore = (Config.Score - Config.AIScore);
                            //tempScore = tempScore * timeBonus;
                            Config.AlterEgoTimedScores.Add((float)(Math.Round(Config.Score - Config.AIScore)));
                            Config.AlterEgoTimedScores.Sort();
                            Config.AlterEgoTimedScores.Reverse();
                            while (Config.AlterEgoTimedScores.Count > 6) Config.AlterEgoTimedScores.RemoveAt(Config.AlterEgoTimedScores.Count - 1);
                            Config.AlterEgoTimedScores.Capacity = Config.AlterEgoTimedScores.Count;
                            Config.AlterEgoTimedScores.TrimExcess();
                            //ScreenManager.SubmitScore((float)(Math.Round(Config.Score - Config.AIScore)), 4);
                            SKApplication.Instance.GameManager.ReportScore("AlterEgoTimed", (float)(Math.Round(Config.Score - Config.AIScore)), new SKListener<SKReportScoreResponse>(OnSuccess, OnFailure));
                            break;
                        case LevelSelect.Five:
                            Config.TimeBanditScores.Add((float)(Math.Round(Config.Score - Config.AIScore)));
                            Config.TimeBanditScores.Sort();
                            Config.TimeBanditScores.Reverse();
                            while (Config.TimeBanditScores.Count > 6) Config.TimeBanditScores.RemoveAt(Config.TimeBanditScores.Count - 1);
                            Config.TimeBanditScores.Capacity = Config.TimeBanditScores.Count;
                            Config.TimeBanditScores.TrimExcess();
                            //ScreenManager.SubmitScore((float)(Math.Round(Config.Score - Config.AIScore)), 5);
                            SKApplication.Instance.GameManager.ReportScore("TimeBandit", (float)(Math.Round(Config.Score - Config.AIScore)), new SKListener<SKReportScoreResponse>(OnSuccess, OnFailure));
                            break;
                        case LevelSelect.Six:
                            Config.ExterminationScores.Add((float)(Math.Round(Config.Score - Config.AIScore)));
                            Config.ExterminationScores.Sort();
                            Config.ExterminationScores.Reverse();
                            while (Config.ExterminationScores.Count > 6) Config.ExterminationScores.RemoveAt(Config.ExterminationScores.Count - 1);
                            Config.ExterminationScores.Capacity = Config.ExterminationScores.Count;
                            Config.ExterminationScores.TrimExcess();
                            //ScreenManager.SubmitScore((float)(Math.Round(Config.Score - Config.AIScore)), 6);
                            SKApplication.Instance.GameManager.ReportScore("Extermination", (float)(Math.Round(Config.Score - Config.AIScore)), new SKListener<SKReportScoreResponse>(OnSuccess, OnFailure));
                            break;
                        case LevelSelect.Practise:
                            break;
                    }



                    //ExitScreen();
                    //LoadingScreen.Load(ScreenManager, true, ControllingPlayer, new BackgroundScreen(), new PhoneScoreScreen());

                    //LoadingScreen.Load(ScreenManager, true, ControllingPlayer, new BackgroundScreen(), new MainMenuScreen());

                    //XLiveScoreForm form = new XLiveScoreForm(XLiveFormFactory.FormManager);
                    //form.FormResultEvent += new EventHandler<ScoreFormResultEventArgs>(form_FormResultEvent);

                    //switch (Config.Level)
                    //{
                    //    case LevelSelect.One:
                    //        form.Show("b6d0140f-fb1d-4cbc-bdb3-6540d5930093", (float)(Math.Round(Config.Score - Config.AIScore)));
                    //        break;
                    //    case LevelSelect.Two:
                    //        form.Show("847c1918-bef5-4394-8109-813678e6f320", (float)(Math.Round(Config.Score - Config.AIScore)));
                    //        break;
                    //    case LevelSelect.Three:
                    //        form.Show("75cc6984-c761-4fa3-9dba-98b9723dc81a", (float)(Math.Round(Config.Score - Config.AIScore)));
                    //        break;
                    //    case LevelSelect.Four:
                    //        form.Show("0ad81324-2712-4256-966e-8c6dfd1217ff", (float)(Math.Round(Config.Score - Config.AIScore)));
                    //        break;
                    //    case LevelSelect.Five:
                    //        form.Show("d4a9829a-277c-433d-8de4-2d846235cca6", (float)(Math.Round(Config.Score - Config.AIScore)));
                    //        break;
                    //    case LevelSelect.Six:
                    //        form.Show("27b9af22-239c-4613-9c37-069d23826981", (float)(Math.Round(Config.Score - Config.AIScore)));
                    //        break;
                    //    case LevelSelect.Practise:
                    //        break;
                    //}
                    break;

                case GameStates.Exiting:
                    NavigationService.Navigate(new Uri("/ScoreScreen.xaml", UriKind.Relative));
                    break;
            }



            cameraTransform = cam.get_transformation(SharedGraphicsDeviceManager.Current.GraphicsDevice, 1f);

            //if (Player.EnemyPlayer != null)
            //    cam.Pos = Player.EnemyPlayer.Position;
            if (Player.Ship != null)
                cam.Pos = Player.Ship.Position;
            //else if (Player.EnemyPlayer != null)
            //    cam.Pos = Player.EnemyPlayer.Position;
            ////testing remove ***********************************************
            //else if (bud != null)
            //    cam.Pos = bud.Position;
            ////*************************************************************

            //View = new Rectangle((int)cam._pos.X - 400, (int)cam._pos.Y - 240, 800, 480);

            ParticleEffects.Update(e.ElapsedTime, cam, ref cameraTransform);
            Timer.Update(e.ElapsedTime);
            //Player.ProcessInput();
            //VirtualThumbsticks.Update();

            //bud.Update(gameTime);

            //MemoryMonitor.Update();

            FloatingScoreList.UpdateAllAnimatedPositions(e.ElapsedTime);
            //FloatingScore.UpdateAnimatedPosition(gameTime);
            FloatingPowerupText.UpdateAnimatedPosition(e.ElapsedTime);
            FloatingMultiplierText.UpdateAnimatedPosition(e.ElapsedTime);


            multiHud.Frame = (int)((Config.Multi % 1) * 10);
            //multi = (Math.Round(Config.Multi, 2)).ToString() + "x";
            multi = ((int)Config.Multi).ToString() + "x";

            if ((int)Config.Multi == multiplierTracker)
            {
                multiplierTracker++;
                FloatingMultiplierText.Score = ("Multiplier: " + ((int)Config.Multi).ToString() + "x");
                FloatingMultiplierText.StartPosition = new Vector2(400, 240);
                FloatingMultiplierText.Alive = true;
                FloatingMultiplierText.LifeSpan = 1500;
            }

            AImultiHud.Frame = (int)((Config.AIMulti % 1) * 10);
            //multi = (Math.Round(Config.Multi, 2)).ToString() + "x";
            AImulti = ((int)Config.AIMulti).ToString() + "x";

            if (Player.Ship != null)
            {
                laserCharges = Player.Ship.laserDefence.ToString();
            }


            if (Player.Ship != null)
            {
                healthHud.Frame = (int)Math.Round(((float)Player.Ship.Health / Config.ShipHealth) * 10) % 10;
                shieldHud.Frame = (int)Math.Round(((float)Player.Ship.Shield.Health / Config.ShieldHealth) * 10) % 10;
                if (Player.Ship.Health > 0)
                    healthHud.Color = Color.Red;
                else
                    healthHud.Color = Color.Transparent;
                if (Player.Ship.Shield.Health > 0)
                    shieldHud.Color = Color.RoyalBlue;
                else
                    shieldHud.Color = Color.Transparent;
            }

            if (Player.EnemyPlayer != null)
            {
                AIHealthHud.Frame = (int)Math.Round(((float)Player.EnemyPlayer.Health / Config.ShipHealth) * 10) % 10;
                AIShieldHud.Frame = (int)Math.Round(((float)Player.EnemyPlayer.Shield.Health / Config.ShieldHealth) * 10) % 10;
                if (Player.EnemyPlayer.Health > 0)
                    AIHealthHud.Color = Color.Red;
                else
                    AIHealthHud.Color = Color.Transparent;
                if (Player.EnemyPlayer.Shield.Health > 0)
                    AIShieldHud.Color = Color.RoyalBlue;
                else
                    AIShieldHud.Color = Color.Transparent;
            }
            else
            {
                AIShieldHud.Color = Color.Transparent;
                AIHealthHud.Color = Color.Transparent;
            }

            if (Player.Ship != null)
            {
                healthText = String.Format("{0}", Player.Ship.Health);
                shieldText = String.Format("{0}", Player.Ship.Shield.Health);
            }
            else
            {
                healthText = String.Format("<>");
                shieldText = String.Format("<>");
            }

            if (Player.EnemyPlayer != null)
            {
                enemyHealthText = String.Format("{0}", Player.EnemyPlayer.Health);
                enemyShieldText = String.Format("{0}", Player.EnemyPlayer.Shield.Health);
            }
            else
            {
                enemyHealthText = String.Format("<>");
                enemyShieldText = String.Format("<>");
            }
        }