示例#1
0
        //NOTE: this function pulls the weight of actually destroying blocks for us. It is applied to the OCActions of a character; not to blocks themselves.
        public void DestroyBlock(Vector3i?point)
        {
            if (point.HasValue)
            {
                OCMap map = OCMap.Instance;        //(OCMap)GameObject.FindSceneObjectsOfType(typeof(OCMap)).FirstOrDefault();

                //for updating goal controllers after deletion.
                OCBlock            blockType       = map.GetBlock(point.Value).block;
                OCGoalController[] goalControllers = (OCGoalController[])GameObject.FindObjectsOfType(typeof(OCGoalController));

                //actually sets the block to null and recomputes the chunk.
                Debug.Log(OCLogSymbol.DEBUG + "DeleteSelectedVoxel called from CreateBlockEffect");
                GameManager.world.voxels.DeleteSelectedVoxel(point.Value);

                //re-update goals concerned with this block type
                foreach (OCGoalController goalController in goalControllers)
                {
                    if (goalController.GoalBlockType == blockType)
                    {
                        goalController.FindGoalBlockPositionInChunks(map.GetChunks());
                    }
                }

                blocksDestroyed++;
            }
        }
        //---------------------------------------------------------------------------

        #region Private Member Data

        //---------------------------------------------------------------------------



        //---------------------------------------------------------------------------

        #endregion

        //---------------------------------------------------------------------------

        #region Accessors and Mutators

        //---------------------------------------------------------------------------



        //---------------------------------------------------------------------------

        #endregion

        //---------------------------------------------------------------------------

        #region Public Member Functions

        //---------------------------------------------------------------------------

        public void TransferBlock(Vector3i?origin, Vector3i?destination)
        {
            if (origin.HasValue && destination.HasValue)
            {
                OCMap map = OCMap.Instance;                //(OCMap)GameObject.FindSceneObjectsOfType(typeof(OCMap)).FirstOrDefault();

                OCGoalController[] goalControllers = (OCGoalController[])GameObject.FindObjectsOfType(typeof(OCGoalController));

                foreach (Transform battery in map.BatteriesSceneObject.transform)
                {
                    if (VectorUtil.AreVectorsEqual(battery.position, new Vector3((float)origin.Value.x, (float)origin.Value.y, (float)origin.Value.z)))
                    {
                        battery.position = new Vector3((float)destination.Value.x, (float)destination.Value.y, (float)destination.Value.z);
                    }
                }

                OCBlockData block = map.GetBlock(origin.Value);

                map.SetBlockAndRecompute(block, destination.Value);
                map.SetBlockAndRecompute(OCBlockData.CreateInstance <OCBlockData>().Init(null, origin.Value), origin.Value);

                foreach (OCGoalController goalController in goalControllers)
                {
                    if (goalController.GoalBlockType == block.block)
                    {
                        goalController.FindGoalBlockPositionInChunks(map.GetChunks());
                    }
                }
            }
        }
示例#3
0
        //---------------------------------------------------------------------------

        #endregion

        //---------------------------------------------------------------------------

        #region Public Member Functions

        //---------------------------------------------------------------------------

        public void CreateBlock(Vector3i?point)
        {
            if (point.HasValue)
            {
                OCMap map = OCMap.Instance;        //(OCMap)GameObject.FindSceneObjectsOfType(typeof(OCMap)).FirstOrDefault();

                OCBlock block = map.GetBlockSet().GetBlock(_BlockType);

                OCGoalController[] goalControllers = (OCGoalController[])GameObject.FindObjectsOfType(typeof(OCGoalController));

                foreach (OCGoalController goalController in goalControllers)
                {
                    if (goalController.GoalBlockType == block)
                    {
                        goalController.FindGoalBlockPositionInChunks(map.GetChunks());
                    }
                }

                Debug.Log(OCLogSymbol.DEBUG + "AddSelectedVoxel called from CreateBlockEffect");
                GameManager.world.voxels.AddSelectedVoxel(point.Value, -transform.forward, block);
            }
        }
示例#4
0
        //---------------------------------------------------------------------------

        #endregion

        //---------------------------------------------------------------------------

        #region Public Member Functions

        //---------------------------------------------------------------------------

        public void CreateBlock(Vector3i?point)
        {
            if (point.HasValue)
            {
                OCMap map = OCMap.Instance;                //(OCMap)GameObject.FindSceneObjectsOfType(typeof(OCMap)).FirstOrDefault();

                OCBlock block = map.GetBlockSet().GetBlock(_BlockType);

                OCGoalController[] goalControllers = (OCGoalController[])GameObject.FindObjectsOfType(typeof(OCGoalController));

                foreach (OCGoalController goalController in goalControllers)
                {
                    if (goalController.GoalBlockType == block)
                    {
                        goalController.FindGoalBlockPositionInChunks(map.GetChunks());
                    }
                }

                //block.SetDirection(GetDirection(-gameObject.transform.forward));

                OCBlockData blockData = OCBlockData.CreateInstance <OCBlockData>().Init(block, VectorUtil.Vector3ToVector3i(point.Value));
                map.SetBlockAndRecompute(blockData, point.Value);
            }
        }