示例#1
0
        public MouseRunner(ILabyrinth labyrinth)
        {
            if(labyrinth == null) throw new ArgumentNullException("labyrinth");

            _labyrinth = labyrinth;
            MouseSpeed = 100;
        }
示例#2
0
        /// <summary>Подключает лабиринт к визульному компоненту для отображения.</summary>
        /// <param name="labyrinth"></param>
        public void Attach(ILabyrinth labyrinth)
        {
            if(labyrinth == null) throw new ArgumentNullException("labyrinth");

            _labyrinth = labyrinth;
            _labyrinth.View = this;
        }
        public void CreateDiamondLabyrinthTest()
        {
            labyrinth = creator.Create(Diamond);

            bool isDiamondLabyrinth = labyrinth is DiamondLabyrinth;

            Assert.IsTrue(isDiamondLabyrinth);
        }
        public void CreateHexagonalLabyrinthTest()
        {
            labyrinth = creator.Create(Hexagon);

            bool isHexagonalLabyrinth = labyrinth is HexagonalLabyrinth;

            Assert.IsTrue(isHexagonalLabyrinth);
        }
        public void CreatePentagonLabyrinthTest()
        {
            labyrinth = creator.Create(Pentagram);

            bool isPentagonLabyrinth = labyrinth is PentagonLabyrinth;

            Assert.IsTrue(isPentagonLabyrinth);
        }
        public void CreateSquareLabyrinthTest()
        {
            labyrinth = creator.Create(Square);

            bool isSquareLabyrinth = labyrinth is SquareLabyrinth;

            Assert.IsTrue(isSquareLabyrinth);
        }
示例#7
0
        public static void WriteStats(ILabyrinth labyrinth)
        {
            var hero = Hero.GetHero;

            Console.ForegroundColor = ConsoleColor.DarkCyan;
            Console.WriteLine($"Count of coins: {hero.CoinsCount} from {labyrinth.StartCoinsCount}");
            Console.ForegroundColor = ConsoleColor.Gray;
        }
        public void ChangeSymbolInPentagonLabyrinthTest()
        {
            labyrinth = new PentagonLabyrinth();
            labyrinth.FillMatrix(randomCharProvider);

            labyrinth.ChangeSymbol(coordinates, ChangedSymbol);
            bool isChanged = ChangedSymbol == labyrinth.Matrix[DefaultRowCoordinate, DefaultColCoordinate];

            Assert.IsTrue(isChanged);
        }
示例#9
0
        public void StartNextLevel(
            ILabyrinth labyrinth,
            Algorithms.Id algorithmId)
        {
            currentLevel = new Level
            {
                Number    = NextLevelNumber,
                Labyrinth = labyrinth,
                Algorithm = Algorithms.Resources.Instance.GetAlgorithm(algorithmId)
            };

            levels.Add(currentLevel);

            SQLiteUtilities.InsertLevel(
                SQLiteUtilities.GetNextLevelID(),
                currentLevel.Number,
                Id,
                labyrinth.Id
                );

            baseAlgorithmId = algorithmId;

            for (int i = 0; i < PlayerList.instance.list.Count; i++)
            {
                Player player = PlayerList.instance.GetPlayerWithId(i);

                switch (player.ServerPlayerGameState)
                {
                case ClientGameState.Ready:
                case ClientGameState.PlayingTutorial:
                case ClientGameState.Playing:
                case ClientGameState.ViewingGlobalReplay:
                case ClientGameState.ViewingLocalReplay:
                case ClientGameState.WaitingForNextLevel:

                    Debug.Log(player);

                    player.serverAlgorithm = baseAlgorithmId;

                    player.serverLabyrinthId = currentLevel.Labyrinth.Id;

                    AssignCourse(player);

                    player.TargetSetGame(
                        player.connectionToClient,
                        currentLevel.Labyrinth.Json,
                        player.serverAlgorithm,
                        currentLevel.Number);

                    break;
                }
            }

            Server.Instance.State.Set(LevelState);
        }
示例#10
0
        public CourseExecution(Course course, ILabyrinth labyrinth)
        {
            this.course = course;

            Queue <int>    steps;
            Queue <string> stepValues;

            SQLiteUtilities.GetPlayerStepsForCourse(course.Id, out steps, out stepValues);

            Actions      = steps.ToArray();
            ActionValues = stepValues.ToArray();
        }
