/// <summary>
 /// Initialize the uiInventory manager.
 /// </summary>
 /// <param name="inventoryName">The inventory name</param>
 /// <param name="dragAreaIndicator"></param>
 /// <param name="dragProcessor"></param>
 /// <param name="canvasDistance">the distance of canvas</param>
 /// <param name="gridSize">the gridSize of inventory</param>
 /// <param name="rows">how many rows in total</param>
 /// <param name="columns">how many columns in total</param>
 /// <param name="x_Mirror">is X axis mirrored</param>
 /// <param name="z_Mirror">is Z axis mirrored</param>
 /// <param name="unlockedPartialGrids">is there any grid locked at the beginning</param>
 /// <param name="unlockedGridCount">how many grids are locked at the beginning</param>
 /// <param name="dragOutDrop">allows item to be dragged and dropped outside inventory</param>
 /// <param name="enableScreenClamp">enable inventory UI panel's screen-clamping</param>
 /// <param name="enableLog">enable inventory log</param>
 /// <param name="toggleUIInventoryKeyDownHandler">This handler should return a signal which toggles the uiInventory(e.g. return Input.GetKeyDown(KeyCode.B);)</param>
 /// <param name="rotateItemKeyDownHandler">This handler should return a signal which rotates the uiInventory item(e.g. return Input.GetKeyDown(KeyCode.R);)</param>
 /// <param name="instantiateUIInventoryGridHandler">This handler should instantiate a prefab with UIInventoryGrid component.</param>
 /// <param name="instantiateUIInventoryItemHandler">This handler should instantiate a prefab with UIInventoryItem component.</param>
 /// <param name="instantiateUIInventoryItemGridHandler">This handler should instantiate a prefab with UIInventoryItemGrid component.</param>
 /// <param name="instantiateUIInventoryItemVirtualOccupationQuadHandler">This handler should instantiate a image for indicating the occupation.</param>
 public UIInventory(
     string inventoryName,
     DragAreaIndicator dragAreaIndicator,
     DragProcessor dragProcessor,
     float canvasDistance,
     int gridSize, int rows, int columns, bool x_Mirror, bool z_Mirror,
     bool unlockedPartialGrids, int unlockedGridCount, bool dragOutDrop, bool enableScreenClamp, bool enableLog,
     KeyDownDelegate toggleUIInventoryKeyDownHandler,
     KeyDownDelegate rotateItemKeyDownHandler,
     InstantiatePrefabDelegate instantiateUIInventoryGridHandler,
     InstantiatePrefabDelegate instantiateUIInventoryItemHandler,
     InstantiatePrefabDelegate instantiateUIInventoryItemGridHandler,
     InstantiatePrefabDelegate instantiateUIInventoryItemVirtualOccupationQuadHandler
     ) : base(inventoryName, dragAreaIndicator, gridSize, rows, columns, x_Mirror, z_Mirror, unlockedPartialGrids, unlockedGridCount, dragOutDrop, enableLog, rotateItemKeyDownHandler,
              (gridPos) => new GridPosR(gridPos.x, -gridPos.z),
              (gridPos_matrix) => new GridPosR(gridPos_matrix.x, -gridPos_matrix.z),
              (gridPos) => new GridPosR(gridPos.x, -gridPos.z),
              (gridPos_matrix) => new GridPosR(gridPos_matrix.x, -gridPos_matrix.z))
 {
     DragProcessor  = dragProcessor;
     CanvasDistance = canvasDistance;
     ToggleUIInventoryKeyDownHandler       = toggleUIInventoryKeyDownHandler;
     InstantiateUIInventoryGridHandler     = instantiateUIInventoryGridHandler;
     InstantiateUIInventoryItemHandler     = instantiateUIInventoryItemHandler;
     InstantiateUIInventoryItemGridHandler = instantiateUIInventoryItemGridHandler;
     InstantiateUIInventoryItemVirtualOccupationQuadHandler = instantiateUIInventoryItemVirtualOccupationQuadHandler;
     EnableScreenClamp = enableScreenClamp;
 }
