Beispiel #1
0
 public QuestionScreen(string msg, GameplayScreen caller, HeadsUpDisplay HUD,
     Player p1)
 {
     parent = caller;
     player = p1;
     hud = HUD;
     string question = RandomGenerator.RandomQuestion( parent.CurrentScore,
                                           out correctAnswer, out answers);
     lifeSpan = 240;
     questionMessage = msg + "\n" + question;
     answerMessage = "\n" + answers[0].ToString().PadLeft(8) + "\n" +
               answers[1] + answers[2].ToString().PadLeft(12) + "\n" +
                            answers[3].ToString().PadLeft(8);
     timeMessage = "\nTime Left: " + lifeSpan;
     message = questionMessage + answerMessage + timeMessage + usageText;
     IsPopup = true;
     TransitionOnTime = TimeSpan.FromSeconds(0.1);
     TransitionOffTime = TimeSpan.Zero;
 }
Beispiel #2
0
        private void GameplayInit(bool isNewGame)
        {
            GameWindow window = ScreenManager.Game.Window;

            healthList = new List<Health>();
            shieldList = new List<Shield>();
            enemyList = new List<Enemy>();
            bossList = new List<Boss>();
            defaultBulletList = new List<Bullet>();
            enemyTexList = new List<Texture2D>();
            bossTexList = new List<Texture2D>();
            bulletTexList = new List<Texture2D>();
            windowSize = new Vector2(window.ClientBounds.Width, window.ClientBounds.Height);
            initialPlayerPosition = new Vector2(windowSize.X / 2, windowSize.Y - 60);
            playerVelocity = new Vector2(6, 6);
            // TODO: determine game mode: single or versus. Use single for now.
            singleMode = true;
            numPlayers = singleMode ? 1 : 2;
            numMoveStrategies = 3;
            numEnemies = 5;
            previousFireTime = TimeSpan.Zero;
            defaultBulletFireRate = TimeSpan.FromSeconds(.15f);

            gameData = FileIO.DeserializeFromXML();
            if(gameData == null)
            {
                string uname = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
                if(uname.Contains(@"\"))
                {
                    string[] nameArry = uname.Split('\\');
                    uname = nameArry[nameArry.Length - 1];
                }
                gameData = new GameData(uname);
                player1CurrentHealth = 100;
                player1CurrentScore = 0;
                FileIO.SerializeToXML(gameData);
            }
            else
            {
                if(isNewGame || gameData.LastGameDied)
                {
                    gameData.CurrentScore = 0;
                    player1CurrentScore = 0;
                    gameData.CurrentHealth = 100;
                    player1CurrentHealth = 100;
                    gameData.LastGameDied = false;
                    FileIO.SerializeToXML(gameData);
                }
                else
                {
                    player1CurrentHealth = gameData.CurrentHealth;
                    player1CurrentScore = gameData.CurrentScore;
                }
            }
            hud = new HeadsUpDisplay(new Vector2(windowSize.X / 2 - 200, 20));
        }