コード例 #1
0
ファイル: Drawer.cs プロジェクト: TeamSazeracProject/TheGame
 public void DrawInConsole(VisualElement element, int row, int col)
 {
     for (int r = 0; r < element.ElementMatrix.GetLength(0); r++)
     {
         for (int c = 0; c < element.ElementMatrix.GetLength(1); c++)
         {
             DrawBrick(element.ElementMatrix[r, c], row + r, col + c);
         }
     }
 }
コード例 #2
0
ファイル: NPC.cs プロジェクト: TeamSazerac/TheGame
 public NPC(string Name, VisualElement visualNPC, List<string> conversation)
 {
     if (string.IsNullOrEmpty(Name))
     {
         throw new ArgumentException("Name is empty");
     }
     if (conversation.Count == 0)
     {
         throw new ArgumentException("Conversation is empty");
     }
     this.Name = Name;
     this.visualNPC = visualNPC;
     this.conversation = conversation;
 }
コード例 #3
0
ファイル: Hero.cs プロジェクト: TeamSazerac/TheGame
 public Hero(string Name, Statistics statistics, Weapon weapon, VisualElement visibleHero, string pathToImage)
 {
     if (string.IsNullOrEmpty(Name))
     {
         throw new ArgumentNullException("Name is empty.");
     }
     if (!File.Exists(pathToImage))
     {
         throw new ArgumentException("Could not find the specified file.");
     }
     this.Name = Name;
     this.statistics = statistics;
     this.weapon = weapon;
     this.visibleHero = visibleHero;
     this.pathToImage = pathToImage;
 }
コード例 #4
0
ファイル: Drawer.cs プロジェクト: TeamSazeracProject/TheGame
        public void DrawMatrixInConsole(VisualElement[,] matrix)
        {
            Console.BackgroundColor = ConsoleColor.Black;
            Console.Clear();

            int currentRow = 0, currentCol = 0;
            int stepsPerRow = matrix[0, 0].ElementMatrix.GetLength(0);
            int stepsPerCol = matrix[0, 0].ElementMatrix.GetLength(1);

            for (int r = 0; r < matrix.GetLength(0); r++)
            {
                for (int c = 0; c < matrix.GetLength(1); c++)
                {
                    DrawInConsole(matrix[r, c], currentRow, currentCol);
                    currentCol += stepsPerCol;
                }
                currentRow += stepsPerRow;
                currentCol = 0;
            }
        }
コード例 #5
0
ファイル: Loader.cs プロジェクト: TeamSazeracProject/TheGame
        public VisualElement[,] LoadLevel(VisualElement[,] matrix, Hero hero, List<NPC> emptyNPCList)
        {
            Dangers dangers = new Dangers();
            VisualElements VisualLoader = new VisualElements();
            NPCs npcs = new NPCs();
            emptyNPCList.Clear();
            Levels levels = new Levels();

            string[] level = levels.Level1;
            List<DangerousTerritory> dangersOnThisLevel = dangers.Level1Dangers;
            switch (hero.level)
            {
                case 1: dangersOnThisLevel = dangers.Level1Dangers; level = levels.Level1; break;
                case 2: dangersOnThisLevel = dangers.Level2Dangers; level = levels.Level2; break;
                case 3: dangersOnThisLevel = dangers.Level3Dangers; level = levels.Level3; break;
                default: break;
            }

            for (int r = 0; r < matrix.GetLength(0); r++)
            {
                for (int c = 0; c < matrix.GetLength(1); c++)
                {
                    if (level[r][c].Equals(' '))
                    {
                        matrix[r, c] = VisualLoader.Grass(sizeOfVisualElements);
                    }
                    else if (level[r][c].Equals('/'))
                    {
                        matrix[r, c] = VisualLoader.Grass(1);
                        matrix[r, c].content = dangersOnThisLevel[0]; /// will have 1-st enemy
                    }
                    else if (level[r][c].Equals('.'))
                    {
                        matrix[r, c] = VisualLoader.Desert(sizeOfVisualElements);
                        matrix[r, c].content = dangersOnThisLevel[1]; /// will have 2-nd enemy
                    }
                    else if (level[r][c].Equals('+'))
                    {
                        matrix[r, c] = VisualLoader.Barren(sizeOfVisualElements);
                        matrix[r, c].content = dangersOnThisLevel[2]; /// will have 3-rd enemy
                    }
                    else if (level[r][c].Equals('#'))
                    {
                        matrix[r, c] = VisualLoader.Rock(sizeOfVisualElements);
                    }
                    else if (level[r][c].Equals(':'))
                    {
                        matrix[r, c] = VisualLoader.Grass(sizeOfVisualElements);
                    }
                    else if (level[r][c].Equals('*'))
                    {
                        matrix[r, c] = VisualLoader.Rock(sizeOfVisualElements); /// Will be chest
                    }
                    else if (char.IsDigit(level[r][c]))
                    {
                        matrix[r, c] = VisualLoader.NPC(sizeOfVisualElements); /// will be NPC
                        NPC npc = npcs.npcList[int.Parse((level[r][c]).ToString())];
                        npc.Position = new Position(r, c);
                        emptyNPCList.Add(npc);
                    }
                    else if (level[r][c].Equals('\''))
                    {
                        matrix[r, c] = VisualLoader.Desert(sizeOfVisualElements);
                        matrix[r, c].content = dangersOnThisLevel[3]; /// will be BOSS
                    }
                    else if (level[r][c].Equals('H'))
                    {
                        matrix[r, c] = VisualLoader.Grass(sizeOfVisualElements);

                            if (hero.Position.row == 0 || hero.Position.col == 0)
                            {
                                hero.Position = new Position(r, c);
                            }

                    }
                    else
                    {
                        matrix[r, c] = VisualLoader.Empty(sizeOfVisualElements);
                    }
                }
            }

            return matrix;
        }
