コード例 #1
0
ファイル: AbstractHero.cs プロジェクト: Raydynn/Quest-Game
 public AbstractHero(Position position)
 {
     this.position = position;
     this.color = Constants.HeroColor;
     this.width = 1;
     this.height = 1;
 }
コード例 #2
0
ファイル: AbstractItem.cs プロジェクト: Raydynn/Quest-Game
 public AbstractItem(Position position)
 {
     this.position = position;
     //this.displaySymbol = Constants.BombDisplaySymbol;
     //this.color = Constants.BombColor;
     //this.width = 1;
     //this.height = 1;
 }
コード例 #3
0
ファイル: Priest.cs プロジェクト: Raydynn/Quest-Game
 public Priest(Position position)
     : base(position)
 {
     this.Hp = Constants.PriestStartingHp;
     this.DisplaySymbol = Constants.PriestDisplaySymbol;
     this.Position = position;
     this.Explanation = string.Format("Priests have {0} hp and ...", this.Hp);
 }
コード例 #4
0
ファイル: WinArea.cs プロジェクト: Raydynn/Quest-Game
 public WinArea(Position position)
 {
     this.initialPositions = position;
     this.displaySymbol = Constants.WinAreaDisplaySymbol;
     this.color = Constants.WinAreaColor;
     this.width = Constants.BoxWidth / 10 - 1;
     this.height = Constants.BoxHeight / 10 - 1;
 }
コード例 #5
0
ファイル: AbstractQuest.cs プロジェクト: Raydynn/Quest-Game
 public AbstractQuest(Position position)
 {
     this.position = position;
     this.color = Constants.QuestsColor;
     this.displaySymbol = Constants.QuestDisplaySymbol;
     this.width = 1;
     this.height = 1;
 }
コード例 #6
0
ファイル: Box.cs プロジェクト: Raydynn/QuestGame
 public Box(Position startingPosition,int length, int height)
 {
     this.startingPosition = startingPosition;
     this.topBorder = new List<Position>();
     this.botBorder = new List<Position>();
     this.leftBorder = new List<Position>();
     this.rightBorder = new List<Position>();
     initBorders(length, height);
 }
コード例 #7
0
ファイル: Visualizer.cs プロジェクト: Raydynn/Quest-Game
        public static void DrawSymbolAtPosition(string symbol, Position position, ConsoleColor color)
        {
            Console.SetCursorPosition(position.GetWidthCoo(), position.GetDebthCoo());
            Console.ForegroundColor = color;
            Console.Write(symbol);

            //// set to avoid the visual glitches caused by the underscore ("_") ;
            Console.SetCursorPosition(0, 41);
        }
コード例 #8
0
ファイル: Bomb.cs プロジェクト: Raydynn/Quest-Game
 public Bomb(Position position, int damage)
 {
     this.position = position;
     this.amountOfDamageItInflicts = damage;
     this.displaySymbol = Constants.BombDisplaySymbol;
     this.color = Constants.BombColor;
     this.width = 1;
     this.height = 1;
 }
コード例 #9
0
ファイル: Magician.cs プロジェクト: Raydynn/Quest-Game
 public Magician(Position position)
     : base(position)
 {
     //// TODO: add something that makes Priest and Magician different.
     //// TODO: add more classes
     this.Hp = Constants.MagicianStartingHp;
     this.DisplaySymbol = Constants.MagicianDisplaySymbol;
     this.Position = position;
     this.Explanation = string.Format("Magicians have {0} hp and ...", this.Hp);
 }
コード例 #10
0
ファイル: Box.cs プロジェクト: Raydynn/Quest-Game
 public Box(Position startingPosition, int length, int height)
 {
     this.startingPosition = startingPosition;
     this.topBorder = new List<Position>();
     this.botBorder = new List<Position>();
     this.leftBorder = new List<Position>();
     this.rightBorder = new List<Position>();
     this.InitBorders(length, height);
     this.displaySymbol = Constants.BoxDisplaySymbol;
     this.color = Constants.BoxColor;
     this.width = length;
     this.height = height;
 }
コード例 #11
0
ファイル: BoardTraverser.cs プロジェクト: Raydynn/Quest-Game
        protected IDisplayPiece GetPieceAtPosition(Position targetPosition, List<IDisplayPiece> boardPieces)
        {
            for (int i = 0; i < boardPieces.Count; i++)
            {
                Position currentBoardPiecePosition = boardPieces[i].Position;

                bool widthCooMatches = targetPosition.GetWidthCoo() == currentBoardPiecePosition.GetWidthCoo();
                bool debthCooMatches = targetPosition.GetDebthCoo() == currentBoardPiecePosition.GetDebthCoo();

                if (widthCooMatches && debthCooMatches)
                {
                    return boardPieces[i];
                }

            }

            return null;
        }
