public MatchesUndoer(BoardData _boardData)
	{
		boardData = _boardData;
		matchesFinder = new MatchesFinder(boardData);
		
		lastMatchedBoardPieces = new List<Match3BoardPiece>(32);
	}
	public BoardHolesMaskGenerator(BoardData _boardData) 
	{
		boardData = _boardData;
		
		if (boardData == null) {
			Debug.LogError("[BoardHolesMaskGenerator] boardData is NULL! Wrong init order?!");
		}
		
	}
	public PossibleMatchGenerator(BoardData _boardData)
	{
		Board = _boardData;
		
		// Allocate tile buffers
		for(int i = 0; i < tilesBuffers.Length; i++) 
		{
			tilesBuffers[i] = new List<Match3Tile>(10);
		}
	}
示例#4
0
	private void Awake ()
	{
		if(Instance == null)
		{
			Instance = this;
			DontDestroyOnLoad (this.gameObject);
		}
		else
			Unload ();
	}
示例#5
0
    public static void timeToThink(GameObject[,] boardData, Stack<GameObject> them, 
	                               Stack<GameObject> us, bool turn, int difficulty)
    {
        BoardData think = new BoardData ();
        think.boardData = boardData;
        think.comp = us;
        think.player = them;
        think.aiTurn = turn;
        //Debug.Log ("SCP files" + think.comp.Count);
        move (think, difficulty);
    }
	/// <summary>
	/// Defined to also give this component the ability to be enabled/disabled.
	/// </summary>
	void Start()
	{
		board = Match3BoardGameLogic.Instance.boardData;
		
		// Register to the board's OnStable event.
		Debug.Log("[BoardShuffleController] Registering to the board's OnStableBoard event...");
		Match3BoardGameLogic.OnStableBoard += OnStableBoardEvent;
		
		matchesFinder = new MatchesFinder(board);
		possibleMatchesFinder = new PossibleMatchesFinder(board);
		matchesUndoer = new MatchesUndoer(board);
		possibleMatchGenerator = new PossibleMatchGenerator(board);
	}
	public PossibleMatchesFinder(BoardData _boardData)
	{		
		Board = _boardData;
		
		foundPossibleMatch = new Match3Tile[3];
		
		// Initialize the partial matches buffers. There can only be a maximum of 3 tiles found in a buffer (list).
		for(int i = 0; i < partialTileMatchesLists.Length; i++) {
			partialTileMatchesLists[i] = new List<Match3Tile>(3);
			isolatedTilesLists[i] = new List<Match3Tile>(3);
		}
		
		// Cache the direction indices indicated by the "Match3BoardPiece" enum. (only in 4 directions)
		dirIndices = new Match3BoardPiece.LinkType[4];
		dirIndices[0] = Match3BoardPiece.LinkType.Top;
		dirIndices[1] = Match3BoardPiece.LinkType.Right;
		dirIndices[2] = Match3BoardPiece.LinkType.Bottom;
		dirIndices[3] = Match3BoardPiece.LinkType.Left;
	}
示例#8
0
    // Use this for initialization
    void Start()
    {
        Data = TetrisBoard.GetComponent<BoardData>();

        if(Data == null)
        {
            Debug.LogError("Invalid board: No data found");
        }
        else
        {
            TileBoard = new bool[Data.Rows, Data.Columns];
            NumberBoard = new int[Data.Rows, Data.Columns];

            for(int i=0;i<TileBoard.GetLength(0);i++)
            {
                for(int j=0;j<TileBoard.GetLength(1);j++)
                {
                    TileBoard[i, j] = true;
                    NumberBoard[i, j] = 0;
                }
            }
        }
    }