示例#11
0
 public static Type GetType(ILabyrinth data)
 {
     if (data.SizeX <= SizeSmall && data.SizeY <= SizeSmall)
     {
         return(Type.Small);
     }
     else if (data.SizeX <= SizeMedium && data.SizeY <= SizeMedium)
     {
         return(Type.Medium);
     }
     else
     {
         return(Type.Large);
     }
 }
示例#12
0
        /// <summary>
        /// Creates labyrinth of type asked by the user
        /// </summary>
        /// <param name="userChoiceOfLabyrinth">Type of labyrinth asked by user</param>
        /// <returns>Returns a labyrinth of type as given in parameter with name "userChoiceOfLabyrinth"</returns>
        public ILabyrinth Create(string userChoiceOfLabyrinth)
        {
            // Ninject used to get contracted class
            var kernel = new StandardKernel();

            kernel.Load(Assembly.GetExecutingAssembly());
            var randomGenerator = kernel.Get <IRandomCharProvider>();

            TypeLabyrinth typeOfLabyrinth = this.GetLabyrinthType(userChoiceOfLabyrinth);
            ILabyrinth    labyrinth       = this.CreateRequiredLabyrinth(typeOfLabyrinth);

            labyrinth.FillMatrix(randomGenerator);

            return(labyrinth);
        }
示例#13
0
 public WorldPresenter(GraphicsDevice GraphicsDevice)
 {
     labyrinthCastle         = new LabyrinthCastle();
     labyrinthForest         = new LabyrinthForest();
     labyrinth               = labyrinthCastle;
     player                  = new Player(labyrinth.GetStartPosition());
     camera1                 = new Camera(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height);
     nrCamera                = 1;
     lightColor              = new Color(1, 1, 1);
     isTurn                  = true;
     nrLabyrinth             = 1;
     nrEffect                = 0;
     effects                 = new Effect[2, 3];
     MediaPlayer.IsRepeating = true;
     flat = false;
 }
示例#14
0
 private void FillDiamondMatrix(ILabyrinth labyrinth)
 {
     for (int row = 0; row < labyrinth.Matrix.GetLength(0); row++)
     {
         for (int col = 0; col < labyrinth.Matrix.GetLength(1); col++)
         {
             if (row % 2 == 1 && col % 2 == 1)
             {
                 labyrinth.Matrix[row, col] = (char)Symbol.Obstacle;
             }
             else
             {
                 labyrinth.Matrix[row, col] = (char)Symbol.Path;
             }
         }
     }
 }
        public LabyrinthObject GetLabyrinthObject(ILabyrinth data)
        {
            switch (Utils.GetType(data))
            {
            case Type.Small:
                return(LabyrinthSmall);

            case Type.Medium:
                return(LabyrinthMedium);

            case Type.Large:
                return(LabyrinthLarge);

            default:    // Type.Unknown:
                return(LabyrinthMedium);
            }
        }
        public void OnEditorState(EditorState state)
        {
            switch (state)
            {
            case EditorState.Editor:
                break;

            case EditorState.Select:

                if (LabyrinthObject != null)
                {
                    LabyrinthObject.gameObject.Destroy();
                    LabyrinthObject = null;
                }

                Labyrinth = null;
                break;
            }
        }
        /// <summary>
        /// StartGame method contains the whole game logic in the correct order to be played
        /// </summary>
        private void StartGame()
        {
            this.creator = new LabyrinthCreator();
            this.Player  = new Player();

            string userChoiceOfLabyrinth = string.Empty;

            userChoiceOfLabyrinth = this.menu.GetLabyrinthTypeFromUser();

            this.labyrinth = this.creator.Create(userChoiceOfLabyrinth);

            this.Player.ShowPlayer(this.labyrinth);

            this.renderer.Render(this.labyrinth);

            this.coordinates = this.command.ProcessCommands();

            this.GetGameLoop();
        }
示例#18
0
        public bool Motion(ConsoleKeyInfo key, ILabyrinth lab)
        {
            {
                var motionFlag = true;
                switch (key.Key)
                {
                case ConsoleKey.W:
                case ConsoleKey.UpArrow: {
                    Up(lab);
                    break;
                }

                case ConsoleKey.D:
                case ConsoleKey.RightArrow: {
                    Right(lab);
                    break;
                }

                case ConsoleKey.S:
                case ConsoleKey.DownArrow: {
                    Down(lab);
                    break;
                }

                case ConsoleKey.A:
                case ConsoleKey.LeftArrow: {
                    Left(lab);
                    break;
                }

                default: {
                    motionFlag = false;
                    break;
                }
                }

                lab.CheckCoin(hero.X, hero.Y);

                return(motionFlag);
            }
        }
