예제 #1
0
    private void SwitchEditMode()
    {
        switch (_mode_edit)
        {
        case EditMode.Select:
            SelectEdit();
            break;

        case EditMode.Paint:
            PaintEdit();
            break;

        case EditMode.Procedural:
            if (_debug_start_modifiers)
            {
                int i = 0;
                foreach (Modifier m in _map_gen.m_ModifiersList)
                {
                    if (m != null && !m.Pass)
                    {
                        Vector3 posTrans = _grid.GetPositionCell(m.StartIndex);
                        DebugCellAtPosition(posTrans, DebugsColor.start_modifier, 1.1f);
                        posTrans.y += _grid.SizeCell;
                        Handles.Label(posTrans, "Start modifier " + i);
                    }
                    i++;
                }
            }
            break;
        }
    }
예제 #2
0
        /// <summary>
        /// Gizmo for debuging a cell.
        /// </summary>
        /// <param name="index">The index of the cell.</param>
        /// <param name="grid">The grid it belongs</param>
        /// <param name="color">Color of the gizmo.</param>
        /// <param name="offsetSize"> The scale amount add to the grid size cell.</param>
        public static void DebugCell(Vector3Int index, Grid3D grid, Color color, float offsetSize = 0.01f)
        {
            if (grid == null)
            {
                return;
            }
            Gizmos.color = color;
            TypeGrid3D typegrid = grid.GetTypeGrid();

            switch (typegrid)
            {
            case TypeGrid3D.Cube:
            {
                Gizmos.DrawWireCube(grid.GetPositionCell(index), Vector3.one * (grid.SizeCell + offsetSize));
            }
            break;

            case TypeGrid3D.Hexagonal:
            {
                Gizmos.DrawMesh(ProceduralMesh.GetHexagonMesh(), grid.GetPositionCell(index), Quaternion.identity, Vector3.one * (grid.SizeCell + offsetSize));
            }
            break;

            default:
                throw new ArgumentException("No type implemented " + typegrid.ToString() + " inherit Grid3D");
            }
        }
예제 #3
0
    private void Start()
    {
        _rb = GetComponent <Rigidbody>();
        Vector3 dest = _grid.GetPositionCell(_index_grid);

        _rb.MovePosition(dest);
        _is_moving = false;
    }
예제 #4
0
    private void FireOnAxis(Vector3Int index, Vector3Int axis)
    {
        for (int i = 1; i <= radius; i++)
        {
            Vector3Int newIndex = index + axis * i;
            Cell       cell     = grid.TryGetCellByIndex(ref newIndex);
            Vector3    position = grid.GetPositionCell(newIndex);
            position.y -= grid.SizeCell / 2;

            if (cell != null)
            {
                if (cell.TryGetComponent(out Destroyable destroyable) && destroyable.Hit())
                {
                    Destroy(cell.gameObject);
                    Instantiate(explosionPrefab, position, Quaternion.identity);
                    Instantiate(firePrefab, position, Quaternion.identity);
                }

                return;
            }

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