示例#9
0
    public async void CreateBoard()
    {
        BoardData boardData = await Addressables.LoadAssetAsync <BoardData>("board").Task;

        // Load tiles
        var whiteTileObj = await boardData.Tiles[0].LoadAssetAsync <GameObject>().Task;
        var blackTileObj = await boardData.Tiles[1].LoadAssetAsync <GameObject>().Task;

        // load pieces
        var whitePawn   = await boardData.Pieces[0].LoadAssetAsync <GameObject>().Task;
        var whiteRook   = await boardData.Pieces[1].LoadAssetAsync <GameObject>().Task;
        var whiteKnight = await boardData.Pieces[2].LoadAssetAsync <GameObject>().Task;
        var whiteBishop = await boardData.Pieces[3].LoadAssetAsync <GameObject>().Task;
        var whiteQueen  = await boardData.Pieces[4].LoadAssetAsync <GameObject>().Task;
        var whiteKing   = await boardData.Pieces[5].LoadAssetAsync <GameObject>().Task;

        var blackPawn   = await boardData.Pieces[6].LoadAssetAsync <GameObject>().Task;
        var blackRook   = await boardData.Pieces[7].LoadAssetAsync <GameObject>().Task;
        var blackKnight = await boardData.Pieces[8].LoadAssetAsync <GameObject>().Task;
        var blackBishop = await boardData.Pieces[9].LoadAssetAsync <GameObject>().Task;
        var blackQueen  = await boardData.Pieces[10].LoadAssetAsync <GameObject>().Task;
        var blackKing   = await boardData.Pieces[11].LoadAssetAsync <GameObject>().Task;

        // Create chessboard tiles
        GameObject l_tile;

        for (int row = 0; row < boardData.Board.MatrixSize; row++)
        {
            for (int col = 0; col < boardData.Board.MatrixSize; col++)
            {
                if ((row + col) % 2 == 0)
                {
                    l_tile = Instantiate(blackTileObj, transform);
                }
                else
                {
                    l_tile = Instantiate(whiteTileObj, transform);
                }

                l_tile.transform.position = new Vector2(col, row);
            }
        }

        // Create chessboard pieces
        GameObject l_piece;

        // --- White pieces ---

        // White pawn 1
        l_piece = Instantiate(whitePawn, transform);
        l_piece.transform.position = new Vector2(0, 1);

        // White pawn 2
        l_piece = Instantiate(whitePawn, transform);
        l_piece.transform.position = new Vector2(1, 1);

        // White pawn 3
        l_piece = Instantiate(whitePawn, transform);
        l_piece.transform.position = new Vector2(2, 1);

        // White pawn 4
        l_piece = Instantiate(whitePawn, transform);
        l_piece.transform.position = new Vector2(3, 1);

        // White pawn 5
        l_piece = Instantiate(whitePawn, transform);
        l_piece.transform.position = new Vector2(4, 1);

        // White pawn 6
        l_piece = Instantiate(whitePawn, transform);
        l_piece.transform.position = new Vector2(5, 1);

        // White pawn 7
        l_piece = Instantiate(whitePawn, transform);
        l_piece.transform.position = new Vector2(6, 1);

        // White pawn 8
        l_piece = Instantiate(whitePawn, transform);
        l_piece.transform.position = new Vector2(7, 1);

        // White rook 1
        l_piece = Instantiate(whiteRook, transform);
        l_piece.transform.position = new Vector2(0, 0);

        // White rook 2
        l_piece = Instantiate(whiteRook, transform);
        l_piece.transform.position = new Vector2(7, 0);

        // White knight 1
        l_piece = Instantiate(whiteKnight, transform);
        l_piece.transform.position = new Vector2(1, 0);

        // White knight 2
        l_piece = Instantiate(whiteKnight, transform);
        l_piece.transform.position = new Vector2(6, 0);

        // White bishop 1
        l_piece = Instantiate(whiteBishop, transform);
        l_piece.transform.position = new Vector2(2, 0);

        // White bishop 2
        l_piece = Instantiate(whiteBishop, transform);
        l_piece.transform.position = new Vector2(5, 0);

        // White queen
        l_piece = Instantiate(whiteQueen, transform);
        l_piece.transform.position = new Vector2(3, 0);

        // White king
        l_piece = Instantiate(whiteKing, transform);
        l_piece.transform.position = new Vector2(4, 0);

        // --- Black pieces ---

        // Black pawn 1
        l_piece = Instantiate(blackPawn, transform);
        l_piece.transform.position = new Vector2(0, 6);

        // Black pawn 2
        l_piece = Instantiate(blackPawn, transform);
        l_piece.transform.position = new Vector2(1, 6);

        // Black pawn 3
        l_piece = Instantiate(blackPawn, transform);
        l_piece.transform.position = new Vector2(2, 6);

        // Black pawn 4
        l_piece = Instantiate(blackPawn, transform);
        l_piece.transform.position = new Vector2(3, 6);

        // Black pawn 5
        l_piece = Instantiate(blackPawn, transform);
        l_piece.transform.position = new Vector2(4, 6);

        // Black pawn 6
        l_piece = Instantiate(blackPawn, transform);
        l_piece.transform.position = new Vector2(5, 6);

        // Black pawn 7
        l_piece = Instantiate(blackPawn, transform);
        l_piece.transform.position = new Vector2(6, 6);

        // Black pawn 8
        l_piece = Instantiate(blackPawn, transform);
        l_piece.transform.position = new Vector2(7, 6);

        // Black rook 1
        l_piece = Instantiate(blackRook, transform);
        l_piece.transform.position = new Vector2(0, 7);

        // Black rook 2
        l_piece = Instantiate(blackRook, transform);
        l_piece.transform.position = new Vector2(7, 7);

        // Black knight 1
        l_piece = Instantiate(blackKnight, transform);
        l_piece.transform.position = new Vector2(1, 7);

        // Black knight 2
        l_piece = Instantiate(blackKnight, transform);
        l_piece.transform.position = new Vector2(6, 7);

        // Black bishop 1
        l_piece = Instantiate(blackBishop, transform);
        l_piece.transform.position = new Vector2(2, 7);

        // Black bishop 2
        l_piece = Instantiate(blackBishop, transform);
        l_piece.transform.position = new Vector2(5, 7);

        // Black queen
        l_piece = Instantiate(blackQueen, transform);
        l_piece.transform.position = new Vector2(3, 7);

        // Black king
        l_piece = Instantiate(blackKing, transform);
        l_piece.transform.position = new Vector2(4, 7);

        // Center the board on the sceen
        transform.position = new Vector2(-boardData.Board.MatrixSize / 2 + 2 / 2, -3.5f);

        // Release addressable data used to create the board
        boardData.Tiles[0].ReleaseAsset();
        boardData.Tiles[1].ReleaseAsset();
        boardData.Pieces[0].ReleaseAsset();
        boardData.Pieces[1].ReleaseAsset();
        boardData.Pieces[2].ReleaseAsset();
        boardData.Pieces[3].ReleaseAsset();
        boardData.Pieces[4].ReleaseAsset();
        boardData.Pieces[5].ReleaseAsset();
        boardData.Pieces[6].ReleaseAsset();
        boardData.Pieces[7].ReleaseAsset();
        boardData.Pieces[8].ReleaseAsset();
        boardData.Pieces[9].ReleaseAsset();
        boardData.Pieces[10].ReleaseAsset();
        boardData.Pieces[11].ReleaseAsset();
    }
