예제 #1
0
        private void ConsumePlaceGains(Position newPlayerPosition)
        {
            foreach (var place in allPlaces)
            {
                if (place.Position.Row == newPlayerPosition.Row &&
                    place.Position.Col == newPlayerPosition.Col)
                {
                    if (!place.IsVisited)
                    {
                        var    gain      = place.Gain;
                        var    gainType  = string.Empty;
                        double gainValue = place.Value;

                        switch (gain)
                        {
                        case Place.PlaceGain.Health:

                            if (this.player.Health + place.Value <= Player.MaxHealth)
                            {
                                this.player.Health += place.Value;
                            }
                            else
                            {
                                gainValue          = Player.MaxHealth - this.player.Health;
                                this.player.Health = Player.MaxHealth;
                            }

                            gainType = Enum.GetName(typeof(Place.PlaceGain), Place.PlaceGain.Health);
                            break;

                        case Place.PlaceGain.Armor:
                            this.player.Defense += place.Value;
                            gainType             = Enum.GetName(typeof(Place.PlaceGain), Place.PlaceGain.Armor);
                            break;

                        case Place.PlaceGain.Experience:
/*                                this.player.Experience += place.Value;*/
                            this.player.GainGoldAndExperience(place.Value, 0);
                            gainType = Enum.GetName(typeof(Place.PlaceGain), Place.PlaceGain.Experience);
                            break;

                        case Place.PlaceGain.Gold:
/*                                this.player.Gold += place.Value;*/
                            this.player.GainGoldAndExperience(0, place.Value);
                            gainType = Enum.GetName(typeof(Place.PlaceGain), Place.PlaceGain.Gold);
                            break;
                        }

                        Visualisator.PrintUnderTheBattleField(VisualisatorConstants.PlaceGainConsumed + place.Type + " " + gainValue + " " + gainType);
                        place.IsVisited = true;
                    }
                    else
                    {
                        Visualisator.PrintUnderTheBattleField(VisualisatorConstants.PlaceAlreadyVisited);
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Open door to the boss and goes to next level.
        /// </summary>
        /// <param name="newPlayerPosition"></param>
        private void TryOpenDoor(Position newPlayerPosition)
        {
            if (allEnemies.Count <= 1)
            {
                PlaceThePlayerOnHisNewPosition(newPlayerPosition);
            }
            else
            {
                Visualisator.PrintUnderTheBattleField(VisualisatorConstants.UnableToCompleteLevel);
            }

            //dinamichno vzemane na levela za zavurshvane na nivoto.

/*            if (player.Level >= 6)
 *          {
 *              PlaceThePlayerOnHisNewPosition(newPlayerPosition);
 *          }
 *          else
 *          {
 *              //print message why can't open the door.
 *          }*/
        }
예제 #3
0
        private void GenerateAndVisitSphinx(Position sphinxPosition)
        {
            if (sphinx == null)
            {
                this.sphinx = new Sphinx(sphinxPosition,
                                         SphinxConstants.BonusGold * levelGenerator.CurrentLevelNumber,
                                         SphinxConstants.MinusHealth * levelGenerator.CurrentLevelNumber);
            }
            if (sphinx.IsVisited)
            {
                Visualisator.PrintUnderTheBattleField(VisualisatorConstants.SphinxIsVisited);
                return;
            }
            var riddle = new Riddle();

            riddle.LoadQuestion();
            bool IsTheAnswerCorrect = riddle.IsItRight();

            sphinx.IsVisited = true;
            if (IsTheAnswerCorrect)
            {
                player.Gold += sphinx.BonusGold;
            }
            else
            {
                if (player.Health <= sphinx.MinusHealth)
                {
                    player.Health = 1;
                }
                else
                {
                    player.Health -= sphinx.MinusHealth;
                }
            }
            Visualisator.PrintAllMap(dungeon, player);
        }