コード例 #1
0
ファイル: GameController.cs プロジェクト: yuhengshi/WS
 // Use this for initialization
 void Awake()
 {
     onEnterGame   = GameObject.Find("UIPanel").GetComponent <OnEnterGame>();
     boardSetup    = onEnterGame.boardSetup;
     boardCanvas   = onEnterGame.board.transform.Find("Canvas");
     settingsPanel = onEnterGame.settingsPanel;
     castles       = new Dictionary <string, List <Location> >()
     {
         { "Advisor", boardSetup.boardAttributes.AdvisorCastle() },
         { "Elephant", boardSetup.boardAttributes.ElephantCastle() },
         { "Horse", boardSetup.boardAttributes.HorseCastle() },
         { "Chariot", boardSetup.boardAttributes.ChariotCastle() },
         { "Cannon", boardSetup.boardAttributes.CannonCastle() },
         { "Soldier", boardSetup.boardAttributes.SoldierCastle() },
     };
     flags        = new Dictionary <Location, GameObject>();
     freezeImages = new Dictionary <Location, GameObject>();
     if (OnEnterGame.gameInfo.currentTurn == Login.playerID)
     {
         onEnterGame.YourTurn();
     }
     else
     {
         onEnterGame.EnemyTurn();
     }
 }
コード例 #2
0
ファイル: BoardSetupTest.cs プロジェクト: hsz-gamedev/pgn.net
        public void Index_accessor_should_set_and_get_Pieces_via_Square()
        {
            var sut = new BoardSetup();
            sut[new Square(File.A, 5)] = Piece.BlackKnight;

            Assert.AreEqual(Piece.BlackKnight, sut[new Square(File.A, 5)]);
        }
コード例 #3
0
ファイル: CameraScaler.cs プロジェクト: ashvacuum/Match-3
 // Use this for initialization
 void Start()
 {
     _board       = FindObjectOfType <BoardSetup>();
     cam          = GetComponent <Camera>();
     screenHeight = Screen.height;
     screenWidth  = Screen.width;
 }
コード例 #4
0
ファイル: BoardSetupTest.cs プロジェクト: hsz-gamedev/pgn.net
        public void Index_accessor_should_set_and_get_Pieces_via_integer()
        {
            var sut = new BoardSetup();
            sut[32] = Piece.BlackKnight;

            Assert.AreEqual(Piece.BlackKnight, sut[File.A, 5]);
        }
コード例 #5
0
ファイル: BoardBuilder.cs プロジェクト: Suprndm/gemswipe
        public int[,] StringToModel(BoardSetup boardSetup)
        {
            var boardString = boardSetup.SetupString;
            var rows        = boardString.Split('-');
            var nbOfRows    = rows.Length;
            var nbOfColumns = rows[0].Split(' ').Length;

            _boardModel = new int[nbOfRows, nbOfColumns];

            for (int i = 0; i < nbOfRows; i++)
            {
                var rowCells = rows[i].Split(' ');
                for (int j = 0; j < nbOfColumns; j++)
                {
                    if (rowCells[j] == "BL")
                    {
                        _boardModel[i, j] = -1;
                    }
                    else
                    {
                        int gemValue;
                        int.TryParse(rowCells[j], out gemValue);
                        _boardModel[i, j] = gemValue;
                    }
                }
            }

            return(_boardModel);
        }
コード例 #6
0
ファイル: BoardSetupTest.cs プロジェクト: hsz-gamedev/pgn.net
        public void Index_accessor_should_set_and_get_Pieces()
        {
            var sut = new BoardSetup();
            sut[0, 4] = Piece.BlackKnight;

            Assert.AreEqual(Piece.BlackKnight, sut[0, 4]);
        }
コード例 #7
0
    void OnLoadComplete(AsyncOperationHandle <TextAsset> handle)
    {
        if (handle.Status == AsyncOperationStatus.Succeeded)
        {
            Debug.Log("demoMap Loaded!!");
            string json = handle.Result.ToString();
            DefaultContractResolver contractResolver = new DefaultContractResolver
            {
                NamingStrategy = new CamelCaseNamingStrategy()
            };
            BoardSetup boardSetup = JsonConvert.DeserializeObject <BoardSetup>(json, new JsonSerializerSettings
            {
                ContractResolver = contractResolver,
                Context          = new StreamingContext(StreamingContextStates.All, new DeserializationContext())
            });

            MonopolyWorld world = boardSetup.World;
            world.Width  = boardSetup.Width;
            world.Height = boardSetup.Height;
            world.AddToWorld(Board);
            foreach (TileObject tile in world.GetAll <TileObject>())
            {
                if (tile.ChancePool.Count > 0)
                {
                    Debug.Log($"found a chance!!! at {tile.Position.ToKey()}");
                }
            }
        }
        else
        {
            Debug.Log("Loading map failed");
        }
    }