示例#10
0
    //public bool AreAnyPlayers() {
    //    return GetPlayers().Count > 0;
    //}
    //private bool CheckAreGoalsSatisfied () {
    //    if (goalObjects.Count == 0) { return true; } // If there's NO criteria, then sure, we're satisfied! For levels that're just about getting to the exit.
    //    for (int i=0; i<goalObjects.Count; i++) {
    //        if (!goalObjects[i].IsOn) { return false; } // return false if any of these guys aren't on.
    //    }
    //    return true; // Looks like we're soooo satisfied!!
    //}

    // Serializing
    public Board Clone()
    {
        BoardData data = ToData();

        return(new Board(data));
    }
示例#11
0
 public AIOpponent(BoardData board, int computerDifficulty, BoardController newController)
 {
     boardData  = board;
     difficulty = computerDifficulty;
     cellValue  = new CellValue(board);
 }
示例#12
0
	public MatchesFinder(BoardData _boardData) 
	{
		Board = _boardData;
	}
示例#13
0
 void Awake()
 {
     gameOver  = false;
     board     = new BoardData(boardSize);
     boardSize = board.Size;
 }
示例#14
0
 public static void movePiece(ref BoardData g, GameObject piece)
 {
     ///if(g.boardData[piece.GetComponent<Piece>().row, piece.GetComponent<Piece> ().col] ==
 }
示例#15
0
 // Use this for initialization
 void Awake()
 {
     Data = GetComponent<BoardData>();
 }
示例#16
0
 public void RestoreBoardState(BoardData data)
 {
     levelConstructor.ConstructGameBoard(data);
 }
示例#17
0
 public abstract TreeNode NavigateTree(BoardData p_boardData);
示例#18
0
 void Awake()
 {
     obj = GetComponent<BoardObject>();
     data = BoardData.getBoardData();
 }
示例#19
0
 public void SetCurrentBoard(int index)
 {
     currentBoard = gameData.boards[index];
 }
示例#20
0
 private static int[] GetHealths(BoardData board)
 {
     return(board.Snakes.Select(x => x.Health).ToArray());
 }
示例#21
0
 private static BodyPartPosition[][] GetSnakeBodies(BoardData board)
 {
     return(board.Snakes.Select(x => x.Body.ToArray()).ToArray());
 }
示例#22
0
 // Loads the game and returns the current player
 public abstract State LoadGame(BoardData boardData);
