コード例 #1
0
        // ---------------------------------------------------------------------------------------------
        // EXPERIMENTAL
        // ---------------------------------------------------------------------------------------------
        protected void setRailgunAim()
        {
            _trfmAimTool.forward = _hit.normal;

            _v3AimPos = _levelEditor.curVoxelsLevelChunk.getHitChunkPos(_hit) * VoxelUtils.CHUNK_SIZE;

            Globals.RailgunShape shape = _levelEditor.curVoxelsLevelChunk.aRailgunShapes [MainMenu.Instance.iSelectedRailgunMaterialIndex];

            _xAimScale = shape.width * VoxelUtils.CHUNK_SIZE;
            _yAimScale = shape.height * VoxelUtils.CHUNK_SIZE;
            _zAimScale = shape.depth * VoxelUtils.CHUNK_SIZE;

            if (_hit.normal.x != 0.0f)
            {
                _v3AimPos.y += (_yAimScale * 0.5f);

                if (_hit.normal.x > 0)
                {
                    _v3AimPos.z += (_xAimScale * 0.5f);
                    _v3AimPos.x += (VoxelUtils.CHUNK_SIZE - (_zAimScale * 0.5f));
                }
                else
                {
                    _v3AimPos.z -= ((_xAimScale * 0.5f) - VoxelUtils.CHUNK_SIZE);
                    _v3AimPos.x += (_zAimScale * 0.5f);
                }
            }
            else if (_hit.normal.y != 0.0f)
            {
                _v3AimPos.x += ((_xAimScale * 0.5f));
                _v3AimPos.z += ((_yAimScale * 0.5f));                // - VoxelUtils.CHUNK_SIZE);

                if (_hit.normal.y > 0)
                {
                    _v3AimPos.y += (VoxelUtils.CHUNK_SIZE - (_zAimScale * 0.5f));
                }
                else
                {
                    _v3AimPos.y += (_zAimScale * 0.5f);
                }
            }
            else if (_hit.normal.z != 0.0f)
            {
                _v3AimPos.y += (_yAimScale * 0.5f);

                if (_hit.normal.z > 0)
                {
                    _v3AimPos.x -= ((_xAimScale * 0.5f) - VoxelUtils.CHUNK_SIZE);
                    _v3AimPos.z += (VoxelUtils.CHUNK_SIZE - (_zAimScale * 0.5f));
                }
                else
                {
                    _v3AimPos.x += (_xAimScale * 0.5f);
                    _v3AimPos.z += (_zAimScale * 0.5f);
                }
            }

            _trfmAimTool.position = _v3AimPos;
        }
コード例 #2
0
 //
 public override void activate()
 {
     Globals.RailgunShape shape = LevelEditor.Instance.curVoxelsLevelChunk.aRailgunShapes[_iSelectedRailgunShape];
     _v3AimSize.x = shape.width;
     _v3AimSize.y = shape.height;
     _v3AimSize.z = shape.depth;
     MainMenu.Instance.resetDigSettings(_v3AimSize);
     _levelEditor.updateDigSettings(_v3AimSize);
 }
コード例 #3
0
        // ---------------------------------------------------------------------------------------------
        // Init shit
        // ---------------------------------------------------------------------------------------------
        public void init(GameObject goParent, bool isExperimental = false)
        {
            _trfmVoxelChunkContainer = goParent.transform;

            _chunkPos = _trfmVoxelChunkContainer.position;

            _trfmVoxels      = _trfmVoxelChunkContainer.Find("voxelsContainer");
            _trfmProps       = _trfmVoxelChunkContainer.Find("propsContainer");
            _trfmPlaceholder = _trfmVoxelChunkContainer.Find("placeholderContainer");

            _aVoxelChunks     = new List <VoxelUtils.VoxelChunk> ();
            _aVoxelChunksUndo = new List <VoxelUtils.VoxelChunk> ();

            _worldProps = new Dictionary <GameObject, worldProp> ();


            // Experimental

            _isExperimentalChunk = isExperimental;
            _levelMap            = LevelMap.Instance;

            _aRailgunShapes = new List <Globals.RailgunShape> ();

            int multiply = (int)(0.5f / VoxelUtils.CHUNK_SIZE);

            //
            // cross
            //
            Globals.RailgunShape shape = new Globals.RailgunShape(4 * multiply, 4 * multiply, 8 * multiply, new List <Vector3>(), new List <Vector3>());
            shape.pos.Add(new Vector3(0, 1, 0) * multiply);
            shape.size.Add(new Vector3(1, 2, 8) * multiply);
            shape.pos.Add(new Vector3(0.5f, 0.5f, 0) * multiply);
            shape.size.Add(new Vector3(1, 3, 8) * multiply);
            shape.pos.Add(new Vector3(1, 0, 0) * multiply);
            shape.size.Add(new Vector3(2, 4, 8) * multiply);
            shape.pos.Add(new Vector3(2.5f, 0.5f, 0) * multiply);
            shape.size.Add(new Vector3(1, 3, 8) * multiply);
            shape.pos.Add(new Vector3(3, 1, 0) * multiply);
            shape.size.Add(new Vector3(1, 2, 8) * multiply);

            _aRailgunShapes.Add(shape);

            //
            // steps
            //
            shape = new Globals.RailgunShape(4 * multiply, 4 * multiply, 4 * multiply, new List <Vector3>(), new List <Vector3>());
            shape.pos.Add(new Vector3(0, 0, 0) * multiply);
            shape.size.Add(new Vector3(4, 4, 1) * multiply);
            shape.pos.Add(new Vector3(0, 1, 1) * multiply);
            shape.size.Add(new Vector3(4, 3, 1) * multiply);
            shape.pos.Add(new Vector3(0, 2, 2) * multiply);
            shape.size.Add(new Vector3(4, 2, 1) * multiply);
            shape.pos.Add(new Vector3(0, 3, 3) * multiply);
            shape.size.Add(new Vector3(4, 1, 1) * multiply);

            _aRailgunShapes.Add(shape);

            //
            // corner right
            //
            shape = new Globals.RailgunShape(6 * multiply, 4 * multiply, 6 * multiply, new List <Vector3>(), new List <Vector3>());
            shape.pos.Add(new Vector3(0, 0, 0) * multiply);
            shape.size.Add(new Vector3(3, 4, 6) * multiply);
            shape.pos.Add(new Vector3(0, 0, 3) * multiply);
            shape.size.Add(new Vector3(6, 4, 3) * multiply);

            _aRailgunShapes.Add(shape);

            //
            // corner left
            //
            shape = new Globals.RailgunShape(6 * multiply, 4 * multiply, 6 * multiply, new List <Vector3>(), new List <Vector3>());
            shape.pos.Add(new Vector3(3, 0, 0) * multiply);
            shape.size.Add(new Vector3(3, 4, 6) * multiply);
            shape.pos.Add(new Vector3(0, 0, 3) * multiply);
            shape.size.Add(new Vector3(6, 4, 3) * multiply);

            _aRailgunShapes.Add(shape);

            // Experimental


            newLevel();
        }