Exemple #2
0
    public BuildingCoverMaskGroup[,] BuildingCoverMaskMatrix_IncludingPreview; // column, row

    public CityInventory(
        string inventoryName,
        DragAreaIndicator dragAreaIndicator,
        DragProcessor dragProcessor,
        int gridSize,
        int rows,
        int columns,
        bool x_Mirror,
        bool z_Mirror,
        bool unlockedPartialGrids,
        int unlockedGridCount,
        bool dragOutDrop,
        KeyDownDelegate rotateItemKeyDownHandler,
        InstantiatePrefabDelegate instantiateCityInventoryGridHandler,
        InstantiatePrefabDelegate instantiateCityInventoryVirtualOccupationQuadHandler
        ) : base(inventoryName, dragAreaIndicator, gridSize, rows, columns, x_Mirror, z_Mirror, unlockedPartialGrids, unlockedGridCount, dragOutDrop,
                 rotateItemKeyDownHandler,
                 (gridPos) => new GridPosR(gridPos.x + columns / 2, gridPos.z + rows / 2, gridPos.orientation),
                 (gp_matrix) => new GridPosR(gp_matrix.x - columns / 2, gp_matrix.z - rows / 2, gp_matrix.orientation),
                 (gridPos) => new GridPos(gridPos.x, gridPos.z),
                 (gp_matrix) => new GridPos(gp_matrix.x, gp_matrix.z)
                 )
    {
        DragProcessor = dragProcessor;
        InstantiateCityInventoryGridHandler = instantiateCityInventoryGridHandler;
        InstantiateCityInventoryVirtualOccupationQuadHandler = instantiateCityInventoryVirtualOccupationQuadHandler;
        InventoryValidMatrix    = new bool[columns, rows];
        BuildingCoverMaskMatrix = new BuildingCoverMaskGroup[columns, rows];
        BuildingCoverMaskMatrix_IncludingPreview = new BuildingCoverMaskGroup[columns, rows];
    }
 public Column(DataGridPCtrls dataGridPCtrls, KeyDownDelegate keydowndel, ColumnType ct = ColumnType.TextBox, double width = 145.0)
 {
     InitializeComponent();
     this.keydowndel     = keydowndel;
     this.dataGridPCtrls = dataGridPCtrls;
     ColType             = ct;
     Width = width;
 }