コード例 #12
0
ファイル: BoardTraverser.cs プロジェクト: Raydynn/QuestGame
        private IDisplayPiece getPieceAtPosition(Position targetPosition,List<IDisplayPiece> boardPieces)
        {
            for (int i = 0; i < boardPieces.Count; i++)
            {
                List<Position> currentBoardPiecePositions = boardPieces[i].getPositions();

                for (int j = 0; j < currentBoardPiecePositions.Count; j++)
                {
                    bool widthCooMatches = targetPosition.getWidthCoo() == currentBoardPiecePositions[j].getWidthCoo();
                    bool debthCooMatches = targetPosition.getDebthCoo() == currentBoardPiecePositions[j].getDebthCoo();

                    if(widthCooMatches && debthCooMatches)
                    {
                        return boardPieces[i];
                    }
                }
            }

            return null;
        }
コード例 #13
0
ファイル: Box.cs プロジェクト: Raydynn/QuestGame
        private void initBorders(int length, int height)
        {
            //Creating top and bottom borders
            for (int i = 0; i < length; i++)
            {
                Position partOfTopBorder = new Position(this.startingPosition.getWidthCoo() + i,this.startingPosition.getDebthCoo());
                Position partOFBottomBorder = new Position(this.startingPosition.getWidthCoo() + i,this.startingPosition.getDebthCoo() + height -1);
                this.topBorder.Add(partOfTopBorder);
                this.botBorder.Add(partOFBottomBorder);
            }

            //Creating left and right borders
            for (int i = 0; i < height; i++)
            {
                Position partOfLeftBorder = new Position(this.startingPosition.getWidthCoo(),this.startingPosition.getDebthCoo() + i);
                Position partOfRightBorder = new Position(this.startingPosition.getWidthCoo() + length - 1, this.startingPosition.getDebthCoo() + i);
                this.leftBorder.Add(partOfLeftBorder);
                this.rightBorder.Add(partOfRightBorder);
            }
        }
コード例 #14
0
ファイル: QuestFactory.cs プロジェクト: Raydynn/Quest-Game
        public static IDisplayPiece GetQuest(string questName, int id, int widthCoo, int debthCoo)
        {
            //// TODO: make the quests drop items
            //// TODO: make items that show on the side of the board (3 items are more than enough)

            Position initPosition = new Position(widthCoo, debthCoo);

            if (questName == "QuizQuest")
            {
                QuizQuest quest = new QuizQuest(initPosition);
                quest.Id = id;
                return quest;
            }
            else if (questName == "FallingRocks")
            {
                FallingRocks quest = new FallingRocks(initPosition);
                quest.Id = id;
                return quest;
            }
            else if(questName == "FlappyBird")
            {
                FlappyBirdQuest quest = new FlappyBirdQuest(initPosition);
                quest.Id = id;
                return quest;
            }
            else if (questName == "GuessTheNumber")
            {
                GuessTheNumber quest = new GuessTheNumber(initPosition);
                quest.Id = id;
                return quest;
            }
            else if (questName == "Hangman")
            {
                Hangman quest = new Hangman(initPosition);
                quest.Id = id;
                return quest;
            }

            return null;
        }
コード例 #15
0
ファイル: MainGame.cs プロジェクト: Raydynn/Quest-Game
 public void SetInitPositionOfBorderAroundWinArea(Position initPositionOfBorderAroundWinArea)
 {
     this.positionOfBorderAroundWinArea = initPositionOfBorderAroundWinArea;
 }
コード例 #16
0
ファイル: FallingRocks.cs プロジェクト: Raydynn/Quest-Game
 public FallingRocks(Position position)
     : base(position)
 {
     this.position = position;
 }
コード例 #17
0
ファイル: QuizQuest.cs プロジェクト: Raydynn/Quest-Game
 public QuizQuest(Position position)
     : base(position)
 {
     this.position = position;
 }
コード例 #18
0
ファイル: FlappyBirdQuest.cs プロジェクト: Raydynn/Quest-Game
 public FlappyBirdQuest(Position position)
     : base(position)
 {
     this.DisplaySymbol = "F";
 }