示例#23
0
 public async void AddNewBoardData(BoardData data)
 {
     await _chatHub.AddNewBoardData(data);
 }
	public void RaiseBoardShuffleRequiredEvent() 
	{
		Match3BoardGameLogic.Instance.unstableLock++;
		
		IsBoardReshuffling = true;
		
		if (OnBoardShuffleRequired != null) {
			OnBoardShuffleRequired();
		}

		OnReshuffleRequired.RaiseEvent();
		
//		Debug.LogWarning("[BoardShuffleController] RaiseBoardShuffleRequiredEvent -> No more possible matches on the board...");
		
		board = Match3BoardGameLogic.Instance.boardData;

		// Collect all board pieces containing a normal tile to prepare for shuffling.
		board.ApplyActionToAll((boardPiece) => 
		{
			// Only re-shuffle normal tiles
			if (boardPiece.Tile != null && boardPiece.Tile.GetType() == typeof(NormalTile) && !boardPiece.Tile.IsDestroying)
			{
				piecesToReshuffle.Add(boardPiece as Match3BoardPiece);
				// Disable the tiles logic before starting the re-shuffle
				boardPiece.Tile.enabled = false;
			}
		});	

		// Disable tile switching input
		TileSwitchInput.Instance.DisableInput();

		StartReshuffleTilesAnim();
	}
        void Player_InfoReceived(object sender, ShogiCore.USI.USIInfoEventArgs e)
        {
            string infoDepth = "";
            string infoSelDepth = "";
            string infoTime = "";
            string infoNodes = "";
            string infoNPS = "";
            string infoScore = "";
            string infoCurrMove = "";
            string infoHashFull = "";
            string infoPVOrString = null;
            string pvLengthString = null;
            bool   lowerBound = false, upperBound = false;

            foreach (USIInfo info in e.SubCommands)
            {
                switch (info.Name)
                {
                case "depth": infoDepth = info.Parameters.FirstOrDefault(); break;

                case "seldepth": infoSelDepth = info.Parameters.FirstOrDefault(); break;

                case "time": infoTime = info.Parameters.FirstOrDefault(); break;

                case "nodes": infoNodes = info.Parameters.FirstOrDefault(); break;

                case "nps": infoNPS = info.Parameters.FirstOrDefault(); break;

                case "currmove": infoCurrMove = info.Parameters.FirstOrDefault(); break;

                case "hashfull": infoHashFull = info.Parameters.FirstOrDefault(); break;

                case "score":
                    if (player.LastScoreWasMate)
                    {
                        int    mateCount    = Math.Abs(player.LastScore) - USIPlayer.MateValue;
                        string mateCountStr = mateCount == 0 ? "" : ":" + mateCount.ToString();
                        infoScore = (0 < player.LastScore ? "+Mate" : "-Mate") + mateCountStr;
                    }
                    else
                    {
                        infoScore = player.LastScoreString;
                    }
                    break;

                case "lowerbound": lowerBound = true; break;

                case "upperbound": upperBound = true; break;

                case "pv": {
                    var           pvList   = info.Parameters;
                    BoardData     b        = Board == null ? null : Board.ToBoardData();
                    List <string> itemList = new List <string>();
                    int           pvLength = 0;
                    foreach (var pv in pvList)
                    {
                        try {
                            MoveData moveData = SFENNotationReader.ToMoveData(pv);
                            if (b == null)
                            {
                                itemList.Add(moveData.ToString());
                            }
                            else
                            {
                                itemList.Add(moveData.ToString(b));
                                b.Do(moveData);
                            }
                            pvLength++;
                        } catch (NotationException) {
                            itemList.Add(pv);
                        }
                    }
                    infoPVOrString = string.Concat(itemList.ToArray());
                    pvLengthString = "PV長=" + pvLength;
                }
                break;

                case "string":
                    infoPVOrString = string.Join(" ", info.Parameters);
                    break;
                }
            }

            if (!string.IsNullOrEmpty(infoSelDepth))
            {
                infoDepth += "/" + infoSelDepth;
            }
            long time, nodes, hashFull;

            if (long.TryParse(infoTime, out time))
            {
                infoTime = time.ToString("#,##0");
            }
            if (long.TryParse(infoNodes, out nodes))
            {
                infoNodes = nodes.ToString("#,##0");
            }
            if (long.TryParse(infoHashFull, out hashFull))
            {
                infoHashFull = (hashFull / 10.0).ToString("0.0").PadLeft(5) + "%";
            }
            if (lowerBound)
            {
                infoScore += "↑";
            }
            if (upperBound)
            {
                infoScore += "↓";
            }

            string toolTipText = pvLengthString;

            if (!string.IsNullOrEmpty(infoDepth))
            {
                toolTipText = "深さ=" + infoDepth + " " + toolTipText;
            }

            try {
                FormUtility.SafeInvoke(this, () => {
                    if (!string.IsNullOrEmpty(infoNPS))
                    {
                        long nps;
                        labelNPS.Text = long.TryParse(infoNPS, out nps) ? "NPS:" + nps.ToString("#,##0") : "NPS:" + infoNPS;
                    }
                    if (!string.IsNullOrEmpty(infoCurrMove))
                    {
                        if (Board == null)
                        {
                            labelCurMove.Text = "探索手:" + SFENNotationReader.ToMoveData(infoCurrMove).ToString();
                        }
                        else
                        {
                            labelCurMove.Text = "探索手:" + ShogiCore.Move.FromNotation(Board,
                                                                                     SFENNotationReader.ToMoveData(infoCurrMove)).ToString(Board);
                        }
                    }
                    if (!string.IsNullOrEmpty(infoHashFull))
                    {
                        labelHashFull.Text = "ハッシュ使用率:" + infoHashFull;
                    }
                    if (!string.IsNullOrEmpty(infoPVOrString))
                    {
                        AddListItem(infoTime, infoDepth, infoNodes, infoScore, infoPVOrString, pvLengthString);
                    }
                    double?meanDepth = stat.MeanDepth;
                    double?meanNPS   = stat.MeanNPS;
                    if (meanDepth.HasValue)
                    {
                        labelMeanDepth.Text = "平均深さ:" + meanDepth.Value.ToString("#0.0");
                    }
                    else
                    {
                        labelMeanDepth.Text = "平均深さ:-";
                    }
                    if (meanNPS.HasValue)
                    {
                        labelMeanNPS.Text = "平均NPS:" + meanNPS.Value.ToString("#,##0");
                    }
                    else
                    {
                        labelMeanNPS.Text = "平均NPS:-";
                    }
                });
            } catch {
                // 無視
            }
        }