コード例 #8
0
ファイル: OnEnterGame.cs プロジェクト: yuhengshi/WS
    // Use this for initialization
    void Awake()
    {
        lineup = Login.user.lineups[Login.user.lastLineupSelected];
        board  = Instantiate(Resources.Load <GameObject>("Board/" + lineup.boardName + "/Board"));
        board.transform.SetSiblingIndex(1);
        boardSetup = board.GetComponent <BoardSetup>();
        boardSetup.Setup(lineup, Login.playerID);                                                 // Set up Player Lineup
        boardSetup.Setup(gameInfo.lineups[gameInfo.TheOtherPlayer()], gameInfo.TheOtherPlayer()); // Set up Enemy Lineup
        GameEvent.SetBoard(boardSetup.boardAttributes);

        modeName.text = gameInfo.mode;
        // Set up Player Info
        playerName.text = Login.user.username;
        playerRank.text = "Rank: " + Login.user.rank.ToString();
        // Set up Opponent Info
        opponentName.text = gameInfo.matchInfo[gameInfo.TheOtherPlayer()].playerName;
        opponentRank.text = "Rank: " + gameInfo.matchInfo[gameInfo.TheOtherPlayer()].rank.ToString();

        foreach (var item in gameInfo.triggers)
        {
            item.Value.StartOfGame();
        }
        SetOreText();
        SetCoinText();
        // SetupTactics
        tacticObjs     = new List <Transform>();
        tacticButtons  = new List <Button>();
        tacticTriggers = new List <TacticTrigger>();
        for (int i = 0; i < Lineup.tacticLimit; i++)
        {
            Transform tacticSlot = tacticBag.Find(String.Format("TacticSlot{0}", i));
            tacticButtons.Add(tacticSlot.GetComponent <Button>());
            tacticObjs.Add(tacticSlot.Find("Tactic"));
            tacticObjs[i].GetComponent <TacticInfo>().SetAttributes(Database.FindTacticAttributes(lineup.tactics[i].tacticName));
            tacticTriggers.Add(tacticObjs[i].GetComponent <TacticInfo>().trigger);
        }
        historySlots = new List <GameObject>();
        for (int i = 0; i < history_limit; i++)
        {
            historySlots.Add(history.Find("Slot" + i.ToString()).gameObject);
        }
        //foreach(var item in gameInfo.triggers)
        //{
        //    if (item.Value.passive == "Tactic")
        //    {
        //        foreach (Tactic tactic in lineup.tactics)
        //            if (item.Value.PassiveCriteria(tactic))
        //                item.Value.Passive(tactic);
        //    }
        //    else if(item.Value.passive == "Piece")
        //    {
        //        foreach (var pair in gameInfo.board)
        //            if (item.Value.PassiveCriteria(pair.Value))
        //                item.Value.Passive(pair.Value);
        //    }
        //}
        StartCoroutine(GameStartAnimation());
        StartCoroutine(Timer());
    }
コード例 #9
0
 // Use this for initialization
 void Start()
 {
     graphicBoard = GetComponent <BoardSetup>();
     logicBoard   = GetComponent <AI>();
     UpdatePanelData();
     currentTurn       = TileStatus.EMPTY;
     gameOverText.text = "";
 }
コード例 #10
0
        public void Index_accessor_should_set_and_get_Pieces_via_file_and_rank()
        {
            var sut = new BoardSetup();

            sut[File.A, 5] = Piece.BlackKnight;

            Assert.Equal(Piece.BlackKnight, sut[File.A, 5]);
        }
コード例 #11
0
ファイル: BoardSetupTest.cs プロジェクト: yika-aixi/pgn.net
        public void Index_accessor_should_set_and_get_Pieces()
        {
            var sut = new BoardSetup();

            sut[0, 4] = Piece.BlackKnight;

            Assert.AreEqual(Piece.BlackKnight, sut[0, 4]);
        }