コード例 #19
0
ファイル: GameFactory.cs プロジェクト: Raydynn/Quest-Game
        public IGame GetGame(string gameName)
        {
            if (gameName == "MainGame")
            {

                MainGame game = new MainGame();
                Position startingPositionOfOuterBorder = new Position(0,0);
                addBoxToGame(game, startingPositionOfOuterBorder, Constants.BoxWidth, Constants.BoxHeight);

                //// TODO: implement abstract logic for this
                int outerBoxWidthMiddle = Constants.BoxWidth / 2;
                int outerBoxHeightMiddle = Constants.BoxHeight / 2;
                int innerBoxPreferedWidth = Constants.BoxWidth / 10 + 1;
                int innerBoxPreferedHeight = Constants.BoxHeight / 10 + 1;
                int innerBoxStartingWidthCoo = outerBoxWidthMiddle - (innerBoxPreferedWidth / 2) - 1 ;
                int innerBoxStartingHeightCoo = outerBoxHeightMiddle - (innerBoxPreferedHeight / 2) - 1;

                Position innerBoxStarterPosition = new Position(innerBoxStartingWidthCoo, innerBoxStartingHeightCoo);
                addBoxToGame(game, innerBoxStarterPosition, innerBoxPreferedWidth, innerBoxPreferedHeight);
                game.SetInitPositionOfBorderAroundWinArea(innerBoxStarterPosition);

                Position winAreaTopLeft = new Position(innerBoxStarterPosition.GetWidthCoo() + 1, innerBoxStarterPosition.GetDebthCoo() + 1);
                IDisplayPiece winArea = new WinArea(winAreaTopLeft);
                game.AddBoardElement(winArea);

                Position playerStartingPosition = new Position(Constants.PlayerStartingX, Constants.PlayerStartingY);

                AbstractHero player;
                int randNum = Generator.GetRandomNumber(1, 3);
                if (randNum == 1)
                {
                    player = new Priest(playerStartingPosition);
                }
                else
                {
                    player = new Magician(playerStartingPosition);
                }

                player.Id = this.UseCurrentID();

                game.AddBoardElement(player);

                //// TODO: add more quests
                List<Position> bombPositions = new List<Position>();

                var questNames = new List<string>
                {
                    "QuizQuest",
                    "FallingRocks",
                    "FlappyBird",
                    "GuessTheNumber",
                    "Hangman"
                };

                var questsCount = questNames.Count;

                for (int j = 0; j < 4; j++)
                {
                    var xRand1 = 0;
                    var xRand2 = 0;
                    var yRand1 = 0;
                    var yRand2 = 0;
                    switch (j)
                    {
                        case 0:
                            xRand1 = 1;
                            xRand2 = innerBoxStartingWidthCoo - 1;
                            yRand1 = 1;
                            yRand2 = innerBoxStartingHeightCoo - 1;
                            break;
                        case 1:
                            xRand1 = innerBoxStartingWidthCoo + innerBoxPreferedWidth + 1;
                            xRand2 = Constants.BoxWidth - 1;
                            yRand1 = 1;
                            yRand2 = innerBoxStartingHeightCoo - 1;
                            break;
                        case 2:
                            xRand1 = 1;
                            xRand2 = innerBoxStartingWidthCoo - 1;
                            yRand1 = innerBoxStartingHeightCoo + innerBoxPreferedHeight + 1;
                            yRand2 = Constants.BoxHeight - 1;
                            break;
                        case 3:
                            xRand1 = innerBoxStartingWidthCoo + innerBoxPreferedWidth + 1;
                            xRand2 = Constants.BoxWidth - 1;
                            yRand1 = innerBoxStartingHeightCoo + innerBoxPreferedHeight + 1;
                            yRand2 = Constants.BoxHeight - 1;
                            break;
                        default:
                            break;
                    }

                    for (int i = 0; i < 3; i++)
                    {
                        IDisplayPiece quizQuest = QuestFactory.GetQuest(
                            questNames[Generator.GetRandomNumber(0, questsCount)],
                            this.UseCurrentID(),
                            Generator.GetRandomNumber(xRand1, xRand2),
                            Generator.GetRandomNumber(yRand1, yRand2));

                        game.AddBoardElement(quizQuest);
                    }

                    for (int k = 0; k < 5; k++)
                    {
                        Position bombPosition = new Position(Generator.GetRandomNumber(xRand1, xRand2), Generator.GetRandomNumber(yRand1, yRand2));
                        Bomb bomb = new Bomb(bombPosition, Generator.GetRandomNumber(1, 4));
                        bomb.Id = this.UseCurrentID();
                        game.AddBoardElement(bomb);
                    }
                }

                PointsItem scoreShower = new PointsItem(new Position(Constants.PlayerScoreWidth,Constants.PlayerScoreDebth));
                scoreShower.MainGame = game;
                scoreShower.TypeOfPoints = "points";
                scoreShower.Id = this.UseCurrentID();
                scoreShower.Color = System.ConsoleColor.White;
                game.AddBoardElement(scoreShower);

                game.SetMinimumWinScore(1);

                return game;
            }

            return null;
        }
