Esempio n. 1
0
        private static List<string> HeroMove(List<string> oldMap, int[] oldPosition, int[] newPosition, string command, Hero hero) // moving method
        {
            char[] tempMapOldLine = oldMap[oldPosition[0] - 1].ToCharArray();
            char[] tempMapNewLine = oldMap[newPosition[0] - 1].ToCharArray();
            if (!CheckForWallsInPAth(oldMap, oldPosition,newPosition))
            {
                throw new ArgumentException(ExceptionConstants.WallReachException);
            }
            else
            {

                tempMapOldLine[oldPosition[1] - 1] = specSymbol;
                oldMap[oldPosition[0] - 1] = new string(tempMapOldLine);
                int temp = SpecialSymbolReach(tempMapNewLine[newPosition[1] - 1], command, hero);
                if (temp == 0) specSymbol = tempMapNewLine[newPosition[1] - 1];
                tempMapNewLine = oldMap[newPosition[0] - 1].ToCharArray();
                tempMapNewLine[newPosition[1] - 1] = heroSymbol;
                oldMap[newPosition[0] - 1] = new string(tempMapNewLine);
                return oldMap;
            }
        }
Esempio n. 2
0
 private static int SpecialSymbolReach(char symbol, string command, Hero hero)// special symbols what to do when you find one
 {
     switch (symbol)
     {
         case chestSymbol:
             DrawScreen.AddLineToBuffer(ref DrawScreen.area2, string.Format(ExceptionConstants.SomethingHappen, "chest", "try to open it"));
             
             Random rnd = new Random();
             if (rnd.Next(1, 3) == 1)
             {
                 string[] recievedGold = core.LootGoldChest().Split(' ');
                 DrawScreen.AddLineToBuffer(ref DrawScreen.area2,
                     string.Format(ExceptionConstants.SomethingHappen, "gold chest", "recieved " + recievedGold[0] + " gold and " + recievedGold[1] + " exp" ));
             }
             else
             {
                 try
                 {
                     var item = core.LootRandomItem();
                     DrawScreen.AddLineToBuffer(ref DrawScreen.area2,
                     string.Format(ExceptionConstants.SomethingHappen, "item chest", "recieved " + item.Id));
                 }
                 catch (ArgumentException e)
                 {
                     DrawScreen.AddLineToBuffer(ref DrawScreen.area2, e.Message);
                 }
                     
             }
             if (command == "up" || command == "down") specSymbol = '║';
             else specSymbol = '═';
             return 1;
         case monsterSymbol:
             DrawScreen.AddLineToBuffer(ref DrawScreen.area2, string.Format(ExceptionConstants.SomethingHappen, "monster", "start fighting"));
             if (command == "up" || command == "down") specSymbol = '║';
             else specSymbol = '═';
             BattleScreen battle = new BattleScreen(core, 0);
             battle.StartBattle();
             return 2;
         case bossSymbol:
             DrawScreen.AddLineToBuffer(ref DrawScreen.area2, string.Format(ExceptionConstants.SomethingHappen, "Boss", "start fighting"));
             if (command == "up" || command == "down") specSymbol = '║';
             else specSymbol = '═';
             BattleScreen bossBattle = new BattleScreen(core, 1);
             bossBattle.StartBattle();
             DrawScreen.AddLineToBuffer(ref DrawScreen.area2, Environment.NewLine);
             DrawScreen.AddLineToBuffer(ref DrawScreen.area2, "YOU HAVE WON THE GAME !! CONGRATZ !!");
             DrawScreen.AddLineToBuffer(ref DrawScreen.area2, Environment.NewLine);
             DrawScreen.drawScreen(Info(), DrawScreen.area2);
             Environment.Exit(0);
             return 3;
         default:
             return 0;
     }
 }
Esempio n. 3
0
 private void FillArea(Hero hero, IMonster monster)
 {
     DrawScreen.AddLineToBuffer(ref battleArea1, Environment.NewLine);
     DrawScreen.AddLineToBuffer(ref battleArea1,
         " ".PadLeft(4, ' ') + hero.Name.PadRight(50, ' ') + monster.ToString());
     DrawScreen.AddLineToBuffer(ref battleArea1,
         " ".PadLeft(4, ' ') + ("Damage " + hero.DamageMin + " - " + hero.DamageMax).PadRight(50, ' ') + "Damage " + monster.DamageMin + " - " + monster.DamageMax);
     DrawScreen.AddLineToBuffer(ref battleArea1,
         " ".PadLeft(4, ' ') + ("HP: " + hero.Health).PadRight(50, ' ') + "HP: " + monster.Health);
     DrawScreen.AddLineToBuffer(ref battleArea1,
         " ".PadLeft(4, ' ') + ("LVL: " + hero.Level).PadRight(50, ' ') + "LVL: " + monster.Level);
     for (int i = 0; i < 2; i++)
     {
         DrawScreen.AddLineToBuffer(ref battleArea1, Environment.NewLine);
     }
     DrawScreen.AddLineToBuffer(ref battleArea1, new string('-', 90));
 }
Esempio n. 4
0
 private void ScreenUpdate(Hero hero, IMonster monster)
 {
     this.FillArea(hero, monster);
     this.CommandsShow();
     this.CombineArea();
 }
Esempio n. 5
0
 private void UpdateHpBar(Hero hero, IMonster monster)
 {
     var i = battleArea1.FindIndex(x => x.Contains("HP:"));
     battleArea1[i] = " ".PadLeft(4, ' ') + ("HP: " + hero.Health).PadRight(50, ' ') + "HP: " + monster.Health;
 }
Esempio n. 6
0
 private int MonsterHit(Hero hero, int damage)
 {
     hero.Health -= damage - (hero.Armor * hero.ArmorRed);
     if (hero.Health < 0) hero.Health = 0;
     return damage;
 }