コード例 #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++;
            }
        }
コード例 #2
0
        //---------------------------------------------------------------------------

        #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
        public void UpdateGoal()
        {
            List3D <OCChunk> chunks = _map.GetChunks();

            FindGoalBlockPositionInChunks(chunks);

            Vector3 sourcePos   = gameObject.transform.position;
            Vector3 distanceVec = ((Vector3)GoalBlockPos) - sourcePos;

            float integrityChange = _goalNameToChangeRatePerSecond["Integrity"] / (distanceVec.magnitude * _distanceAttenuation);

            integrityChange = integrityChange / 10;

            UnityEngine.GameObject[] agiArray = UnityEngine.GameObject.FindGameObjectsWithTag("OCAGI");

            if (integrityChange > 0.04)
            {
                for (int iAGI = 0; iAGI < agiArray.Length; iAGI++)
                {
                    UnityEngine.GameObject agiObject = agiArray[iAGI];

                    OpenCog.Embodiment.OCPhysiologicalModel agiPhysModel = agiObject.GetComponent <OpenCog.Embodiment.OCPhysiologicalModel>();

                    OpenCog.Embodiment.OCPhysiologicalEffect nearHomeEffect = new OpenCog.Embodiment.OCPhysiologicalEffect(OpenCog.Embodiment.OCPhysiologicalEffect.CostLevel.NONE);

                    nearHomeEffect.FitnessChange = integrityChange;

                    //UnityEngine.Debug.Log ("Increasing Integrity by '" + integrityChange.ToString() + "'");

                    agiPhysModel.ProcessPhysiologicalEffect(nearHomeEffect);
                }
            }
        }
コード例 #4
0
        //---------------------------------------------------------------------------

        #endregion

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

        #region Public Member Functions

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

        public IEnumerator Start()
        {
            _map = OCMap.Instance;    //(OCMap)GameObject.FindObjectOfType (typeof(OCMap));

            _goalBlockType = _map.GetBlockSet().GetBlock(_blockType);

            List3D <OCChunk> chunks = _map.GetChunks();

            // Since this is probably bogging down the gameplay, switch it to block creation only.
            FindGoalBlockPositionInChunks(chunks);

            while (Application.isPlaying)
            {
                yield return(new WaitForSeconds(1.0f));

                UpdateGoal();
            }
//		yield return 0;
        }
コード例 #5
0
        //---------------------------------------------------------------------------

        #region Private Member Data

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



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

        #endregion

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

        #region Accessors and Mutators

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



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

        #endregion

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

        #region Public Member Functions

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

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

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

                OCBlock blockType = map.GetBlock(point.Value).block;

                map.SetBlockAndRecompute(OCBlockData.CreateInstance <OCBlockData>().Init(null, point.Value), point.Value);

                foreach (OCGoalController goalController in goalControllers)
                {
                    if (goalController.GoalBlockType == blockType)
                    {
                        goalController.FindGoalBlockPositionInChunks(map.GetChunks());
                    }
                }
            }
        }
コード例 #6
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);
            }
        }
コード例 #7
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);
            }
        }
コード例 #8
0
	//---------------------------------------------------------------------------

	#endregion

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

	#region Public Member Functions

	//---------------------------------------------------------------------------
		
	public IEnumerator Start()
	{
		_map = OCMap.Instance;//(OCMap)GameObject.FindObjectOfType (typeof(OCMap));
			
		_goalBlockType = 	_map.GetBlockSet().GetBlock(_blockType);
				
		List3D<OCChunk> chunks = _map.GetChunks ();
			
		// Since this is probably bogging down the gameplay, switch it to block creation only.
		FindGoalBlockPositionInChunks(chunks);
			
		while (Application.isPlaying) 
		{
			yield return new WaitForSeconds (1.0f);
			UpdateGoal();
		}
//		yield return 0;
	}