示例#26
0
    /*
     * Finds how deep we must search based on the difficulty.
     * On a scale from 1-10, how far will a level 1 look ahead compared to a level 5?
     */
    static int getDepth(BoardData game, int difficulty)
    {
        int nOpponentPieces = game.player.Count;
        float popRatio = getPopulationRatio (game.comp, game.player);

        if (difficulty == 1)
            return 3;
        else if (difficulty == 2)
            return 6;
        else if (difficulty == 3)
            return (int)Mathf.Ceil ((difficulty*difficulty) /(2*popRatio));

        return 5;
    }
示例#27
0
 public GameData(string _gameid, BoardData _board)
 {
     GameId = _gameid;
     Board  = _board;
 }
示例#28
0
 //Splits the selected piece and moves other piece to other side
 public static void splitPiece(ref BoardData g, GameObject piece)
 {
 }
示例#29
0
 public abstract void SetData(BoardData boardData);
示例#30
0
        public static void AddToDb(IServiceProvider services)
        {
            var users = new UserInterface(services);

            users.Add(new UserCreateRequest()
            {
                Email    = "*****@*****.**",
                Name     = "FAFF",
                Password = "******",
            }, false).GetAwaiter().GetResult();
            users.Add(new UserCreateRequest()
            {
                Email    = "[email protected]",
                Name     = "A",
                Password = "******",
            }, false).GetAwaiter().GetResult();
            BoardData board1 = null;

            services.DoWithDB(async db =>
            {
                var faff  = await db.Users.FirstOrDefaultAsync(u => u.Name == "FAFF");
                var aUser = await db.Users.FirstOrDefaultAsync(u => u.Name == "A");

                board1 = db.Boards.FirstOrDefault() ?? db.Boards.Add(new BoardData()
                {
                    Id          = 1,
                    Title       = "Benefact",
                    UrlName     = "benefact",
                    Description = "Benefact board",
                    Creator     = faff,
                }).Entity;

                var board2 = db.Boards.Skip(1).FirstOrDefault() ?? db.Boards.Add(new BoardData()
                {
                    Id = 2, Title = "FAFF", UrlName = "faff", Creator = faff
                }).Entity;

                aUser.EmailVerified = true;
                faff.EmailVerified  = true;
                faff.Roles.Add(new UserRole()
                {
                    BoardId   = 1,
                    UserId    = faff.Id,
                    Privilege = Privilege.Admin,
                });
                aUser.Roles.Add(new UserRole()
                {
                    BoardId   = 1,
                    UserId    = aUser.Id,
                    Privilege = Privilege.Read,
                });
                db.Tags.Add(new TagData()
                {
                    Name    = "Story",
                    Color   = "#001f3f",
                    BoardId = 1,
                });
                db.Tags.Add(new TagData()
                {
                    Name    = "Dev Task",
                    Color   = "#2ECC40",
                    BoardId = 1,
                });
                db.Tags.Add(new TagData()
                {
                    Name    = "Business Boiz",
                    Color   = "#FF851B",
                    BoardId = 1,
                });
                db.Tags.Add(new TagData()
                {
                    Name      = "Bug",
                    Character = "bug",
                    BoardId   = 1,
                });
                db.Tags.Add(new TagData()
                {
                    Name      = "Star",
                    Color     = "#F012BE",
                    Character = "star",
                    BoardId   = 1,
                });
                db.SaveChanges();
                var todo = db.Columns.Add(new ColumnData()
                {
                    State             = CardState.Proposed,
                    AllowContribution = false,
                    Title             = "To Do",
                    Index             = 1,
                    BoardId           = 1,
                }).Entity;
                var inProgress = db.Columns.Add(new ColumnData()
                {
                    AllowContribution = false,
                    Title             = "In Progress",
                    State             = CardState.InProgress,
                    Index             = 2,
                    BoardId           = 1,
                }).Entity;
                var done = db.Columns.Add(new ColumnData()
                {
                    AllowContribution = false,
                    Title             = "Done",
                    State             = CardState.Complete,
                    Index             = 3,
                    BoardId           = 1,
                }).Entity;
                db.SaveChanges();
                db.Cards.Add(new CardData()
                {
                    Title       = "Get MD Working",
                    Description = "Some Markdown\n=====\n\n```csharp\n var herp = \"derp\";\n```",
                    ColumnId    = todo.Id,
                    TagIds      = new[] { 1, 2, 3, 4, 5 }.ToList(),
                    BoardId     = 1,
                    Index       = 1,
                    AuthorId    = faff.Id,
                    Archived    = false,
                });
                db.Cards.Add(new CardData()
                {
                    Title       = "Make sure UTF8 works 😑",
                    Description = "😈😈😈😈😈😈",
                    ColumnId    = todo.Id,
                    TagIds      = new[] { 1 }.ToList(),
                    BoardId     = 1,
                    Index       = 2,
                    AuthorId    = faff.Id,
                    Archived    = false,
                });
                db.Cards.Add(new CardData()
                {
                    Title       = "Some Bug",
                    Description = "There was a bug",
                    ColumnId    = inProgress.Id,
                    TagIds      = new[] { 4, 2 }.ToList(),
                    BoardId     = 1,
                    Index       = 3,
                    AuthorId    = faff.Id,
                    Archived    = false,
                });
                db.Cards.Add(new CardData()
                {
                    Title       = "Fixed Bug",
                    Description = "There was a bug",
                    ColumnId    = done.Id,
                    TagIds      = new[] { 4 }.ToList(),
                    BoardId     = 1,
                    Index       = 4,
                    AuthorId    = faff.Id,
                    Archived    = false,
                });
                db.SaveChanges();
                return(true);
            }).GetAwaiter().GetResult();
        }
