Beispiel #1
0
        /// <summary>
        /// Elindít egy új játékot a megadott paraméterekket
        /// </summary>
        /// <param name="gameMode">játékmód</param>
        /// <param name="difficulty">nehézség</param>
        /// <param name="imageList">képek listája</param>
        /// <param name="boardAnimal">a tábla alakzata, ha null, akkor szimpla négyzet lesz</param>
        /// <returns>A táblával tér vissza</returns>

        /*public Board newGame(GameMode gameMode, Difficulty difficulty, IBoardShapes boardAnimal, List<Image> imageList)
         * {
         *  this.gameMode = gameMode;
         *
         *  board = new Board(imageList);
         *  board.createBoard(difficulty, boardAnimal); //TODO az imageList-bõl válasszon képet
         *  //board.createBoard_New(difficulty, boardAnimal);
         *  ImagesToFind = Game.ImagesToFind.createNewImagesToFind(gameMode, difficulty, board);
         *
         *  if (gameMode == GameMode.TIME)
         *  {
         *      elapsedTime = new TimeSpan(0, 0, 30);
         *  }
         *  else
         *  {
         *      elapsedTime = TimeSpan.Zero;
         *  }
         *  if(TimeElapsedHandler!=null) TimeElapsedHandler(elapsedTime);
         *  time.Start();
         *
         *  return board;
         * }*/

        /// <summary>
        /// Elindít egy új játékot a megadott paraméterekket
        /// </summary>
        /// <param name="gameMode">játékmód</param>
        /// <param name="difficulty">nehézség</param>
        /// <param name="imageList">képek listája</param>
        /// <param name="boardAnimal">a tábla alakzata, ha null, akkor szimpla négyzet lesz</param>
        /// <returns>A táblával tér vissza</returns>
        public Board NewGame(GameMode gameMode, Difficulty difficulty, IBoardShapes boardAnimal, List <Image> imageList)
        {
            this.gameMode   = gameMode;
            this.difficulty = difficulty;
            board           = new Board(imageList);
            board.CreateBoard(difficulty, boardAnimal);
            ImagesToFind = Game.ImagesToFind.CreateNewImagesToFind(gameMode, difficulty, board);

            if (gameMode == GameMode.TIME)
            {
                ElapsedTime = new TimeSpan(0, 0, 30);
            }
            else
            {
                ElapsedTime = TimeSpan.Zero;
            }
            if (TimeElapsedHandler != null)
            {
                TimeElapsedHandler(ElapsedTime);
            }
            startTime = GameManager.CurrentGameTime;
            Paused    = false;
            time.Start();

            return(board);
        }
Beispiel #2
0
        public void NewGame(GameMode gameMode, Difficulty difficulty, bool music, bool vibration)
        {
            if (gameMode == GameMode.ENDLESS || gameMode == GameMode.NORMAL || gameMode == GameMode.TIME)
            {
                IBoardShapes boardShape   = CreateBoardShape();
                int          pictureCount = boardShape.GetFieldCount(difficulty);

                LevelManager levelManager = new LevelManager();

                SinglePlayerGameCommunicator.Instance.StartSinglePlayer(difficulty, pictureCount,
                                                                        delegate(ServerCommunicator.Objects.NewBoardResponse nr)
                {
                    List <Image> imageList = ServerCommunicator.Objects.NewBoardResponse.getImagesFromResponse(GameManager.Instance.GraphicsDevice, nr);
                    Board board            = levelManager.NewGame(gameMode, difficulty, boardShape, imageList);
                    gameModel.SetLevelManager(levelManager);
                    gameModel.SetBoard(board);

                    GameModel.Loading = false;
                });
            }
            else
            {
                //TODO multiplayer módok
            }
        }
Beispiel #3
0
        /// <summary>
        /// Feltölti a Field-ek listáját a megadott nehézségen koordinátákkal együtt.
        /// </summary>
        /// <param name="difficulty"></param>

        /*public void createBoard_old(Difficulty difficulty, IBoardShapes boardAnimal)
         * {
         *  if (boardAnimal != null)
         *  {
         *      int[][] boardMap = boardAnimal.getField(difficulty);
         *      Y = boardMap.GetLength(0);
         *      X = boardMap[0].GetLength(0);
         *      for (int y = 0; y < boardMap.GetLength(0); y++)
         *      {
         *          for (int x = 0; x < boardMap[y].GetLength(0); x++)
         *          {
         *              if (boardMap[y][x] == 1)
         *              {
         *                  addRandomFieldToAllFields(difficulty, y, x);
         *              }
         *          }
         *      }
         *  }
         * }*/

        /// <summary>
        /// Feltölti a Field-ek listáját a megadott nehézségen koordinátákkal együtt.
        /// </summary>
        /// <param name="difficulty"></param>
        public void CreateBoard(Difficulty difficulty, IBoardShapes boardAnimal)
        {
            int[][] boardMap     = boardAnimal.GetField(difficulty);
            int     imageCounter = 0;

            Y = boardMap.GetLength(0);
            X = boardMap[0].GetLength(0);
            for (int y = 0; y < boardMap.GetLength(0); y++)
            {
                for (int x = 0; x < boardMap[y].GetLength(0); x++)
                {
                    if (boardMap[y][x] == 1)
                    {
                        //addRandomFieldToAllFields(difficulty, y, x);
                        Field field = new Field(imageList[imageCounter], imageCounter, y, x, true, null);
                        AllFields.Add(field);
                        imageCounter++;
                    }
                }
            }
        }
        /*public void checkInForMulti(GameMode gameMode, Difficulty difficulty, CheckInForMultiRequest request, CheckInForMultiHandler newBoardHandler)
         * {
         *  if (gameMode == GameMode.ENDLESS || gameMode == GameMode.NORMAL || gameMode == GameMode.TIME)
         *  {
         *      throw new InvalidParameterException("There is no multiplayer for normal, time or endless gamemodes");
         *  }
         *  string gmStr = gameMode.ToString().ToLower();
         *  string diffStr = difficulty.ToString().ToLower();
         *
         *  sendPostCommand("/check-in-for-multi/" + gmStr + "/" + diffStr,request,
         *      delegate(String s)
         *      {
         *          newBoardHandler(fastJSON.JSON.ToObject<CheckInForMultiResponse>(s));
         *      });
         * }*/


        public void Registration(string name, GameMode gameMode, Difficulty difficulty, IBoardShapes shape)
        {
            if (gameMode == GameMode.ENDLESS || gameMode == GameMode.NORMAL || gameMode == GameMode.TIME)
            {
                throw new InvalidParameterException("There is no multiplayer for normal, time or endless gamemodes");
            }
            string gmStr   = gameMode.ToString().ToLower();
            string diffStr = difficulty.ToString().ToLower();

            RegistrationRequest request = new RegistrationRequest()
            {
                difficulty = diffStr,
                layout     = shape.ToString(),
                mode       = gmStr,
                name       = name
            };

            fastJSON.JSON.Parameters.UseExtensions = false;

            SendSocket(fastJSON.JSON.ToJSON(request));
        }