コード例 #12
0
ファイル: BoardSetupTest.cs プロジェクト: yika-aixi/pgn.net
        public void Index_accessor_should_set_and_get_Pieces_via_Square()
        {
            var sut = new BoardSetup();

            sut[new Square(File.A, 5)] = Piece.BlackKnight;

            Assert.AreEqual(Piece.BlackKnight, sut[new Square(File.A, 5)]);
        }
コード例 #13
0
ファイル: BoardSetupTest.cs プロジェクト: yika-aixi/pgn.net
        public void Index_accessor_should_set_and_get_Pieces_via_integer()
        {
            var sut = new BoardSetup();

            sut[32] = Piece.BlackKnight;

            Assert.AreEqual(Piece.BlackKnight, sut[File.A, 5]);
        }
コード例 #14
0
    private void Awake()
    {
        GameObject UIPanel = GameObject.Find("UIPanel");

        boardCanvas     = transform.Find("Canvas");
        onEnterGame     = UIPanel.GetComponent <OnEnterGame>();
        scale           = transform.localScale.x;
        boardSetup      = GetComponent <BoardSetup>();
        boardAttributes = boardSetup.boardAttributes;
        oldLocation     = onEnterGame.oldLocation;
        pathDot         = onEnterGame.pathDot;
    }
コード例 #15
0
        private void Connect_OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            KulamiPeer peer = IncomingChallengesListBox.SelectedPeer();

            if (peer == null)
            {
                return;
            }

            peer.SendResponse(true);
            StartGame(peer,
                      BoardSetup.GetBoard(peer.IncomingRequest.BoardNum),
                      !peer.IncomingRequest.ChallengerGoesFirst);
        }
コード例 #16
0
ファイル: Board.cs プロジェクト: th-tran/bubble-pop
 void Awake()
 {
     boardBomber      = GetComponent <BoardBomber>();
     boardClearer     = GetComponent <BoardClearer>();
     boardCollapser   = GetComponent <BoardCollapser>();
     boardDeadlock    = GetComponent <BoardDeadlock>();
     boardFiller      = GetComponent <BoardFiller>();
     boardHighlighter = GetComponent <BoardHighlighter>();
     boardInput       = GetComponent <BoardInput>();
     boardMatcher     = GetComponent <BoardMatcher>();
     boardQuery       = GetComponent <BoardQuery>();
     boardSetup       = GetComponent <BoardSetup>();
     boardShuffler    = GetComponent <BoardShuffler>();
     boardTiles       = GetComponent <BoardTiles>();
 }
コード例 #17
0
ファイル: BoardSetupTest.cs プロジェクト: hsz-gamedev/pgn.net
        public void square_number_correspondation_test()
        {
            var sut = new BoardSetup();
            sut[0] = Piece.BlackPawn;
            sut[1] = Piece.WhiteKing;
            sut[59] = Piece.BlackRook;
            sut[36] = Piece.WhiteQueen;
            sut[63] = Piece.BlackBishop;

            Assert.AreEqual(Piece.BlackPawn, sut[File.A, 1]);
            Assert.AreEqual(Piece.WhiteKing, sut[File.B, 1]);
            Assert.AreEqual(Piece.BlackRook, sut[File.D, 8]);
            Assert.AreEqual(Piece.WhiteQueen, sut[File.E, 5]);
            Assert.AreEqual(Piece.BlackBishop, sut[File.H, 8]);
        }
コード例 #18
0
ファイル: BoardSetupTest.cs プロジェクト: yika-aixi/pgn.net
        public void square_number_correspondation_test()
        {
            var sut = new BoardSetup();

            sut[0]  = Piece.BlackPawn;
            sut[1]  = Piece.WhiteKing;
            sut[59] = Piece.BlackRook;
            sut[36] = Piece.WhiteQueen;
            sut[63] = Piece.BlackBishop;

            Assert.AreEqual(Piece.BlackPawn, sut[File.A, 1]);
            Assert.AreEqual(Piece.WhiteKing, sut[File.B, 1]);
            Assert.AreEqual(Piece.BlackRook, sut[File.D, 8]);
            Assert.AreEqual(Piece.WhiteQueen, sut[File.E, 5]);
            Assert.AreEqual(Piece.BlackBishop, sut[File.H, 8]);
        }