示例#31
0
 public void ConstructSolutionBoard(BoardData solutionBoardData)
 {
     ConstructBoard(solutionBoardData, solutionBoardParent);
 }
示例#32
0
 private void StartGame(BoardData boardData)
 {
     ChessBoard.gameObject.SetActive(true);
     ChessBoard.Create();
     ChessPieceManager.Initialize(boardData, ChessBoard);
 }
示例#33
0
    private void ConstructBoard(BoardData data, Transform boardParent)
    {
        // Getting board parents
        //GameObject shapePrefab = GameManager.manager.shapePrefab;
        float cellSize   = boardParent.GetComponent <GridLayoutGroup>().cellSize.y;
        float shapeSize  = 2.25f * (cellSize / 384);
        int   boardCount = data.boardSize.x * data.boardSize.y;

        boardManager.shapeSize = shapeSize;

        // Declaring Tracker Variables
        GameSlot         slot;
        GameShape        shape;
        SlotLock         slotLock;
        ShapeTransformer shapeTransformer;

        // Loop through the board and set the board state to the data
        for (int i = 0; i < boardCount; i++)
        {
            // Getting the Game Slot/Shape Reference
            slot             = boardParent.GetChild(i).GetComponent <GameSlot>();
            shape            = slot?.GetSlotShape();
            slotLock         = slot?.GetSlotLock();
            shapeTransformer = boardParent.GetChild(i).GetComponent <ShapeTransformer>();

            #region Generating Slot Shape
            if (shape != null)
            {
                // Checking if a shape doesn't exist on the passed in data
                if (data.shapes[i] == null || data.shapes[i].shapeType == GameShape.ShapeType.None)
                {
                    Destroy(shape.gameObject);
                }
                else if (shape.GetShapeData() != data.shapes[i])
                {
                    // Shape does exist but doesn't match the shape in the data, set them to be equivalent
                    shape.SetShapeColor(data.shapes[i].shapeColor);
                    shape.SetShapeType(data.shapes[i].shapeType);
                }
            }
            else
            {
                // Checking to see if a shape exists in the data at the given spot, if so create a new one
                if (data.shapes[i] != null && data.shapes[i].shapeType != GameShape.ShapeType.None)
                {
                    // Creating the shape
                    GameObject newShape = Instantiate(shapePrefab, slot.transform);
                    newShape.transform.localPosition = new Vector3(0.5f, -0.5f, 0f);
                    newShape.transform.localScale    = new Vector3(shapeSize, shapeSize, 0f);

                    // Getting the GameShape reference and setting it equal to the shape in the data
                    GameShape shapeRef = newShape.GetComponent <GameShape>();
                    shapeRef.SetShapeColor(data.shapes[i].shapeColor);
                    shapeRef.SetShapeType(data.shapes[i].shapeType);

                    slot.SetSlotShapeReference(shapeRef.transform);
                }
            }
            #endregion

            #region Generating Slot Lock
            if (slotLock != null)
            {
                LockData lockData = data.locks[i];
                if (lockData != null)
                {
                    Debug.Log($"Generating Slot Lock at Index {i} of type {lockData.lockType} with {lockData.lockTimer} move(s) left");

                    // Active
                    if (lockData.lockTimer > 0)
                    {
                        if (slotLock.GetLockCounter() <= 0)
                        {
                            slotLock.SetLockToActive();
                        }

                        slotLock.SetLockSettings(lockData.lockType, lockData.lockTimer);
                        slot.LockGameSlot();
                    }
                    else if (slotLock.GetLockCounter() > 0)
                    {
                        slotLock.SetLockToDestruct();
                    }
                }
            }
            else
            {
                LockData lockData = data.locks[i];
                if (lockData != null && lockData.lockType != SlotLock.LockType.None)
                {
                    GameObject newLock = Instantiate(slotLockPrefab, slot.transform);
                    newLock.transform.localPosition = new Vector3(0f, -cellSize / 2f, 0f);
                    newLock.transform.localScale    = new Vector3(cellSize / 384f, cellSize / 384f);

                    slotLock = newLock.GetComponent <SlotLock>();
                    slotLock.SetLockSettings(lockData.lockType, lockData.lockTimer);

                    slot.GetComponent <GameSlot>().SetSlotLock(slotLock);
                }
            }
            #endregion

            #region Generate Shape Transformers
            if (shapeTransformer != null)
            {
                shapeTransformer.SetTransformerData(data.transformers[i]);
            }
            #endregion
        }
    }
示例#34
0
 public IMessage CreateGameResultsMessage(BoardData boardData)
 {
     return(DataMessage.FromBoardData(boardData, true));
 }
