public static Request GenerateRepeatCellRequest(GRange range, GCell cell)
 {
     return(new Request()
     {
         RepeatCell = new RepeatCellRequest()
         {
             Cell = cell.GetCellData(),
             Fields = cell.GetFields(),
             Range = range.GetGridRange()
         }
     });
 }
Ejemplo n.º 2
0
    [Server] public bool SetPlayerToPosition(GameObject playerO, int x, int y)
    {
        if (!CheckPosition(x, y))
        {
            return(false);
        }

        DC_Player player = playerO.GetComponent <DC_Player>();

        if (player.gameGridX > 0)
        {
            int oldPos = GetPosInt(player.gameGridX, player.gameGridY);

            // var oldCell = cells[oldPos];
            var oldCell = gridCells[oldPos];

            oldCell.player = null;

            // cells[oldPos] = oldCell;
            // cells.Dirty(oldPos);

            gridCells[oldPos] = oldCell;

            RpcSetCell(oldPos, oldCell);
        }

        player.gameGridX = x;
        player.gameGridY = y;

        int newPos = GetPosInt(x, y);

        // GCell cell = cells[newPos];
        GCell cell = gridCells[newPos];

        cell.player = playerO;

        // cells[newPos] = cell;
        // cells.Dirty(newPos);

        gridCells[newPos] = cell;

        player.RpcUpdatePosition(cell.cellPos);
        RpcSetCell(newPos, cell);

        return(true);
    }
Ejemplo n.º 3
0
    [Server] public void UpdateCellPositions()
    {
        for (int i = 0; i < gridCells.Length; i++)
        {
            GCell cell    = gridCells[i];
            GCell newCell = cell;

            float halfGrid = (gridCellSize / 2f);

            float x = ((cell.x) * gridCellSize) - halfGrid;
            float y = ((cell.y) * gridCellSize) - halfGrid;

            float offset = (gridCellSize * 3f) / 2f;

            newCell.cellPos = new Vector3(y - offset, 0f, -(x - offset));

            gridCells[i] = newCell;

            // cells[i] = newCell;
            // cells.Dirty(i);
        }
    }
Ejemplo n.º 4
0
 [ClientRpc] public void RpcSetCell(int index, GCell cell)
 {
     gridCells[index]  = cell;
     gridSelectorDirty = true;
 }