public void SetGameLevel_Template(int indexGameLevel) { _indexGameLevelCounter = indexGameLevel; if (!AreAllLevelsExecuted()) { var allIndexLevelsList = Enum.GetValues(typeof(GameLevelsEnum)).Cast <GameLevelsEnum>().ToList(); GameLevelsEnum selectedLevel = allIndexLevelsList[indexGameLevel]; LevelTemplate selectedGameLevel = _gameLevelInvoker.GetLevel(selectedLevel); if (selectedGameLevel == null) { return; } //Potions Visibility and Location var bluePotionLocation = (selectedGameLevel.BluePotionVisibility == Visibility.Visible) ? new System.Drawing.Point(300, 200) : new System.Drawing.Point(400, 350); BluePotionImage = SetSingleImageVisibilityAndLocation(BluePotionImage, bluePotionLocation, selectedGameLevel.BluePotionVisibility); var redPotionLocation = (selectedGameLevel.RedPotionVisibility == Visibility.Visible) ? new System.Drawing.Point(700, 255) : new System.Drawing.Point(400, 400); RedPotionImage = SetSingleImageVisibilityAndLocation(RedPotionImage, redPotionLocation, selectedGameLevel.RedPotionVisibility); //Weapons Visibility and Location var swordWeaponLocation = (selectedGameLevel.SwordVisibility == Visibility.Visible) ? new System.Drawing.Point(700, 300) : new System.Drawing.Point(400, 350); SwordWeaponImage = SetSingleImageVisibilityAndLocation(SwordWeaponImage, swordWeaponLocation, selectedGameLevel.SwordVisibility); var maceWeaponLocation = (selectedGameLevel.MaceVisibility == Visibility.Visible) ? new System.Drawing.Point(350, 350) : new System.Drawing.Point(400, 350); MaceWeaponImage = SetSingleImageVisibilityAndLocation(MaceWeaponImage, maceWeaponLocation, selectedGameLevel.MaceVisibility); var bowAndArrowWeaponLocation = (selectedGameLevel.BowAndArrowVisibility == Visibility.Visible) ? new System.Drawing.Point(500, 150) : new System.Drawing.Point(400, 350); BowAndArrowWeaponImage = SetSingleImageVisibilityAndLocation(BowAndArrowWeaponImage, bowAndArrowWeaponLocation, selectedGameLevel.BowAndArrowVisibility); //shooting Weapons TIMERS SetTimerOnOff(DispatcherTimer_ShootingArrow, selectedGameLevel.ArrowTimer); SetTimerOnOff(DispatcherTimer_EnemyFireball, selectedGameLevel.EnemyFireballTimer); SetTimerOnOff(DispatcherTimer_ControlShootingWeaponsVisibilityState, selectedGameLevel.ShootingWeaponsVisibilityTimer); //Player _player.RemoveEnemy_UnsubscribeAllObservers(); _player.AddEnemy_SubscribeObserver(_bat); _player.AddEnemy_SubscribeObserver(_wizard); _player.SetHealth(selectedGameLevel.HeroPlayerHealthPoints); _player.SetMovementStrategy(selectedGameLevel.HeroPlayerMovementStrategy); _player.AllArrowShootingLeftImages = SetImagesNewLocationAndSetHidden(_player.AllArrowShootingLeftImages, new System.Drawing.Point(700, 250)); _player.AllArrowShootingRightImages = SetImagesNewLocationAndSetHidden(_player.AllArrowShootingRightImages, new System.Drawing.Point(650, 250)); SetTimerOnOff(DispatcherTimer_HeroPlayer, selectedGameLevel.HeroPlayerTimer); //Enemy Bat _bat.EnemyImage.Visibility = selectedGameLevel.BatVisibility; _bat.SetHealth(selectedGameLevel.BatHealthPoints); _bat.SetMovementStrategy(selectedGameLevel.BatMovementStrategy); SetTimerOnOff(DispatcherTimer_Bat, selectedGameLevel.BatTimer); //Enemy Wizard _wizard.EnemyImage.Visibility = selectedGameLevel.WizardVisibility; _wizard.SetHealth(selectedGameLevel.WizardHealthpoints); _wizard.SetMovementStrategy(selectedGameLevel.WizardMovementStrategy); _wizard.AllFireballLeftShootingImages = SetImagesNewLocationAndSetHidden(_wizard.AllFireballLeftShootingImages, new System.Drawing.Point(600, 250)); _wizard.AllFireballRightShootingImages = SetImagesNewLocationAndSetHidden(_wizard.AllFireballRightShootingImages, new System.Drawing.Point(550, 250)); SetTimerOnOff(DispatcherTimer_Wizard, selectedGameLevel.WizardTimer); } }
public LevelTemplate GetLevel(GameLevelsEnum gameLevel) { var selectedLevel = allLevelsTemplates.Where(a => a.GameLevelNumber == gameLevel).FirstOrDefault(); return(selectedLevel); }