示例#19
0
 /// <summary>
 /// Remove Player from a position
 /// </summary>
 public void RemovePlayer(ILabyrinth labyrinth)
 {
     labyrinth.ChangeSymbol(this.Coordinates, this.currentSymbol);
 }
示例#20
0
 public void OnPlayClicked(ILabyrinth labyrinth)
 {
     Enabled = true;
     Enabled = false;
     //GameManager.Instance.CurrentGame.StartRoundWithLabyrinth(labyrinth.Id);
 }
示例#21
0
 /// <summary>
 /// Puts players sign in the labyrinth
 /// </summary>
 /// <param name="labyrinth">Labyrinth object in which the player should appear </param>
 public void ShowPlayer(ILabyrinth labyrinth)
 {
     this.currentSymbol = this.GetCurrentSymbol(labyrinth);
     labyrinth.ChangeSymbol(this.Coordinates, (char)Symbol.Player);
 }
 public override Direction[] GetPrioritizedDirections(AlgorithmExecutionState state, ILabyrinth labyrinth)
 {
     return(new Direction[] { Direction.Up, Direction.Right, Direction.Down, Direction.Left });
 }
 public void CreateLabyrinthShouldThrowExceptionTest()
 {
     labyrinth = creator.Create(Other);
 }
示例#24
0
 /// <summary>
 /// Return the initial sign in current position
 /// </summary>
 private char GetCurrentSymbol(ILabyrinth labyrinth)
 {
     return(labyrinth.Matrix[this.Coordinates.Row, this.Coordinates.Col]);
 }
        // up right down left
        public override Direction[] GetPrioritizedDirections(AlgorithmExecutionState state, ILabyrinth labyrinth)
        {
            Vector2Int dest;

            List <PriorityDirection> dirs = new List <PriorityDirection>();

            int up = 0;

            dest = state.position;

            for (
                up = 0;
                labyrinth.GetIsTileWalkable(
                    dest = Promoscience.Utils.GetMoveDestination(dest, Direction.Up));
                up++)
            {
                ;
            }


            dirs.Add(new PriorityDirection
            {
                Prio = up,
                dir  = Direction.Up
            });

            //
            int right = 0;

            dest = state.position;

            for (
                right = 0;
                labyrinth.GetIsTileWalkable(
                    dest = Promoscience.Utils.GetMoveDestination(dest, Direction.Right));
                right++)
            {
                ;
            }


            dirs.Add(new PriorityDirection
            {
                Prio = right,
                dir  = Direction.Right
            });


            //

            int down = 0;

            dest = state.position;

            for (
                down = 0;
                labyrinth.GetIsTileWalkable(
                    dest = Promoscience.Utils.GetMoveDestination(dest, Direction.Down));
                down++)
            {
                ;
            }

            dirs.Add(new PriorityDirection
            {
                Prio = down,
                dir  = Direction.Down
            });

            //

            int left = 0;

            dest = state.position;


            for (
                left = 0;
                labyrinth.GetIsTileWalkable(
                    dest = Promoscience.Utils.GetMoveDestination(dest, Direction.Left));
                left++)
            {
                ;
            }

            dirs.Add(new PriorityDirection
            {
                Prio = left,
                dir  = Direction.Left
            });

            return(dirs.OrderByDescending(x => x.Prio).Select(x => x.dir).ToArray());
        }
 internal LabyrinthWithPlayer(ILabyrinth labyrinth, int[] playerPosition)
 {
     this.labyrinth = labyrinth;
     this.playerPosition = playerPosition;
 }
