コード例 #1
0
ファイル: UnitTest1.cs プロジェクト: rynnnaa/WeDoku
        public void CanSetGameSpaceMaksked()
        {
            GameSpace gameSpace = new GameSpace();

            gameSpace.Masked = true;
            gameSpace.Masked = false;

            Assert.False(gameSpace.Masked);
        }
コード例 #2
0
ファイル: UnitTest1.cs プロジェクト: rynnnaa/WeDoku
        public void CanSetGameSpaceValue()
        {
            GameSpace gameSpace = new GameSpace();

            gameSpace.Value = 2;
            gameSpace.Value = 1;

            Assert.Equal(1, gameSpace.Value);
        }
コード例 #3
0
ファイル: UnitTest1.cs プロジェクト: rynnnaa/WeDoku
        public void CanSetGameSpaceX()
        {
            GameSpace gameSpace = new GameSpace();

            gameSpace.X = 2;
            gameSpace.X = 1;

            Assert.Equal(1, gameSpace.X);
        }
 public async Task UnselectPieceAsync(GameSpace thisSpace)
 {
     if (PreviousPiece.Equals(thisSpace))
     {
         PreviousPiece = new Vector();
     }
     SelectUnSelectSpace(thisSpace);
     await _thisState.SaveSimpleSinglePlayerGameAsync(_saveRoot);
 }
コード例 #5
0
        async Task ISolitaireBoardEvents.PieceSelectedAsync(GameSpace space, SolitaireBoardGameMainGameClass game)
        {
            if (space.Vector.Equals(game.PreviousPiece) == false)
            {
                await game.HightlightSpaceAsync(space);

                return;
            }
            game.SelectUnSelectSpace(space);
        }
コード例 #6
0
ファイル: GameHub.cs プロジェクト: rynnnaa/WeDoku
        /// <summary>
        ///     Contains the game logic for the sudoku board. When connected clients make a request to this
        ///      hub endpoint, they send down an x coordinate, a y coordinate, the ID associated with the board
        ///      they are currently playing on, and the value they are attempting to place on a space.
        ///
        ///     All of the given values are first parsed into integers. Then, the GameSpace entry associated with
        ///     the given boardID and x/y coordinates is located, and its stored value compared to the input value
        ///     from the user. If the user guessed the value incorrectly, Signal R is used to indicate an incorrect
        ///     guess on their browser. If the input matches the gamespace's value, and the gamespace is currently masked
        ///     (not displayed, i.e. not played on), the board is updated with the new number of completed spaces,
        ///     the gamespace entry is updated as being "unmasked", i.e. displayed, and all client browsers are sent a
        ///     signal r trigger to "unmask" the space and show its value, removing the input form for that space.\
        ///
        ///     If, after a space is successfully unmasked, the board is completed, i.e. its "placed" value reaches 81,
        ///     the game is complete. A new gameboard is generated, a trigger is sent to all client browsers to show that
        ///     the board has been completed, displaying a link to reload the page and display the newly updated gameboard.
        ///
        /// </summary>
        /// <param name="x"> x coordinate of the space a player is trying to fill </param>
        /// <param name="y"> y coordinate of the space a player is trying to fill </param>
        /// <param name="boardID"> ID of the board the user is currently playing on </param>
        /// <param name="value"> value that the user is trying to place on a space </param>
        /// <returns></returns>
        public async Task SendCoordinate(string x, string y, string boardID, string value)
        {
            int input  = int.Parse($"{value}");
            int bID    = int.Parse($"{boardID}");
            int xCoord = int.Parse($"{x}");
            int yCoord = int.Parse($"{y}");

            if (input < 10 && input > 0)
            {
                GameSpace spaceToUpdate = await _gsManager.GetGameSpace(xCoord, yCoord, bID);

                if (input == spaceToUpdate.Value)
                {
                    if (spaceToUpdate.Masked)
                    {
                        spaceToUpdate.Masked = false;
                        await _gsManager.UpdateGameSpace(spaceToUpdate);

                        GameBoard board = await _boardManager.GetJustBoard(bID);

                        board.Placed++;
                        if (board.Placed >= 81)
                        {
                            await Clients.All.SendAsync("UpdateSpace", x, y, value);

                            await Clients.All.SendAsync("BoardComplete");

                            GridBuilder builder = new GridBuilder(50);
                            board = builder.BuildGameBoard(bID);
                            await _boardManager.UpdateGameBoard(board);

                            await Clients.All.SendAsync("NewBoardReady");
                        }
                        else
                        {
                            await _boardManager.UpdateGameBoard(board);

                            await Clients.All.SendAsync("UpdateSpace", x, y, value);
                        }
                    }
                    else
                    {
                        Console.Write("ayyy");
                    }
                }
                else
                {
                    await Clients.Caller.SendAsync("ErrorMessage", x, y, value, "Incorrect! Try again.");
                }
            }
            else
            {
                await Clients.Caller.SendAsync("ErrorMessage", x, y, value, "Value was not within valid range. Values must be integers between 1 and 9");
            }
        }
