示例#1
0
    ////////////////////////////////////////
    // Select differents modes

    private void MoveInput()
    {
        if (Event.current.type == EventType.Layout)
        {
            HandleUtility.AddDefaultControl(0);
        }

        if (_selection.Count != 0)
        {
            //Preview destination
            Vector3    input       = GetGridPositionInput(0.5f, _collide_with_plane);
            Vector3Int destination = _grid.GetIndexByPosition(ref input);
            DebugSelection(destination);

            //Move apply
            if (Event.current.type == EventType.MouseDown && Event.current.button == 0)
            {
                Undo.SetCurrentGroupName("Move selected");
                int group = Undo.GetCurrentGroup();

                FuncEditor.StampCells(_selection, _grid, destination, _overwrite_cells_modif);
                foreach (MapTileGridCreator.Core.Cell c in _selection)
                {
                    Undo.DestroyObjectImmediate(c.gameObject);
                }

                Undo.CollapseUndoOperations(group);
                _mode_select = SelectMode.Default;
                Selection.SetActiveObjectWithContext(_grid.gameObject, null);
            }
            //Reset selection
            else if (Event.current.type == EventType.MouseDown && Event.current.button == 1)
            {
                _mode_select = SelectMode.Default;
            }
        }
    }
示例#2
0
    private void Explode()
    {
        Vector3 position = transform.position;

        Instantiate(explosionPrefab, position, Quaternion.identity);
        Instantiate(firePrefab, position, Quaternion.identity);

        Vector3Int index = grid.GetIndexByPosition(ref position);

        foreach (Vector3Int axis in grid.GetConnexAxes())
        {
            // Skip top and down axes
            if (axis.y != 0)
            {
                continue;
            }

            FireOnAxis(index, axis);
        }

        player.OnBombExploded();
        Destroy(gameObject);
    }
示例#3
0
        /// <summary>
        /// Instantiate a cell with a prefab as model.
        /// </summary>
        /// <param name="prefab">The prefab to instantiate as a cell.</param>
        /// <param name="grid">The grid the cell will belongs.</param>
        /// <param name="position"> The position of the cell.</param>
        /// <returns>The cell component associated to the gameobject.</returns>
        public static Cell InstantiateCell(GameObject prefab, Grid3D grid, Vector3 position)
        {
            Vector3Int index = grid.GetIndexByPosition(ref position);

            return(InstantiateCell(prefab, grid, index));
        }