public void UpdateAllNodes(object Data)
        {
            lock (GridNodes)
            {
                if (Terrain != null)
                {
                    Vector3 TerrainPosition = Terrain.transform.position;
                    Vector3 TerrainSize     = Terrain.terrainData.size;

                    var ArrayData = Data as object[];
                    ForEach((int NodeIndex, GridNode Node) =>
                    {
                        Node.UpdateNode(Terrain, TerrainPosition, TerrainSize, NodeSize, ObstaclePadding, MaxSlope, CastExtends, TerrainLayer, ObstacleLayer, (GameObject FoundObject) =>
                        {
                            IDynamicObstacle Dynamic = FoundObject.GetComponent <IDynamicObstacle>(); // check if there is a dynamic obstacle
                            if (Dynamic != null)
                            {
                                return(!Dynamic.IsObstacle);
                            } // check if object is dynamic
                            return(false);
                        });
                    });
                }
                else
                {
                    UnityEngine.Debug.LogError("There is no terrain assigned to this grid!");
                }
            }
        }
        private void Awake()
        {
            _obstacle = this.GetComponent <DynamicObstacle>();

            var b = this.GetComponent <Renderer>().bounds;

            //move distance is a bit too long if the door is axis aligned, but it'll do for this example
            _slider = new Slider((b.max - b.min).magnitude, this.speedInSeconds);
        }
示例#3
0
//
//	/// <summary>
//	/// Open this door
//	/// </summary>
//	public void Open(AISpawnerElevator spawner = null){
//		StopAllCoroutines ();
//		StartCoroutine (MathHelper.IELerpLocalPositionOverTime (this.transform, _closedPos, _openPos, 1f));
//		Invoke ("updateDynamicObstacle", 1f);
//		//To be deleted
////		if (spawner != null) {
//////			spawner.SetState (AISpawner.State.OPEN);
//////			spawner.DoNext ();
////			StartCoroutine(spawner.IEDoNextDelayed(spawner, AISpawnerElevator.State.OPEN, 1f));
////		}
//	}
//
//	/// <summary>
//	/// Close this door
//	/// </summary>
//	public void Close(AISpawnerElevator spawner = null){
//		StopAllCoroutines ();
//		StartCoroutine (MathHelper.IELerpLocalPositionOverTime (this.transform, _openPos, _closedPos, 1f));
//		Invoke ("updateDynamicObstacle", 1f);
//		//To be deleted
////		if (spawner != null) {
//////			spawner.SetState (AISpawner.State.CLOSED);
////			//			spawner.DoNext ();
////			StartCoroutine(spawner.IEDoNextDelayed(spawner, AISpawnerElevator.State.CLOSED, 1f));
////		}
//	}

    /// <summary>
    /// Update dynamic obstacle, if this object has one as a component
    /// </summary>
    void updateDynamicObstacle()
    {
        IDynamicObstacle dynamicObstacle = GetComponent <DynamicObstacle> ();

        if (dynamicObstacle != null)
        {
            dynamicObstacle.ActivateUpdates(null, false);
//			print ("Updated");
        }
    }
示例#4
0
文件: Cell.cs 项目: rmcmrz/unity-rl
        internal bool RemoveDynamicObstacle(IDynamicObstacle dynamicObstacle)
        {
            if (_dynamicObstacles != null)
            {
                if (_dynamicObstacles.Remove(dynamicObstacle))
                {
                    return(UpdateExclusionMask());
                }
            }

            return(false);
        }
示例#5
0
文件: Cell.cs 项目: rmcmrz/unity-rl
        internal bool AddDynamicObstacle(IDynamicObstacle dynamicObstacle)
        {
            if (_permanentlyBlocked)
            {
                return(false);
            }

            if (_dynamicObstacles == null)
            {
                _dynamicObstacles = new List <IDynamicObstacle>(2);
            }

            if (_dynamicObstacles.AddUnique(dynamicObstacle))
            {
                return(UpdateExclusionMask());
            }

            return(false);
        }
示例#6
0
        private void Awake()
        {
            if (this.door == null)
            {
                Debug.LogWarning("You must assign a door to the slider.");
                this.enabled = false;
                return;
            }

            _obstacle = this.door.GetComponent <DynamicObstacle>();

            if (_obstacle == null)
            {
                //Of course you could opt to simply add it to the door if missing instead if failing.
                Debug.LogWarning("You must assign a DynamicObstacle component to the door.");
                this.enabled = false;
                return;
            }

            var b = this.door.GetComponent <Renderer>().bounds;

            //move distance is a bit too long if the door is axis aligned, but it'll do for this example
            _slider = new Slider((b.max - b.min).magnitude, this.speedInSeconds);
        }
示例#7
0
文件: Cell.cs 项目: forwolk/UnityApex
        internal bool RemoveDynamicObstacle(IDynamicObstacle dynamicObstacle)
        {
            if (!_permanentlyBlocked && _dynamicObstacles != null)
            {
                if (_dynamicObstacles.Remove(dynamicObstacle))
                {
                    return UpdateExclusionMask();
                }
            }

            return false;
        }
示例#8
0
文件: Cell.cs 项目: forwolk/UnityApex
        internal bool AddDynamicObstacle(IDynamicObstacle dynamicObstacle)
        {
            if (_permanentlyBlocked)
            {
                return false;
            }

            if (_dynamicObstacles == null)
            {
                _dynamicObstacles = new List<IDynamicObstacle>(2);
            }

            if (_dynamicObstacles.AddUnique(dynamicObstacle))
            {
                return UpdateExclusionMask();
            }

            return false;
        }