示例#35
0
 void Start()
 {
     boardData = GameObject.FindGameObjectWithTag("Board").GetComponent <BoardData>();
 }
示例#36
0
 public void Clear()
 {
     _board = new BoardData();
     packetHandler.Clear();
 }
示例#37
0
	private void GetBoardData (BoardData boardData)
	{
		currentIndexSquare = boardData.currentSquare;
		gameState = boardData.gameState;
		character.PositionTo (boardData.currentCharacterPosition + (Vector3.up*2));
		MiniGamesManager.SetMiniGameByIndex (boardData.indexMiniGame,boardData.miniGameState,boardData.minigamesViewed);
		boardData.Unload ();
	}
示例#38
0
 public LevelData(BoardData gameBoardData, BoardData solutionBoardData)
 {
     this.gameBoardData     = gameBoardData;
     this.solutionBoardData = solutionBoardData;
 }
示例#39
0
 void Awake()
 {
     boardData = GetComponentInParent <BoardData>();
 }
	protected virtual void Awake() {
		cachedTransform = transform;
		boardData = GetComponent<BoardData>();
	}
示例#41
0
 public void ConstructGameBoard(BoardData gameBoardData)
 {
     ConstructBoard(gameBoardData, gameBoardParent);
 }
	public virtual void InitComponent() {
//		Debug.Log("[AbstractBoardAnimations] InitComponent...");
		boardData = boardRenderer.Board;
	}
示例#43
0
 public override void Setup()
 {
     _boardData = Parameters.BoardData;
     base.Setup();
 }
 public FigureData(int sizeOfBoard, BoardData board)
 {
     boardSize = sizeOfBoard;
     boardData = board;
 }
示例#45
0
文件: Bbs.cs 项目: plonk/Jimaku2
        private Board CreateBoard(Uri uri)
        {
            Debug.Assert(uri.Host.Equals("jbbs.shitaraba.net", StringComparison.InvariantCultureIgnoreCase));

            Match match;
            match = Regex.Match(uri.AbsolutePath, @"^/([A-Za-z]+)/(\d+)/?$");
            if (!match.Success)
                match = Regex.Match(uri.AbsolutePath, @"^/bbs/read\.cgi/([A-Za-z]+)/(\d+)($|/)");
            Debug.Assert(match.Success);

            Board b = new Board();

            b._server = this;
            var data = new BoardData();

            data.Category = match.Groups[1].Value;
            data.BoardNumber = match.Groups[2].Value;
            b._data = data;

            return b;
        }
示例#46
0
 static BoardData clone(BoardData game)
 {
     GameObject[,] board = new GameObject[8, 8];
     board = game.boardData;
     //board = ;
     return game;
 }
示例#47
0
 private void CreateBoardParent()
 {
     BoardParent = new GameObject("Board");
     BoardParent.AddComponent<BoardData>();
     Data = BoardParent.GetComponent<BoardData>();
 }
示例#48
0
    static void move(BoardData board, int time)
    {
        GameSim currBoard = new GameSim ();
        currBoard.game = clone (board);
        currBoard.selectedPiece = null;
        Debug.Log ("IN AI HOORAY");
        currBoard.bestMove = new Vector3(7,7,0);
        int depth = getDepth (currBoard.game, time);

        ScorePieces (currBoard, depth);

        //Vector3 moveTo =
        //currBoard.selectedPiece.transform.position = moveTo;
    }
示例#49
0
    //private int[] kingBoardLateGameValues = new int[] {
    //            -50,-40,-30,-20,-20,-30,-40,-50,
    //            -30,-20,-10,  0,  0,-10,-20,-30,
    //            -30,-10, 20, 30, 30, 20,-10,-30,
    //            -30,-10, 30, 40, 40, 30,-10,-30,
    //            -30,-10, 30, 40, 40, 30,-10,-30,
    //            -30,-10, 20, 30, 30, 20,-10,-30,
    //            -30,-30,  0,  0,  0,  0,-30,-30,
    //            -50,-30,-30,-30,-30,-30,-30,-50
    //};

    //private int[] kingBoardMirroredLateGameValues = new int[] {
    //            -50,-30,-30,-30,-30,-30,-30,-50,
    //            -30,-30,  0,  0,  0,  0,-30,-30,
    //            -30,-10, 20, 30, 30, 20,-10,-30,
    //            -30,-10, 30, 40, 40, 30,-10,-30,
    //            -30,-10, 30, 40, 40, 30,-10,-30,
    //            -30,-10, 20, 30, 30, 20,-10,-30,
    //            -30,-20,-10,  0,  0,-10,-20,-30,
    //            -50,-40,-30,-20,-20,-30,-40,-50
    //};

    public CellValue(BoardData data)
    {
        boardData = data;
        boardSize = data.BoardSize;
    }
示例#50
0
 public static void removePiece(ref BoardData g, GameObject piece)
 {
 }
