private void RemoveTutorial()
 {
     RemoveEntity(tutorialEntity);
     tutorialEntity = null;
 }
Esempio n. 2
0
 private void ShowTutorial()
 {
     if (GlobalVariables.CurrentLevel == 1 && GlobalVariables.CurrentDrive == 1)
     {
         tutorialEntity = new TutorialEntity(new Color(150, 255, 130), RemoveTutorial);
         AddEntity(tutorialEntity);
     }
 }
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            GlobalVariables.CheckAchievements();

            if (!levelEnded)
            {
                elapsedTime += gameTime.ElapsedGameTime.TotalSeconds;
                HUDEntity.TimeScore = (int)elapsedTime;
                HUDEntity.FilesScore = NumberOfDocumentFiles;

                if (CheckLose())
                {
                    levelEnded = true;

                    List<int> scores = new List<int>();
                    scores.Add(GlobalVariables.LevelScore);
                    scores.Add((int)elapsedTime);
                    scores.Add(NumberOfDocumentFiles);

                    GlobalVariables.UpdateSurvivalVariables(scores);

                    CursorEntity.CursorView = CursorType.Normal;
                    SoundManager.ChangeMusicVolume(SoundManager.MIN_VOLUME);

                    List<Button> buttons = new List<Button>();
                    Color color = new Color(150, 255, 130);
                    buttons.Add(new Button(color, "Retry Area", new ButtonPressed(RetryLevel)));
                    buttons.Add(new Button(color, "Return to Armory Console", new ButtonPressed(ReturnToArmoryConsole)));
                    buttons.Add(new Button(color, "Return to Main Console", new ButtonPressed(ReturnToMainMenu)));

                    TitleSubtitleButtonAnnouncerEntity loseTitle = new TitleSubtitleButtonAnnouncerEntity(new AnnouncerEnded(GoToNextWorld),
                        color, "Survival Ends", GetScoreSubtitle() , buttons);

                    AddOverLayer(loseTitle);
                }

                if (Input.CheckKeyboardButton(Keys.Escape) == GameButtonState.Pressed && !pauseGame)
                {
                    PauseGame();
                }

                if (Input.CheckKeyboardButton(Keys.F1) == GameButtonState.Pressed)
                {
                    if (tutorialEntity == null)
                    {
                        tutorialEntity = new TutorialEntity(new Color(150, 255, 130), RemoveTutorial);
                        AddEntity(tutorialEntity);
                    }
                    else
                    {
                        tutorialEntity.FinishTutorial();
                    }
                }

                if (Input.CheckLeftMouseButton() == GameButtonState.Up && Input.CheckRightMouseButton() == GameButtonState.Up)
                {
                    if (CursorEntity.IsShooting)
                    {
                        CursorEntity.IsShooting = false;
                    }
                }
            }
        }
Esempio n. 4
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            GlobalVariables.CheckAchievements();

            if (LevelAlarm != null)
            {
                LevelAlarm.SpeedFactor = OGE.PlayerSlowFactor;
                HUDEntity.SurvivalRemainingTime = (int)Math.Ceiling(LevelAlarm.CurrentSeconds);
            }
            else
            {
                HUDEntity.SurvivalRemainingTime = 0;
            }

            if (!levelEnded)
            {
                if (CheckLose())
                {
                    if (LevelAlarm != null)
                    {
                        LevelAlarm.Pause();
                    }

                    levelEnded = true;

                    CursorEntity.CursorView = CursorType.Normal;
                    SoundManager.ChangeMusicVolume(SoundManager.MIN_VOLUME);

                    List<Button> buttons = new List<Button>();
                    Color color = new Color(255, 180, 180);
                    buttons.Add(new Button(color, "Retry Area", new ButtonPressed(RetryLevel)));
                    if (!levelData.IsSelectedLevel())
                    {
                        buttons.Add(new Button(color, "Return to Armory Console", new ButtonPressed(ReturnToUpgradeMenu)));
                    }
                    else
                    {
                        buttons.Add(new Button(color, "Return to Sector Console", new ButtonPressed(ReturnToLevelSelector)));
                    }
                    buttons.Add(new Button(color, "Return to Main Console", new ButtonPressed(ReturnToMainMenu)));

                    TitleButtonAnnouncerEntity loseTitle = new TitleButtonAnnouncerEntity(new AnnouncerEnded(GoToNextWorld), color,
                        failReason, buttons);

                    AddOverLayer(loseTitle);
                }

                if (CheckWin())
                {
                    levelEnded = true;

                    //Convert the files
                    List<BaseEntity> files = GetCollisionEntitiesType(CollisionType.File);

                    for (int i = 0; i < files.Count; i++)
                    {
                        if (files[i] is ExeFile)
                        {
                            if (!(files[i] as ExeFile).IsInfected)
                            {
                                (files[i] as ExeFile).AddScore();
                                GlobalVariables.Achievements[typeof(ExeFile)].CurrentNumber += 1;
                            }

                            (files[i] as ExeFile).LevelEnded();
                        }

                        if (files[i] is ZipFile)
                        {
                            GlobalVariables.Achievements[typeof(ZipFile)].CurrentNumber += 1;
                        }
                    }

                    TitleTimeAnnouncerEntity winTitle = new TitleTimeAnnouncerEntity(new AnnouncerEnded(GameWin), "Sector Secured");
                    winTitle.TintColor = new Color(150, 255, 130);

                    AddOverLayer(winTitle);
                }

                if (TotalNumberOfZipFiles > 0)
                {
                    List<BaseEntity> zipFiles = GetCollisionEntitiesType(CollisionType.File);
                    List<Vector2> zipPositions = new List<Vector2>();
                    foreach (BaseFile zipFile in zipFiles)
                    {
                        if (zipFile is ZipFile)
                        {
                            zipPositions.Add(zipFile.Position);
                        }
                    }

                    HUDEntity.FileArrowEntity.UpdatePosition(zipPositions);
                }

                if (Input.CheckKeyboardButton(Keys.Escape) == GameButtonState.Pressed && !pauseGame)
                {
                    PauseGame();
                }

                if (Input.CheckKeyboardButton(Keys.F1) == GameButtonState.Pressed)
                {
                    if (tutorialEntity == null)
                    {
                        tutorialEntity = new TutorialEntity(new Color(150, 255, 130), RemoveTutorial);
                        AddEntity(tutorialEntity);
                    }
                    else
                    {
                        tutorialEntity.FinishTutorial();
                    }
                }

                if (Input.CheckLeftMouseButton() == GameButtonState.Up && Input.CheckRightMouseButton() == GameButtonState.Up)
                {
                    if (CursorEntity.IsShooting)
                    {
                        CursorEntity.IsShooting = false;
                    }
                }
            }
        }