コード例 #20
0
ファイル: GameFactory.cs プロジェクト: Raydynn/Quest-Game
        private void addBoxToGame(MainGame game, Position startingPosition, int width, int height)
        {
            int startingWidth = startingPosition.GetWidthCoo();
            int startingDebt = startingPosition.GetDebthCoo();
            int depricatedUse = 1;
            for (int i = 0; i < width; i++)
            {
                Position currentPositionOfPartOfTopBorder = new Position(startingWidth + i, startingDebt);
                Box partOfTopBorder = new Box(currentPositionOfPartOfTopBorder, depricatedUse, depricatedUse);
                partOfTopBorder.Id = this.UseCurrentID();

                Position currentPositionOFPartOfBotBorder = new Position(startingWidth + i, startingDebt + height);
                Box partOfBotBorder = new Box(currentPositionOFPartOfBotBorder, depricatedUse, depricatedUse);
                partOfBotBorder.Id = this.UseCurrentID();
                game.AddBoardElement(partOfTopBorder);
                game.AddBoardElement(partOfBotBorder);
            }

            for (int i = 0; i < height - 1; i++)
            {
                Position currentPositionOfPartOfLeftBorder = new Position(startingWidth, startingDebt + 1 + i);
                Box partOfLeftBorder = new Box(currentPositionOfPartOfLeftBorder, depricatedUse, depricatedUse);
                partOfLeftBorder.Id = this.UseCurrentID();

                Position currentPositionOfPartOfRightBorder = new Position(startingWidth + width - 1, startingDebt + 1 + i);
                Box partOfRightBorder = new Box(currentPositionOfPartOfRightBorder, depricatedUse, depricatedUse);
                partOfRightBorder.Id = this.UseCurrentID();

                game.AddBoardElement(partOfLeftBorder);
                game.AddBoardElement(partOfRightBorder);
            }
        }
コード例 #21
0
ファイル: MainGame.cs プロジェクト: Raydynn/Quest-Game
        public override double StartGame()
        {
            Visualizer.DrawEverything(this.boardElements);
            this.gameStatus = 0;
            Position scorePosition = new Position(Constants.PlayerScoreWidth, Constants.PlayerScoreDebth);
            IDisplayPiece scoreShower = GetPieceAtPosition(scorePosition, this.boardElements);
            Visualizer.DrawDisplayPieceOnConsole(scoreShower);

            this.winAreaPoints = ((WinArea)this.boardElements
                                                .Find(x => x.DisplaySymbol == "W")).GetPositions();

            Position playerStartingPosition = new Position(Constants.PlayerStartingX, Constants.PlayerStartingY);
            this.player = (AbstractHero)GetPieceAtPosition(playerStartingPosition, this.boardElements);

            while (this.gameStatus == 0)
            {
                if (this.playerScore >= minimumWinScore)
                {
                    int widthCooOfDoor = this.positionOfBorderAroundWinArea.GetWidthCoo();
                    int debtCooOfDoor = this.positionOfBorderAroundWinArea.GetDebthCoo() + 1;
                    Position positionOfDoorToWin = new Position(widthCooOfDoor, debtCooOfDoor);

                    IDisplayPiece doorToWinArea = GetPieceAtPosition(positionOfDoorToWin, this.boardElements);
                    if (doorToWinArea != null)
                    {
                        RemoveDisplayPiece(doorToWinArea);
                    }

                }

                //// TODO: make every move to remove 0.1 points from the player score and explain it at the begining so that the players think on how they play and there is gamification to the movement as well
                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo userInput = Console.ReadKey();

                    if (userInput.Key == ConsoleKey.Q)
                    {
                        this.gameStatus = -1;
                    }
                    else
                    {
                        this.TryMovingToDirection(this.player.Move(userInput));
                    }
                }

                if (this.player.Hp <= 0)
                {
                    this.gameStatus = -1;
                }
            }

            Console.ForegroundColor = ConsoleColor.White;
            Console.Clear();
            if (gameStatus == 1)
            {
                Console.WriteLine("Congratulations you won!");
                Console.WriteLine("Your Score: {0}", PlayerScore);

                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine(this.player.ToString());
            }
            else if (gameStatus == -1)
            {
                Console.WriteLine("You lost the game");
            }

            Console.ReadLine();

            return playerScore;
        }
コード例 #22
0
ファイル: WinArea.cs プロジェクト: Raydynn/Quest-Game
 public void WinAreaAddPosition(Position initialPositions)
 {
     this.winAreas.Add(initialPositions);
 }
コード例 #23
0
ファイル: GuessTheNumber.cs プロジェクト: Raydynn/Quest-Game
 public GuessTheNumber(Position position)
     : base(position)
 {
     this.position = position;
 }
コード例 #24
0
ファイル: PointsItem.cs プロジェクト: Raydynn/Quest-Game
 public PointsItem(Position position)
     : base(position)
 {
 }