コード例 #7
0
ファイル: Board.cs プロジェクト: BigBoyMuscles/gridtown
    public GameSpace[] getColumn(int x)
    {
        GameSpace[] column = new GameSpace[boardSize];

        for (int y = 0; y < column.Length; y++)
        {
            column[y] = getTile(x, y);
        }

        return(column);
    }
コード例 #8
0
ファイル: Board.cs プロジェクト: BigBoyMuscles/gridtown
    public GameSpace[] getRow(int y)
    {
        GameSpace[] row = new GameSpace[boardSize];

        for (int x = 0; x < row.Length; x++)
        {
            row[x] = getTile(x, y);
        }

        return(row);
    }
コード例 #9
0
    static public GameSpace get()
    {
        GameSpace gs = GameObject.FindObjectOfType <GameSpace>();

        if (gs == null)
        {
            return(null);
        }
        gs.updateSize();
        return(gs);
    }
コード例 #10
0
        async Task ISolitaireBoardEvents.PiecePlacedAsync(GameSpace space, SolitaireBoardGameMainGameClass game)
        {
            if (game.IsValidMove(space) == false)
            {
                await UIPlatform.ShowMessageAsync("Illegal Move");

                await game.UnselectPieceAsync(space);

                return;
            }
            await game.MakeMoveAsync(space);
        }
コード例 #11
0
        public GameSpace[,] GetGameSpaces()
        {
            var spaces = new GameSpace[3, 3];

            for (int x = 0; x < 3; x++)
            {
                for (int y = 0; y < 3; y++)
                {
                    spaces[x, y] = new GameSpace();
                }
            }
            return(spaces);
        }
コード例 #12
0
        public Village(GameSpace space, object owner) : base(space, owner)
        {
            NWField fld = (NWField)owner;
            ExtRect v   = fld.AreaRect;

            v.Left   += 18;
            v.Right  -= 18;
            v.Top    += 7;
            v.Bottom -= 5;
            Area      = v;

            Gates = new List <ExtPoint>();
        }
        public async Task ProcessCommandAsync(GameSpace thisSpace)
        {
            if (thisSpace.HasImage == false)
            {
                if (PreviousPiece.Column == 0 || PreviousPiece.Row == 0)
                {
                    return; // because nothing selected
                }
                await _solitaireBoard.PiecePlacedAsync(thisSpace, this);

                return;
            }
            await _solitaireBoard.PieceSelectedAsync(thisSpace, this);
        }
 public void SelectUnSelectSpace(GameSpace thisSpace)
 {
     foreach (GameSpace tempSpace in _saveRoot.SpaceList)
     {
         tempSpace.ClearSpace();
     }
     if (thisSpace == PreviousSpace)
     {
         PreviousSpace = new GameSpace();
     }
     else
     {
         PreviousSpace       = thisSpace;
         PreviousSpace.Color = cs.Yellow;
     }
 }
        public bool IsValidMove(GameSpace thisSpace)
        {
            GameSpace previousSpace;

            previousSpace = _saveRoot.SpaceList[PreviousPiece];
            if (thisSpace.Vector.Column != previousSpace.Vector.Column &&
                thisSpace.Vector.Row != previousSpace.Vector.Row)
            {
                return(false);
            }
            IEnumerable <GameSpace> thisCol;

            thisCol = MoveList(thisSpace, previousSpace);
            if (thisCol.Count() == 0)
            {
                return(false);
            }
            return(!thisCol.Any(Items => Items.HasImage == false));
        }