コード例 #19
0
        /// <summary>
        ///		Convierte los movimientos
        /// </summary>
        private List <MovementBaseModel> ConvertMovements(BoardSetup board, List <BaseMovementModel> movements)
        {
            SquareModel square = new SquareModel();

            // Inicializa el tablero
            if (board == null)
            {
                square.Reset();
            }
            else
            {
                square.Reset(board);
            }
            // Genera los movimientos
            return(new Parsers.MovementConversor(square).Convert(movements));
        }
コード例 #20
0
        public Board(BoardSetup boardSetup, float x, float y, float width, float height) : base(x, y, height, width)
        {
            _maxBoardWidth  = width;
            _maxBoardHeight = width;
            _boardSetup     = boardSetup;

            _randomizer = new Random();

            NbOfRows    = boardSetup.Rows;
            NbOfColumns = boardSetup.Columns;

            UpdateDimensions();
            Setup(boardSetup);

            DeclarePannable(this);
        }
コード例 #21
0
        public GameSetupState()
        {
            UnitLayoutFactory factory = new UnitLayoutFactory();

            factory.GetLayout("s_ship").Setup(UnitLayout.Type.SShip, "+");
            factory.GetLayout("m_ship").Setup(UnitLayout.Type.MShip, "++");
            factory.GetLayout("l_ship").Setup(UnitLayout.Type.LShip, "+++");
            factory.GetLayout("xl_ship").Setup(UnitLayout.Type.XLShip, "++++");
            BoardSetup.factory = factory;

            setup = new BoardSetup();

            handler = new ChatHandler();
            handler.SetSuccessor(new GameSetupHandler(setup)).SetSuccessor(new UserHandler()).SetSuccessor(new HelpHandler());
            PrintWelcomeMessage2();
        }
コード例 #22
0
ファイル: FenParser.cs プロジェクト: jbautistam/BauChess
        /// <summary>
        ///		Interpreta una cadena FEN
        /// </summary>
        internal BoardSetup Parse(string fen)
        {
            BoardSetup board = new BoardSetup();

            // Interpreta la cadena
            if (!string.IsNullOrEmpty(fen))
            {
                string [] parts = fen.Trim().Split(' ');

                if (parts.Length == 6)
                {
                    // Obtiene las piezas del tablero
                    board.Pieces.AddRange(ParseBoardPieces(parts[0]));
                    // Obtiene si tienen que jugar blancas o negras
                    // “w” significa que mueven las blancas y “b” las negras
                    board.Parameters.IsWhiteMove = parts[1].Equals("W", StringComparison.CurrentCultureIgnoreCase);
                    // Obtiene la posibilidad de enroques
                    // Si el enroque ya no es posible para ninguna de las partes, se coloca el carácter “-“.
                    // De lo contrario, irán una o más letras: “K” (es posible el enroque en el flanco del rey blanco),
                    // “Q” (es posible el enroque en el flanco de la dama blanca), “k” (es posible el enroque en el flanco
                    // del rey negro), y/o “q” (es posible el enroque en el flanco de la dama negra).
                    board.Parameters.CanWhiteCastleKingSide  = parts[2].IndexOf("K") >= 0;
                    board.Parameters.CanWhiteCastleQueenSide = parts[2].IndexOf("Q") >= 0;
                    board.Parameters.CanBlackCastleKingSide  = parts[2].IndexOf("k") >= 0;
                    board.Parameters.CanBlackCastleQueenSide = parts[2].IndexOf("q") >= 0;
                    // Captura al paso
                    //  Posibilidad de captura al paso de un peón en notación algebraica. Si no hay posibilidad de
                    // captura al paso de ningún peón, se colocará el carácter “-“. Si un peón acaba de hacer una
                    // jugada de 2 cuadros, se pondrá la casilla que está “detrás” del peón. Ésta se deberá poner
                    // independientemente de si hay o no algún peón en condiciones de realizar una captura al paso.
                    if (parts[3] != "-")
                    {
                        board.Parameters.EnPassantCellTarget = new CellModel(parts[3]);
                    }
                    // Número de medios movimientos
                    // Número de medios movimientos desde la última captura o avance de peón. Esto se utiliza para determinar si unas tablas
                    // pueden ser reclamadas en virtud de la regla de los cincuenta movimientos.
                    board.Parameters.HalfMoveClock = GetInt(parts[4]);
                    // Número total de movimientos de la partida.
                    // Tiene el valor de 1 para la posición inicial y se va incrementando con cada movimiento de las negras.
                    board.Parameters.FullMoveCount = GetInt(parts[5]);
                }
            }
            // Devuelve los datos del tablero
            return(board);
        }