示例#51
0
    private void SetUpBoard(BoardData data)
    {
        GameObject hexObject, rowBase;
        bool       bIsRowOffset = false;
        Hexagon    hexScript;

        if (mBoard != null)
        {
            foreach (Hexagon hex in mBoard)
            {
                if (hex != null)
                {
                    Destroy(hex.gameObject);
                }
            }
        }
        mBoard = new Hexagon [data.mBoardSize, data.mBoardSize];
        for (int i = 0; i < data.mBoardSize; i++)
        {
            rowBase   = GameObject.Instantiate(mHexagonPrefab);
            hexScript = rowBase.GetComponent <Hexagon> ();
            hexScript.Initiate(0, i, this);
            if (!bIsRowOffset)
            {
                rowBase.transform.position = new Vector2(-(data.mBoardSize / 2.0f) * hexScript.GetHexWidth(),
                                                         -i * hexScript.GetHexHeight() * (.75f));
                bIsRowOffset = true;
            }
            else
            {
                rowBase.transform.position = new Vector2(-(data.mBoardSize / 2.0f) * hexScript.GetHexWidth() -
                                                         hexScript.GetHexWidth() / 2, -i * hexScript.GetHexHeight() * (.75f));
                bIsRowOffset = false;
            }
            rowBase.transform.parent = this.transform;
            rowBase.name             = "0," + i.ToString();

            for (int j = 1; j < data.mBoardSize; j++)
            {
                if (data.mBoardSpaces [j, i] > 0)
                {
                    hexObject = GameObject.Instantiate(mHexagonPrefab);
                    hexScript = hexObject.GetComponent <Hexagon> ();
                    hexScript.Initiate(j, i, this);
                    hexObject.transform.position = new Vector2(rowBase.transform.position.x + j * hexScript.GetHexWidth(),
                                                               rowBase.transform.position.y);
                    hexObject.transform.parent = this.transform;
                    hexObject.name             = j.ToString() + "," + i.ToString();
                    mBoard [j, i] = hexScript;

                    if (data.mBoardSpaces [j, i] == 2)
                    {
                        mBoard [j, i].EnablePeg(false);
                    }
                }
            }
            if (data.mBoardSpaces [0, i] == 1)
            {
                mBoard [0, i] = hexScript;
            }
            else if (data.mBoardSpaces [0, i] == 2)
            {
                mBoard [0, i] = hexScript;
                mBoard [0, i].EnablePeg(false);
            }
            else
            {
                Destroy(rowBase.gameObject);
            }
        }
    }
示例#52
0
文件: Board.cs 项目: alomi/Ludo
 public Board(BoardData data)
 {
     this.data = data;
 }
示例#53
0
        public static int PieceValue(BoardData boardData, int[] board)
        {
            int score = 0;
            int index = 0;

            for (int i = 21; i <= 98; i++)
            {
                if (i % 10 == 9)
                {
                    i += 2;
                }
                int piece = board[i];
                if (piece != 0)
                {
                    switch (piece)
                    {
                    case (int)WHITE_PAWN:
                        score += 100;
                        score += PAWN[index];
                        score += PawnWeakness(board, true, i);
                        break;

                    case (int)BLACK_PAWN:
                        score -= 100;
                        score -= PAWN[(63 - index) / 8 * 8 + index % 8];
                        score -= PawnWeakness(board, false, i);
                        break;

                    case (int)WHITE_KNIGHT:
                        score += 300;
                        score += KNIGHT[index];
                        score += KnightBonus(i, true, board);
                        break;

                    case (int)BLACK_KNIGHT:
                        score -= 300;
                        score -= KNIGHT[(63 - index) / 8 * 8 + index % 8];
                        score -= KnightBonus(i, false, board);
                        break;

                    case (int)WHITE_BISHOP:
                        score += 330;
                        score += BISHOP[index];
                        score += BishopBonus(i, true, boardData.PieceLocations);
                        break;

                    case (int)BLACK_BISHOP:
                        score -= 330;
                        score -= BISHOP[(63 - index) / 8 * 8 + index % 8];
                        score -= BishopBonus(i, false, boardData.PieceLocations);
                        break;

                    case (int)WHITE_ROOK:
                        score += 500;
                        score += ROOK[index];
                        score += RookBonus(i, true, board);
                        break;

                    case (int)BLACK_ROOK:
                        score -= 500;
                        score -= ROOK[(63 - index) / 8 * 8 + index % 8];
                        score -= RookBonus(i, false, board);
                        break;

                    case (int)WHITE_QUEEN:
                        score += 900;
                        score += QUEEN[index];
                        break;

                    case (int)BLACK_QUEEN:
                        score -= 900;
                        score -= QUEEN[(63 - index) / 8 * 8 + index % 8];
                        break;

                    case (int)WHITE_KING:
                        if (boardData.endGame)
                        {
                            score += KING_END[index];
                        }
                        else
                        {
                            score += KING[index];
                            score += KingSafety(board, i, true);
                        }
                        break;

                    default:
                        if (boardData.endGame)
                        {
                            score -= KING_END[(63 - index) / 8 * 8 + index % 8];
                        }
                        else
                        {
                            score -= KING[(63 - index) / 8 * 8 + index % 8];
                            score -= KingSafety(board, i, false);
                        }
                        break;
                    }
                }
                index++;
            }
            return(score);
        }