示例#27
0
        public void Update(GameTime gameTime)
        {
            Vector3 moveVector     = new Vector3(0, 0, 0);
            float   timeDifference = (float)gameTime.ElapsedGameTime.TotalMilliseconds / 400.0f;

            labyrinth.Update(timeDifference);

            KeyboardState keyState = Keyboard.GetState();

            if (keyState.IsKeyDown(Keys.Up) || keyState.IsKeyDown(Keys.W))
            {
                moveVector += new Vector3(0, 0, 1);
            }
            if (keyState.IsKeyDown(Keys.Down) || keyState.IsKeyDown(Keys.S))
            {
                moveVector += new Vector3(0, 0, -1);
            }
            if (keyState.IsKeyDown(Keys.Right) || keyState.IsKeyDown(Keys.D))
            {
                moveVector += new Vector3(-1, 0, 0);
            }
            if (keyState.IsKeyDown(Keys.Left) || keyState.IsKeyDown(Keys.A))
            {
                moveVector += new Vector3(1, 0, 0);
            }
            if (keyState.IsKeyDown(Keys.NumPad1))
            {
                nrCamera = 1;
            }
            if (keyState.IsKeyDown(Keys.NumPad2))
            {
                nrCamera = 2;
            }
            if (keyState.IsKeyDown(Keys.NumPad3))
            {
                nrCamera = 3;
            }
            if (keyState.IsKeyDown(Keys.L))
            {
                isTurn = false;
            }
            if (keyState.IsKeyDown(Keys.O))
            {
                isTurn = true;
            }
            if (keyState.IsKeyDown(Keys.X))
            {
                labyrinth = labyrinthCastle;
                player.SetPosition(labyrinth.GetStartPosition());
                nrLabyrinth = 1;
            }
            if (keyState.IsKeyDown(Keys.Z))
            {
                labyrinth = labyrinthForest;
                player.SetPosition(labyrinth.GetStartPosition());
                nrLabyrinth = 0;
            }
            if (keyState.IsKeyDown(Keys.P))
            {
                nrEffect = 0;
                flat     = false;
            }
            if (keyState.IsKeyDown(Keys.B))
            {
                nrEffect = 1;
                flat     = false;
            }
            if (keyState.IsKeyDown(Keys.G))
            {
                nrEffect = 2;
                flat     = false;
            }
            if (keyState.IsKeyDown(Keys.F))
            {
                nrEffect = 2;
                flat     = true;
            }

            bool move = labyrinth.IsCollision(player.GetPosition(moveVector, timeDifference));

            player.Move(moveVector, timeDifference, move);
            view = camera1.GetView(timeDifference, player.Position, move);

            if (labyrinth.IsEnd(player.Position))
            {
                player.SetPosition(labyrinth.GetStartPosition());
            }
        }
示例#28
0
 public MouseContext(ILabyrinth labyrinth, Coords mouseCoords)
 {
     _labyrinth = labyrinth;
     _mouseCoords = mouseCoords;
 }
示例#29
0
        // up right down left
        public override Direction[] GetPrioritizedDirections(AlgorithmExecutionState state, ILabyrinth labyrinth)
        {
            List <PriorityDirection> dirs = new List <PriorityDirection>();

            dirs.Add(new PriorityDirection
            {
                Prio =
                    (labyrinth.EndPos - Promoscience.Utils.GetMoveDestination(state.position, Direction.Up)).magnitude,
                dir = Direction.Up
            });

            dirs.Add(new PriorityDirection
            {
                Prio =
                    (labyrinth.EndPos - Promoscience.Utils.GetMoveDestination(state.position, Direction.Right)).magnitude,
                dir = Direction.Right
            });

            dirs.Add(new PriorityDirection
            {
                Prio =
                    (labyrinth.EndPos - Promoscience.Utils.GetMoveDestination(state.position, Direction.Down)).magnitude,
                dir = Direction.Down
            });

            dirs.Add(new PriorityDirection
            {
                Prio =
                    (labyrinth.EndPos - Promoscience.Utils.GetMoveDestination(state.position, Direction.Left)).magnitude,
                dir = Direction.Left
            });


            return(dirs.OrderBy(x => x.Prio).Select(x => x.dir).ToArray());
        }
示例#30
0
        private void Move(ILabyrinth labyrinth, int[] newPosition)
        {
            bool isValidMove = labyrinth[newPosition[1], newPosition[0]] == Labyrinth.BLANK_SYMBOL;

            if (!isValidMove)
            {
                throw new ArgumentException("Invalid move!");
            }

            this.Player.PositionX = newPosition[0];
            this.Player.PositionY = newPosition[1];
            this.Player.Moves++;

            this.CheckIfEscaped();

            this.AddDrawableObjectsToBuffer();
        }