コード例 #16
0
ファイル: Player.cs プロジェクト: MrP78/MIniWar
 void Start()
 {
     ai                 = GameObject.FindObjectOfType <AI>();
     anim               = GetComponent <Animator>();
     turnover           = GameObject.FindObjectOfType <TurnOver>();
     atri               = GetComponent <CharacterAtributes>();
     gather             = GameObject.FindObjectOfType <InformationGatherer>();
     moveChecker        = GameObject.FindObjectOfType <MoveChecker>();
     healthBar.maxValue = atri.health;
     healthBar.value    = atri.health;
     ActionMenu         = GameObject.FindObjectOfType <Menu>();
     canvas             = GameObject.Find("ActionMenu").GetComponentInChildren <Canvas>();
     canvas.enabled     = false;
     menu               = GameObject.Find("ActionMenu").GetComponentInChildren <Dropdown>();
     menu.ClearOptions();
     menu.AddOptions(DropOptions1);
     menu.Hide();
     orginalMoves = moves;
     ps           = GetComponent <ParticleSystem>();
     gameSpace    = GameObject.FindObjectOfType <GameSpace>();
 }
コード例 #17
0
    void Start()
    {
        // 2-step process to getting a game object and only then referencing a script
        // Apparently, must use a GameObject to "get" a script from
        gameSpaceObj    = GameObject.Find("Maze");
        gameSpaceScript = gameSpaceObj.GetComponent <GameSpace> ();

        itemCollected            = GameObject.FindGameObjectWithTag("ItemCollected");
        itemCollectedAudioSource = itemCollected.GetComponent <AudioSource> ();
        itemCollectedClip        = itemCollectedAudioSource.clip;

        winAudio       = GameObject.FindGameObjectWithTag("YouWin");
        winAudioSource = winAudio.GetComponent <AudioSource> ();
        winClip        = winAudioSource.clip;

        camera = GameObject.FindGameObjectWithTag("MainCamera");
        camera.transform.position = this.transform.position + new Vector3(0f, 0f, -10f);
        camera.transform.parent   = this.transform;

        animator = GetComponent <Animator> ();
    }
コード例 #18
0
    //Get references to neighbor tiles
    private void getNeighbors()
    {
        if (hasNeighbor.north)
        {
            north = board.getTile(coordinates + Vector2.up);
        }

        if (hasNeighbor.east)
        {
            east = board.getTile(coordinates + Vector2.right);
        }

        if (hasNeighbor.south)
        {
            south = board.getTile(coordinates + Vector2.down);
        }

        if (hasNeighbor.west)
        {
            west = board.getTile(coordinates + Vector2.left);
        }
    }
コード例 #19
0
ファイル: Rook.cs プロジェクト: BigBoyMuscles/gridtown
    public override Vector2[] getMoves()
    {
        GameSpace[] row    = gameBoard.getRow((int)controller.getCoordinates().y);
        GameSpace[] column = gameBoard.getColumn((int)controller.getCoordinates().x);

        int mSize = row.Length + column.Length;

        GameSpace[] m = new GameSpace[mSize];

        Array.Copy(row, m, row.Length);
        Array.Copy(column, 0, m, row.Length, column.Length);

        Vector2[] validMoves = new Vector2[m.Length];

        for (int i = 0; i < validMoves.Length; i++)
        {
            validMoves[i] = m[i].getCoordinates();
            Debug.Log("Valid Move: " + validMoves[i]);
        }

        return(validMoves);
    }
コード例 #20
0
        /// <summary>
        /// Handeling KeyDown Events for left, right, and down
        /// </summary>
        private void Window_KeyDown(object sender, KeyEventArgs e)
        {
            if (ButtonNewGame.IsVisible == true && e.Key == Key.Up)
            {
                GameSpace = new GameSpace(this);
                return;
            }

            else if (GameSpace == null)
            {
                return;
            }

            else if (!GameSpace.isCountdown && !GameSpace.IsGame && ButtonStart.IsVisible == true && e.Key == Key.Up)
            {
                GameSpace.isCountdown = true;
                GameSpace.StartCountDown();
                return;
            }

            if (GameSpace.IsGame)
            {
                switch (e.Key)
                {
                case Key.Left:
                case Key.Right:
                    //case Key.Down:
                    GameSpace.KeyDown(e.Key);
                    e.Handled = true;
                    break;

                default:
                    break;
                }
            }
        }
