Пример #1
0
    void SpawnPlayer(int num)
    {
        playerNum = num;
        BoardLocation pos = new BoardLocation( new IntVector2(0,0), new IntVector2( 0, 0 ) );
        int x = 1;
        int y = 1;
        switch (num)
        {
            case 0: x = 1; y = 1; break;
            case 1: x = 17; y = 1; break;
            case 2: x = 1; y = 8; break;
            case 3: x = 17; y = 8; break;
        }

        pos = new BoardLocation( new IntVector2( x, y ), pos.offset );

        PacmanData player = (PacmanData)((GameObject) Network.Instantiate(playerPrefab, new Vector3(0,0,0), Quaternion.identity, 0)).GetComponent<PacmanData>();

        PacmanData animate = player.GetComponent<PacmanData>();
        animate.Data.maxSpeed = 8;
        animate.Data.boardLocation = pos;

        animate.setPlayerNum(playerNum);

        SpawnGhost();
    }
 public void board_should_return_white_when_asked_for_third_from_left_top_square()
 {
     BoardLocation board = new BoardLocation(2,0);
     BlackWhiteColor expected = BlackWhiteColor.White;
     BlackWhiteColor actual = board.GetSquareColor();
     Assert.AreEqual(expected, actual);
 }
Пример #3
0
    void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
    {
        BoardLocation newLocation= new BoardLocation(new IntVector2(0,0), new IntVector2(0,0));
        int maxSpeed = 0;
        IntVector2 direction = new IntVector2(0,0);
        BoardLocation lastBoardLocation = new BoardLocation(new IntVector2( 0, 0), new IntVector2(0,0));

        if (stream.isWriting)
        {
            newLocation = this.boardLocation;
            maxSpeed = this.maxSpeed;
            direction = this.direction;
            lastBoardLocation = this.lastBoardLocation;

            newLocation.Serialize( stream );
            stream.Serialize( ref maxSpeed );
            direction.Serialize( stream );
            lastBoardLocation.Serialize( stream );
        }
        else
        {
            newLocation.DeSerialize( stream );
            stream.Serialize( ref maxSpeed );
            direction.DeSerialize( stream );
            lastBoardLocation.DeSerialize( stream );

            this.boardLocation = newLocation;
            this.maxSpeed = maxSpeed;
            this.direction = direction;
            this.lastBoardLocation = lastBoardLocation;
        }
    }
 public void board_should_return_black_when_asked_for_color_of_top_right_square()
 {
     BoardLocation board = new BoardLocation(7,0);
     BlackWhiteColor expected = BlackWhiteColor.Black;
     BlackWhiteColor actual = board.GetSquareColor();
     Assert.AreEqual(expected, actual);
 }
 public void board_should_return_white_when_asked_for_fourth_from_left_second_down_square()
 {
     BoardLocation board = new BoardLocation(3,1);
     BlackWhiteColor expected = BlackWhiteColor.White;
     BlackWhiteColor actual = board.GetSquareColor();
     Assert.AreEqual(expected, actual);
 }
Пример #6
0
    public List<BoardObject> EatPelletsInRadius(BoardLocation pos, int radius )
    {
        List<BoardObject> result = new List<BoardObject>();
        List<BoardObject> inSqare;
        if ( Data.Pellets.TryGetValue( pos.location, out inSqare ) )
        {
            foreach ( BoardObject g in inSqare )
            {
                int distance = BoardLocation.SqrDistance(g.boardLocation, pos );
                if ( distance <= radius * radius )
                {
                    result.Add( g );
                }
            }
        }

        foreach (BoardObject g in result )
        {
            inSqare.Remove( g );
        }

        return result;
    }
Пример #7
0
 /// <summary>
 /// Initialization
 /// </summary>
 public void Start()
 {
     stepsLeft = StepCount;
     attacksLeft = AttackCount;
     boardLocation = gameObject.GetComponent<BoardLocation>();
     walkableTiles = new List<GameObject>();
     attackableTiles = new List<GameObject>();
     currentPath = new List<GameObject>();
 }
Пример #8
0
 /// <summary>
 /// Initialization
 /// </summary>
 public void Start()
 {
     boardLocation = gameObject.GetComponent<BoardLocation>();
     Initialize();
 }
 public BoardSquare()
 {
     InitializeComponent();
     Location = new BoardLocation(Int32.MinValue, Int32.MinValue);
 }
Пример #10
0
    private void createPellet( BoardLocation pos )
    {
        if ( !( GameProperties.isSinglePlayer || Network.isServer ) ) return;

        if ( !Pellets.ContainsKey( pos.location ) )
        {
            Pellets.Add( pos.location, new List<BoardObject>());
        }

        Vector3 renderPos = Accessor.convertToRenderPos( pos );
        Quaternion rot = Quaternion.identity;
        BoardObject g = null;
        if ( GameProperties.isSinglePlayer )
        {
            g = ((GameObject)Instantiate( pelletPrefab, renderPos, rot )).GetComponent<BoardObject>();
        }
        else
        {
            g = ((GameObject)Network.Instantiate( pelletPrefab, renderPos, rot, 0 )).GetComponent<BoardObject>();
        }
        g.boardLocation = pos;
        Pellets[pos.location].Add( g );
    }
Пример #11
0
 public Vector3 convertToRenderPos( BoardLocation b )
 {
     float x = .5f + b.location.x + ((float)b.offset.x) / Constants.BoardCellDiameter;
     float y = .5f + b.location.y + ((float)b.offset.y) / Constants.BoardCellDiameter;
     return new Vector3( x, y, 0 );
 }
Пример #12
0
    public BoardLocation tryMove( BoardLocation pos, IntVector2 vel )
    {
        // the tile coordinates
        int x = pos.location.x;
        int y = pos.location.y;

        // the position within the tile, center is (0,0), +y is up
        int cellPosX = pos.offset.x;
        int cellPosY = pos.offset.y;

        cellPosX += vel.x;
        cellPosY += vel.y;

        // array representing whether there is a path to the right, up, left, and down respectively
        bool[] roads = new bool[4]{ isOpen(x + 1,y),
            isOpen(x, y + 1),
            isOpen(x - 1,y),
            isOpen(x, y - 1)};

        // force position to an axis when there is not a road in the direction the position is off
        if ( cellPosX > 0 && !roads[0] ) cellPosX = 0;
        if ( cellPosX < 0 && !roads[2] ) cellPosX = 0;
        if ( cellPosY > 0 && !roads[1] ) cellPosY = 0;
        if ( cellPosY < 0 && !roads[3] ) cellPosY = 0;

        // force to the closer axis
        if ( Math.Abs( cellPosX ) > Math.Abs( cellPosY ) ) cellPosY = 0;
        else cellPosX = 0;

        // translate back to world coords and return
        return new BoardLocation( new IntVector2( x, y ), new IntVector2( cellPosX, cellPosY ));
    }
Пример #13
0
 /// <summary>
 /// Used for intialization
 /// </summary>
 public void Start()
 {
     originalColor = gameObject.renderer.material.color;
     boardLocation = gameObject.GetComponent<BoardLocation>();
     originalHeight = transform.position.y;
 }
Пример #14
0
 public bool LocationIsOccupiedBy(BoardLocation boardLocation, Player player) => this[boardLocation].Player() == player;
Пример #15
0
 public bool LocationIsEmpty(BoardLocation boardLocation) => this[boardLocation] == ChessPiece.None;
Пример #16
0
        public bool ContainsPawn(BoardLocation boardLocation)
        {
            var piece = this[boardLocation];

            return(piece == ChessPiece.BlackPawn || piece == ChessPiece.WhitePawn);
        }