コード例 #23
0
ファイル: Board.cs プロジェクト: JamieKennedy/Chess
    public void Start()
    {
        dead = GameObject.FindGameObjectWithTag("Dead");
        BoardSetup setup = this.gameObject.GetComponent <BoardSetup>();

        playerManager = this.gameObject.GetComponent <PlayerManager>();
        setup.InitBoard();
        setup.InitPlayers();
        setup.InitPieces();



        board = setup.GetBoard();


        playerManager.SetInitialTurnState();
    }
コード例 #24
0
        private void Play_OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            // Set up game engine
            HumanPlayer humanPlayerRed   = new HumanPlayer(PlayerOneNamePrompt.Text, GameBoardUserControl.human_move_handler);
            HumanPlayer humanPlayerBlack = new HumanPlayer(PlayerTwoNamePrompt.Text, GameBoardUserControl.human_move_handler);

            Board board = BoardSetup.Random();

            GameBoardUserControl control = new GameBoardUserControl(
                board,
                humanPlayerRed,
                humanPlayerBlack,
                PieceType.Red
                );

            ContentControlActions.setBaseContentControl(control);
        }
コード例 #25
0
        public GameBoardUserControl(Board board, Player playerOne, Player playerTwo, PieceType firstType)
        {
            InitializeComponent();

            //this gets the board configuration and shows the proper mask on the gameboard
            setGameboardConfig(BoardSetup.FromBoard(board));

            HumanPlayerName.Content = playerOne.GetName();
            RobotPlayerName.Content = playerTwo.GetName();

            engine = new GameEngine(board, playerOne, playerTwo, firstType);

            inactiveImages = new[, ]
            {
                { p00, p01, p02, p03, p04, p05, p06, p07 },
                { p10, p11, p12, p13, p14, p15, p16, p17 },
                { p20, p21, p22, p23, p24, p25, p26, p27 },
                { p30, p31, p32, p33, p34, p35, p36, p37 },
                { p40, p41, p42, p43, p44, p45, p46, p47 },
                { p50, p51, p52, p53, p54, p55, p56, p57 },
                { p60, p61, p62, p63, p64, p65, p66, p67 },
                { p70, p71, p72, p73, p74, p75, p76, p77 }
            };

            activeImages = new Image[8, 8];

            humanTurn   = false;
            humanMove   = Move.None;
            validMoves  = new Move[0];
            playedMoves = new List <Move>();

            PlayerOne = playerOne;
            PlayerTwo = playerTwo;

            engine.OnPlayerChanged += on_player_changed;
            engine.OnPlayerMove    += on_player_moved;
            engine.OnGameEnd       += on_game_end;

            setUpPlayerCustom(playerOne);
            setUpPlayerCustom(playerTwo);
            difficultyIsHard = !(playerTwo is EasyAiPlayer);

            engine.start();

            VolumeManager.playBattleTheme();
        }
        public GameplayState(BoardSetup yourBoard, BoardSetup opponentBoard, bool _yourTurn)
        {
            TurnHandler turnHandler = new TurnHandler();

            turnHandler.SetSuccessor(new ChatHandler()).SetSuccessor(new UserHandler()).SetSuccessor(new HelpHandler());

            turnHandler.instance = new GameInstance(yourBoard, opponentBoard, _yourTurn);

            handler = turnHandler;

            if (_yourTurn)
            {
                Console.WriteLine("Your turn");
            }
            else
            {
                Console.WriteLine("Its opponents turn");
            }
        }
コード例 #27
0
        private void startGame()
        {
            ContentControlActions.FadeOut();

            // Set up game engine
            HumanPlayer humanPlayer = new HumanPlayer(GameBoardUserControl.human_move_handler);
            Player      AiPlayer    = gameModeIsHard ? (Player) new HardAiPlayer() : new EasyAiPlayer();

            Board board = BoardSetup.Random();

            GameBoardUserControl control = new GameBoardUserControl(
                board,
                humanPlayer,
                AiPlayer,
                playerGoesFirst ? PieceType.Red : PieceType.Black
                );

            ContentControlActions.setBaseContentControl(control);
        }