Exemple #4
0
        /// <summary>
        /// Create a new inventory
        /// </summary>
        /// <param name="inventoryName">The inventory name</param>
        /// <param name="dragAreaIndicator"></param>
        /// <param name="gridSize">the gridSize of inventory</param>
        /// <param name="rows">how many rows in total</param>
        /// <param name="columns">how many columns in total</param>
        /// <param name="x_Mirror">is X axis mirrored</param>
        /// <param name="z_Mirror">is Z axis mirrored</param>
        /// <param name="unlockedPartialGrids">is there any grid locked at the beginning</param>
        /// <param name="unlockedGridCount">how many grids are locked at the beginning</param>
        /// <param name="dragOutDrop">allows item to be dragged and dropped outside inventory</param>
        /// <param name="enableLog">enable inventory log</param>
        /// <param name="rotateItemKeyDownHandler">this delegate should return a bool whether the rotate item key is pressed down</param>
        /// <param name="coordinateTransformationHandler_FromPosToMatrixIndex"></param>
        /// <param name="coordinateTransformationHandler_FromMatrixIndexToPos"></param>
        /// <param name="coordinateTransformationHandler_FromPosToMatrixIndex_Diff"></param>
        /// <param name="coordinateTransformationHandler_FromMatrixIndexToPos_Diff"></param>
        protected Inventory(
            string inventoryName,
            DragAreaIndicator dragAreaIndicator,
            int gridSize,
            int rows,
            int columns,
            bool x_Mirror,
            bool z_Mirror,
            bool unlockedPartialGrids,
            int unlockedGridCount,
            bool dragOutDrop,
            bool enableLog,
            KeyDownDelegate rotateItemKeyDownHandler,
            CoordinateTransformationDelegate coordinateTransformationHandler_FromPosToMatrixIndex,
            CoordinateTransformationDelegate coordinateTransformationHandler_FromMatrixIndexToPos,
            CoordinateTransformationDelegate coordinateTransformationHandler_FromPosToMatrixIndex_Diff,
            CoordinateTransformationDelegate coordinateTransformationHandler_FromMatrixIndexToPos_Diff
            )
        {
            InventoryName     = inventoryName;
            DragAreaIndicator = dragAreaIndicator;
            GridSize          = gridSize;
            Rows                   = rows;
            Columns                = columns;
            X_Mirror               = x_Mirror;
            Z_Mirror               = z_Mirror;
            UnlockedPartialGrids   = unlockedPartialGrids;
            this.unlockedGridCount = unlockedGridCount;
            DragOutDrop            = dragOutDrop;
            EnableLog              = enableLog;

            RotateItemKeyDownHandler = rotateItemKeyDownHandler;
            CoordinateTransformationHandler_FromPosToMatrixIndex      = coordinateTransformationHandler_FromPosToMatrixIndex;
            CoordinateTransformationHandler_FromMatrixIndexToPos      = coordinateTransformationHandler_FromMatrixIndexToPos;
            CoordinateTransformationHandler_FromPosToMatrixIndex_Diff = coordinateTransformationHandler_FromPosToMatrixIndex_Diff;
            CoordinateTransformationHandler_FromMatrixIndexToPos_Diff = coordinateTransformationHandler_FromMatrixIndexToPos_Diff;

            InventoryGridMatrix = new InventoryGrid[Columns, Rows];
            for (int row = 0; row < Rows; row++)
            {
                for (int col = 0; col < Columns; col++)
                {
                    InventoryGrid ig = new InventoryGrid();
                    ig.State = InventoryGrid.States.Unavailable;
                    InventoryGridMatrix[col, row] = ig;
                }
            }

            InventoryItemMatrix = new InventoryItem[Columns, Rows];
        }
Exemple #5
0
        /// <summary>
        /// Fires <paramref name="keyDownEvent"/> when <paramref name="keyCode"/> is down.
        /// </summary>
        /// <param name="keyCode">The key.</param>
        /// <param name="keyDownEvent">The method to execute.</param>
        /// <param name="repeat">If true, the key event will be continuously while the key is down.</param>
        /// <param name="repeatInterval">The interval between key presses if <paramref name="repeat"/> is true.</param>
        public void SubscribeToKey(KeyCode keyCode, KeyDownDelegate keyDownEvent, bool repeat = false,
                                   float repeatInterval = 0.1f)
        {
            InputPatch.KeyDown += o =>
            {
                if (o == keyCode)
                {
                    keyDownEvent(keyCode);
                }
            };

            var key = new InputPatch.KeyStruct(keyCode, repeat, repeatInterval);

            if (!InputPatch.KeyCodesToListenTo.Contains(key))
            {
                InputPatch.KeyCodesToListenTo.Add(key);
            }
        }
 public MechaEditorInventory(
     string inventoryName,
     DragArea dragArea,
     int gridSize,
     int rows,
     int columns,
     bool x_Mirror,
     bool z_Mirror,
     bool unlockedPartialGrids,
     int unlockedGridCount,
     KeyDownDelegate rotateItemKeyDownHandler
     ) : base(inventoryName, dragArea, gridSize, rows, columns, x_Mirror, z_Mirror, unlockedPartialGrids, unlockedGridCount, rotateItemKeyDownHandler,
              (gridPos) => new GridPosR(gridPos.x + ConfigManager.EDIT_AREA_HALF_SIZE, gridPos.z + ConfigManager.EDIT_AREA_HALF_SIZE, gridPos.orientation),
              (gp_matrix) => new GridPosR(gp_matrix.x - ConfigManager.EDIT_AREA_HALF_SIZE, gp_matrix.z - ConfigManager.EDIT_AREA_HALF_SIZE, gp_matrix.orientation),
              (gridPos) => new GridPos(gridPos.x, gridPos.z),
              (gp_matrix) => new GridPos(gp_matrix.x, gp_matrix.z)
              )
 {
 }