コード例 #4
0
        // ---------------------------------------------------------------------------------------------
        public void railgunDig(RaycastHit hit)
        {
            LevelEditor.Instance.resetUndoActions();
            saveCurrentVoxelChunks();
            MainMenu.Instance.setUndoButton(true);

            _lastChunkPos = getHitChunkPos(hit);

            Globals.RailgunShape shape = _aRailgunShapes [MainMenu.Instance.iSelectedRailgunMaterialIndex];

            int     i, len = shape.pos.Count;
            Vector3 pos, size;

            if (hit.normal.x != 0)
            {
                if (hit.normal.x < 0)
                {
                    //Debug.Log ("right");
                    for (i = 0; i < len; ++i)
                    {
                        pos  = new Vector3(_lastChunkPos.x + shape.pos [i].z, _lastChunkPos.y + shape.pos [i].y, _lastChunkPos.z - (shape.size [i].x - 1) - shape.pos [i].x);
                        size = new Vector3(shape.size [i].z, shape.size [i].y, shape.size [i].x);
                        subtractChunk(pos, size, false);
                    }
                }
                else
                {
                    //Debug.Log ("left");
                    for (i = 0; i < len; ++i)
                    {
                        pos  = new Vector3(_lastChunkPos.x - (shape.size [i].z - 1) - shape.pos [i].z, _lastChunkPos.y + shape.pos [i].y, _lastChunkPos.z + shape.pos [i].x);
                        size = new Vector3(shape.size [i].z, shape.size [i].y, shape.size [i].x);
                        subtractChunk(pos, size, false);
                    }
                }
            }
            else if (hit.normal.y != 0)
            {
                if (hit.normal.y < 0)
                {
                    //Debug.Log ("ceiling");
                    for (i = 0; i < len; ++i)
                    {
                        pos  = new Vector3(_lastChunkPos.x + shape.pos [i].x, _lastChunkPos.y + shape.pos [i].z, _lastChunkPos.z + shape.pos [i].y);
                        size = new Vector3(shape.size [i].x, shape.size [i].z, shape.size [i].y);
                        subtractChunk(pos, size, false);
                    }
                }
                else
                {
                    //Debug.Log ("floor");
                    for (i = 0; i < len; ++i)
                    {
                        pos  = new Vector3(_lastChunkPos.x + shape.pos [i].x, _lastChunkPos.y - (shape.size [i].z - 1) - shape.pos [i].z, _lastChunkPos.z + shape.pos [i].y);
                        size = new Vector3(shape.size [i].x, shape.size [i].z, shape.size [i].y);
                        subtractChunk(pos, size, false);
                    }
                }
            }
            else if (hit.normal.z != 0)
            {
                // this is the default direction - everything going +
                if (hit.normal.z < 0)
                {
                    //Debug.Log ("front");
                    for (i = 0; i < len; ++i)
                    {
                        pos  = new Vector3(_lastChunkPos.x + shape.pos [i].x, _lastChunkPos.y + shape.pos [i].y, _lastChunkPos.z + shape.pos [i].z);
                        size = shape.size [i];
                        subtractChunk(pos, size, false);
                    }
                }
                else
                {
                    //Debug.Log ("back");
                    for (i = 0; i < len; ++i)
                    {
                        pos  = new Vector3(_lastChunkPos.x - (shape.size [i].x - 1) - shape.pos [i].x, _lastChunkPos.y + shape.pos [i].y, _lastChunkPos.z - (shape.size [i].z - 1) - shape.pos [i].z);
                        size = shape.size [i];
                        subtractChunk(pos, size, false);
                    }
                }
            }
        }