コード例 #28
0
        private void on_game_response(object sender, NetGameResponseEventArgs e)
        {
            KulamiPeer peer = sender as KulamiPeer;

            if (peer == null)
            {
                return;
            }

            if (e.ChallengeAccpeted)
            {
                StartGame(peer, BoardSetup.GetBoard(e.BoardNum), e.ChallengerGoesFirst);
            }
            else
            {
                Dispatcher.Invoke(() =>
                {
                    IncomingChallengesListBox.RemovePeer(peer, IncomingChallengesCanvas);
                });
            }
        }
コード例 #29
0
    // Use this for initialization
    void Start()
    {
        if (board == null)
        {
            populateBoardArray();
        }
        if (setup == null)
        {
            setup = new BoardSetup();
        }

        if (!isServer)
        {
            return;
        }

        for (int yCoord = -boardSize; yCoord <= boardSize; yCoord++)
        {
            for (int xCoord = -boardSize; xCoord <= boardSize; xCoord++)
            {
                int distance = axialHexdistance(new int[] { xCoord, yCoord }, new int[] { 0, 0 });
                if (distance <= boardSize)
                {
                    HexType hexType = setup.getRandomHex();
                    int     token;
                    if (hexType != HexType.DESERT)
                    {
                        token = setup.getRandomToken();
                    }
                    else
                    {
                        token = -1;
                    }
                    createHex(xCoord, yCoord, hexType, token);
                }
            }
        }
    }
コード例 #30
0
 private void Start()
 {
     _match = FindObjectOfType <MatchFinder>();
     _board = FindObjectOfType <BoardSetup>();
 }
コード例 #31
0
ファイル: Program.cs プロジェクト: wesIdeal/PgnTool.Net
        public static string GetFen(this BoardSetup b)
        {
            string output = "";

            Piece  piece;
            string row, pieceStr, castleStr, epStr;
            int    emptySquares;

            for (int iRank = 0; iRank < 8; ++iRank)
            {
                row          = "";
                emptySquares = 0;
                for (int iFile = 0; iFile < 8; ++iFile)
                {
                    piece = b[iFile, iRank];
                    if (piece == null)
                    {
                        emptySquares += 1;
                    }
                    else
                    {
                        if (emptySquares > 0)
                        {
                            row += emptySquares.ToString();
                        }
                        pieceStr     = PieceToString(b[iFile, iRank]);
                        row         += pieceStr.Trim();
                        emptySquares = 0;
                    }
                    if (iFile > 0 & iFile % 7 == 0)
                    {
                        if (emptySquares > 0)
                        {
                            row += emptySquares.ToString();
                        }
                        output += row;
                        if (iRank < 7)
                        {
                            output += "/";
                        }
                    }
                }
            }

            if (b.IsWhiteMove)
            {
                output += " w";
            }
            else
            {
                output += " b";
            }

            castleStr = " ";
            if (b.CanWhiteCastleKingSide)
            {
                castleStr += "K";
            }
            if (b.CanWhiteCastleQueenSide)
            {
                castleStr += "Q";
            }
            if (b.CanBlackCastleKingSide)
            {
                castleStr += "k";
            }
            if (b.CanBlackCastleQueenSide)
            {
                castleStr += "q";
            }

            if (castleStr.Length > 1)
            {
                output += castleStr;
            }
            else
            {
                output += " -";
            }

            epStr = "-";
            if (b.EnPassantSquare != null)
            {
                epStr = b.EnPassantSquare.ToString();
            }
            output += " " + epStr;

            output += " " + b.HalfMoveClock.ToString();
            output += " " + b.FullMoveCount.ToString();

            return(output);
        }
コード例 #32
0
ファイル: Board.cs プロジェクト: IsaiahDahlberg/Chess
 public void SetBoard()
 {
     Grid = new Grid(BoardSetup.CreateGridCellList());
 }