コード例 #21
0
 public Item(GameSpace space, object owner)
     : base(space, owner)
 {
     Frame = 0;
     State = ItemState.is_Normal;
 }
        private IEnumerable <GameSpace> MoveList(GameSpace thisSpace, GameSpace previousSpace)
        {
            IEnumerable <GameSpace> output;

            if (thisSpace.Vector.Column == previousSpace.Vector.Column)
            {
                if (thisSpace.Vector.Row > previousSpace.Vector.Row)
                {
                    output = from Spaces in _saveRoot.SpaceList
                             where Spaces.Vector.Column == thisSpace.Vector.Column
                             & Spaces.Vector.Row > previousSpace.Vector.Row & Spaces.Vector.Row < thisSpace.Vector.Row
                             select Spaces;
                    if (output.Count() > 0)
                    {
                        output = from Moves in output
                                 orderby Moves.Vector.Row
                                 select Moves;
                    }
                }
                else
                {
                    output = from Spaces in _saveRoot.SpaceList
                             where Spaces.Vector.Column == thisSpace.Vector.Column &
                             Spaces.Vector.Row <previousSpace.Vector.Row& Spaces.Vector.Row> thisSpace.Vector.Row
                             select Spaces;
                    if (output.Count() > 0)
                    {
                        output = from Moves in output
                                 orderby Moves.Vector.Row descending
                                 select Moves;
                    }
                }
                return(output);
            }
            if (thisSpace.Vector.Column > previousSpace.Vector.Column)
            {
                output = from Spaces in _saveRoot.SpaceList
                         where Spaces.Vector.Row == thisSpace.Vector.Row &
                         Spaces.Vector.Column > previousSpace.Vector.Column & Spaces.Vector.Column < thisSpace.Vector.Column
                         select Spaces;
                if (output.Count() > 0)
                {
                    output = from Moves in output
                             orderby Moves.Vector.Row
                             select Moves;
                }
                return(output);
            }
            else
            {
                output = from Spaces in _saveRoot.SpaceList
                         where Spaces.Vector.Row == thisSpace.Vector.Row &
                         Spaces.Vector.Column <previousSpace.Vector.Column& Spaces.Vector.Column> thisSpace.Vector.Column
                         select Spaces;
                if (output.Count() > 0)
                {
                    output = from Moves in output
                             orderby Moves.Vector.Row descending
                             select Moves;
                }
                return(output);
            }
        }
コード例 #23
0
 public Region(GameSpace space, object owner)
     : base(space, owner)
 {
 }
コード例 #24
0
 public GameEvent(GameSpace space, object owner)
     : base(space, owner)
 {
 }
コード例 #25
0
 public MapObject(GameSpace space, object owner)
     : base(space, owner)
 {
     Loops    = 1;
     AnimKind = AnimationKind.None;
 }
コード例 #26
0
 public async Task MakeMoveAsync(GameSpace space)
 {
     await _mainGame.ProcessCommandAsync(space);
 }
コード例 #27
0
 public BaseRoom(GameSpace space, object owner)
     : base(space, owner)
 {
     fDoorList = new ExtList <Door>(true);
 }
 public async Task HightlightSpaceAsync(GameSpace thisSpace)
 {
     SelectUnSelectSpace(thisSpace);
     PreviousPiece = thisSpace.Vector;
     await _thisState.SaveSimpleSinglePlayerGameAsync(_saveRoot);
 }
コード例 #29
0
ファイル: Gate.cs プロジェクト: nullsweet/NorseWorld-Ragnarok
 public Gate(GameSpace space, object owner) : base(space, owner)
 {
 }
コード例 #30
0
 void Start()
 {
     _spawnInto = GameManager.main.shipPool;
     _gameSpace = GameManager.main.gameSpace;
 }