Exemple #7
0
 /// <summary>
 /// Initialize the backpack manager.
 /// </summary>
 /// <param name="inventoryName">the name of the backpack</param>
 /// <param name="gridSize">the size (in pixel) of each grid of backpack items in UI panels.</param>
 /// <param name="toggleBackpackKeyDownHandler">This handler should return a signal which toggles the backpack(e.g. return Input.GetKeyDown(KeyCode.B);)</param>
 /// <param name="rotateItemKeyDownHandler">This handler should return a signal which rotates the backpack item(e.g. return Input.GetKeyDown(KeyCode.R);)</param>
 /// <param name="instantiateBackpackGridHandler">This handler should instantiate a prefab with BackpackGrid component.</param>
 /// <param name="instantiateBackpackItemHandler">This handler should instantiate a prefab with BackpackItem component.</param>
 /// <param name="instantiateBackpackItemGridHandler">This handler should instantiate a prefab with BackpackItemGrid component.</param>
 /// <param name="instantiateBackpackItemVirtualOccupationQuadHandler">This handler should instantiate a image for indicating the occupation.</param>
 public Backpack(
     string inventoryName, DragArea dragArea, int gridSize, int rows, int columns, bool x_Mirror, bool z_Mirror, bool unlockPartialGrids, int unlockedGridCount,
     KeyDownDelegate toggleBackpackKeyDownHandler,
     KeyDownDelegate rotateItemKeyDownHandler,
     InstantiatePrefabDelegate instantiateBackpackGridHandler,
     InstantiatePrefabDelegate instantiateBackpackItemHandler,
     InstantiatePrefabDelegate instantiateBackpackItemGridHandler,
     InstantiatePrefabDelegate instantiateBackpackItemVirtualOccupationQuadHandler
     ) : base(inventoryName, dragArea, gridSize, rows, columns, x_Mirror, z_Mirror, unlockPartialGrids, unlockedGridCount, rotateItemKeyDownHandler,
              (gridPos) => new GridPosR(gridPos.x, -gridPos.z),
              (gridPos_matrix) => new GridPosR(gridPos_matrix.x, -gridPos_matrix.z),
              (gridPos) => new GridPosR(gridPos.x, -gridPos.z),
              (gridPos_matrix) => new GridPosR(gridPos_matrix.x, -gridPos_matrix.z))
 {
     ToggleBackpackKeyDownHandler       = toggleBackpackKeyDownHandler;
     InstantiateBackpackGridHandler     = instantiateBackpackGridHandler;
     InstantiateBackpackItemHandler     = instantiateBackpackItemHandler;
     InstantiateBackpackItemGridHandler = instantiateBackpackItemGridHandler;
     InstantiateBackpackItemVirtualOccupationQuadHandler = instantiateBackpackItemVirtualOccupationQuadHandler;
 }
 static CallbackHandler()
 {
     keyDownCB = new KeyDownDelegate(fireKeyPressed);
     keyUpCB   = new KeyUpDelegate(fireKeyReleased);
 }
        private static extern IntPtr NativeKeyboard_new(IntPtr osWindow, KeyDownDelegate keyDownCB, KeyUpDelegate keyUpCB
#if FULL_AOT_COMPILE
                                                        , IntPtr instanceHandle
#endif
                                                        );