コード例 #33
0
        public void SerialiseTest()
        {
            BoardSetup a = new BoardSetup
            {
                Name = "a",
                Timer = null,
                Create = true,
                Disabled = false,
                Pages = 5,
                Repeat = true,
                SaveDirectory = @"C:\Temp\",
                Sleep = 20
            };

            BoardSetup b = new BoardSetup
            {
                Name = "b",
                Timer = new BoardTimer { Days = 0, Hours = 0, Minutes = 0, Seconds = 0, Disabled = true },
                Create = true,
                Disabled = false,
                Pages = 5,
                Repeat = true,
                SaveDirectory = @"C:\Temp\",
                Filter = new BoardThreadFilter { ImageCount = 3 },
                Sleep = 30
            };

            BoardSetup c = new BoardSetup
            {
                Name = "c",
                Timer = new BoardTimer { Days = 0, Hours = 0, Minutes = 0, Seconds = 0, Disabled = true },
                Create = true,
                Disabled = true,
                Pages = 10,
                Repeat = false,
                SaveDirectory = @"C:\Temp2\",
                Filter = new BoardThreadFilter { ImageCount = 10 },
                Sleep = 30
            };

            BoardSetup d = new BoardSetup
            {
                Name = "d",
                Timer = new BoardTimer { Days = 0, Hours = 0, Minutes = 20, Seconds = 0, Disabled = false },
                Create = false,
                Disabled = false,
                Pages = 5,
                Repeat = true,
                SaveDirectory = @"C:\Temp2\",
                Filter = new BoardThreadFilter { ImageCount = 3 },
                Sleep = 60
            };

            BoardSetup e = new BoardSetup
            {
                Name = "e",
                Timer = new BoardTimer { Days = 0, Hours = 0, Minutes = 20, Seconds = 0, Disabled = true },
                Create = false,
                Disabled = false,
                Pages = 15,
                Repeat = true,
                SaveDirectory = @"C:\Temp2\",
                Filter = new BoardThreadFilter { ImageCount = 3 },
                Sleep = 10
            };

            var config = new BoardConfig { Boards = new List<BoardSetup>() { a, b, c, d } };

            using (var writer = new StreamWriter(Environment.CurrentDirectory + "\\config.xml"))
            {
                new XmlSerializer(typeof(BoardConfig)).Serialize(writer, config);
            }

            using (var reader = new StreamReader(Environment.CurrentDirectory + "\\config.xml"))
            {
                object deserialize = new XmlSerializer(typeof(BoardConfig)).Deserialize(reader);

                config = deserialize as BoardConfig;

                Assert.NotNull(config);
            }

            foreach(var board in config.Boards)
            {
                Assert.NotNull(board.Timer);
            }
        }
コード例 #34
0
        private async Task Setup(BoardSetup boardSetup)
        {
            _isBusy = true;

            IGems     = new List <IGem>();
            Gems      = new List <Gem>();
            CellsList = new List <Cell>();
            var boardString = boardSetup.SetupString;

            var rows        = boardString.Split('-');
            var nbOfRows    = rows.Length;
            var nbOfColumns = rows[0].Split(' ').Length;


            for (int j = 0; j < nbOfRows; j++)
            {
                var rowCells = rows[j].Split(' ');
                for (int i = 0; i < nbOfColumns; i++)
                {
                    IList <string> splitData = SplitCellGemData(rowCells[i]);
                    Cell           cell      = CreateCell(i, j, splitData[0]);
                    CellsList.Add(cell);

                    Gem gem = CreateGem(i, j, splitData[1]);
                    if (gem != null)
                    {
                        AddChild(gem);
                        cell.Assign(gem);
                        IGems.Add(gem);
                        if (gem is Gem)
                        {
                            Gems.Add(gem);
                        }
                    }
                }
            }

            var maxNbOfColumns = 0;
            var maxNbOfRows    = 0;

            foreach (var cell in CellsList)
            {
                maxNbOfColumns = Math.Max(maxNbOfColumns, cell.IndexX + 1);
                maxNbOfRows    = Math.Max(maxNbOfRows, cell.IndexY + 1);
            }

            NbOfRows    = maxNbOfRows;
            NbOfColumns = maxNbOfColumns;
            Cells       = new Cell[NbOfColumns, NbOfRows];

            for (int i = 0; i < NbOfColumns; i++)
            {
                for (int j = 0; j < NbOfRows; j++)
                {
                    Cells[i, j] = CellsList.Single(cell => cell.IndexX == i && cell.IndexY == j);
                }
            }

            await PopGems();
            await AnimationsEnded();

            _isBusy = false;
        }
コード例 #35
0
ファイル: MatchFinder.cs プロジェクト: ashvacuum/Match-3
 private void Start()
 {
     _board = FindObjectOfType <BoardSetup>();
 }