コード例 #6
0
ファイル: Loader.cs プロジェクト: TeamSazeracProject/TheGame
        public VisualElement[,] LoadVisibleLevel(VisualElement[,] VisibleMatrix, VisualElement[,] matrix, Hero hero)
        {
            VisualElements VisualLoader = new VisualElements();

            VisibleMatrix[VisibleMatrix.GetLength(0) / 2, VisibleMatrix.GetLength(1) / 2] = VisualLoader.Hero(1);
            for (int r2 = 0; r2 < VisibleMatrix.GetLength(0); r2++)
            {
                for (int c2 = 0; c2 < VisibleMatrix.GetLength(0); c2++)
                {
                    int actualPositionRow = hero.Position.row - VisibleMatrix.GetLength(0) / 2 + r2;
                    int actualPositionCol = hero.Position.col - VisibleMatrix.GetLength(0) / 2 + c2;

                    if (actualPositionRow >= 0 ||
                        actualPositionRow > matrix.GetLength(0) ||
                        actualPositionCol >= 0 ||
                        actualPositionCol > matrix.GetLength(1))
                    {
                        VisibleMatrix[r2, c2] = VisualLoader.Empty(sizeOfVisualElements);
                    }
                    else
                    {
                        VisibleMatrix[r2, c2] = matrix[actualPositionRow, actualPositionCol];
                    }
                }
            }
            return VisibleMatrix;
        }
コード例 #7
0
ファイル: Battle.cs プロジェクト: TeamSazeracProject/TheGame
        public void StartBattle(Hero TheHero,
                                Enemy TheEnemy, 
                                bool BossFight, 
                                VisualElement[,] matrix, 
                                List<NPC> NPCsOfCurrentLevel)
        {
            hero = TheHero;
            enemy = TheEnemy;

            totalHeroHP = hero.Statistics.HitPoints;
            currentHeroHP = totalHeroHP;
            totalEnemyHP = enemy.Statistics.HitPoints;
            currentEnemyHP = totalEnemyHP;
            DrawBattle(hero, enemy);

            while (currentHeroHP > 0 && currentEnemyHP > 0)
            {
                ProcessInput(Console.ReadKey());
                Thread.Sleep(1000);
                DrawBattle(hero, enemy);
                if (escapeSuccessful)
                {
                    break;
                }
                if (currentEnemyHP < 1)
                {
                    break;
                }
                EnemyAttack();
                Thread.Sleep(1000);
                DrawBattle(hero, enemy);

                enemyIsCrippled = false;
            }

            if (currentHeroHP < 1)
            {
                // game over
                TheHero.LevelUp();
                hero.Position = new Position(0, 0);
                Loader load = new Loader();
                NPCsOfCurrentLevel.Clear();
                matrix = load.LoadLevel(matrix, TheHero, NPCsOfCurrentLevel);
            }
            else
            {
                if (BossFight)
                {
                    TheHero.LevelUp();
                    hero.Position = new Position(0, 0);

                    if (TheHero.level > 3)
                    {
                        // Game compleated
                    }

                    MenuChangeWeapon newWeapon = new MenuChangeWeapon();
                    newWeapon.GetRandomWeapon(TheHero);

                    Loader load = new Loader();
                    NPCsOfCurrentLevel.Clear();

                    matrix = load.LoadLevel(matrix, TheHero, NPCsOfCurrentLevel);
                }
                else if (!escapeSuccessful)
                {
                    DiceRoller dice = new DiceRoller();
                    if (dice.NewDice(0.5))
                    {
                        MenuChangeWeapon newWeapon = new MenuChangeWeapon();
                        newWeapon.GetRandomWeapon(TheHero);
                    }
                }
            }
        }