示例#1
0
 public void ExecuteSteps(int pBounds)
 {
     if (pathSteps_.Count == 0)
     {
         return;
     }
     if (pathSteps_[0].eventBound_ == pBounds)
     {
         mCurrentStep = pathSteps_[0];
         MoveToPosition(mCurrentStep.targetPosition_);
         pathSteps_.RemoveAt(0);
     }
 }
示例#2
0
        public void SetIntegration(int pIndex)
        {
            if (mSelectedUnit != null)
            {
                //NavMeshHit nHit;
                //if (NavMesh.SamplePosition(mCurrentInteractionObj.transform.position, out nHit, 1, NavMesh.AllAreas))
                //{
                //    Debug.Log("Inside Navmesh SamplePosition " + mCurrentInteractionObj);
                //    mTargetUIOverlayPos = Input.mousePosition;
                //    stepOverlayUI.gameObject.SetActive(true);
                //    mSelectedUnit.AddSteps(nHit.position);
                //}
                mSelectedUnit.AddSteps(mCurrentInteractionObj.transform.position);
                GameObject GO = null;
                Debug.Log("mSelectedUnit : " + mSelectedUnit.pathSteps_.Count);
                PathStep pathStep = mSelectedUnit.pathSteps_[mSelectedUnit.pathSteps_.Count - 1];
                switch (pIndex)
                {
                default:
                case 0:
                    GO = GameObject.CreatePrimitive(PrimitiveType.Cube);
                    pathStep.debugOnPathReach = "kick";
                    break;

                case 1:
                    GO = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                    pathStep.debugOnPathReach = "open";
                    break;

                case 2:
                    GO = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
                    pathStep.debugOnPathReach = "flashbang";
                    break;
                }
                GO.transform.localScale = Vector3.one * 0.1f;
                GO.transform.position   = mSelectedUnit.pathSteps_[mSelectedUnit.pathSteps_.Count - 1].targetPosition_ + Vector3.up;
                Destroy(GO.GetComponent <SphereCollider>());
            }
        }
示例#3
0
        public void AddSteps(Vector3 pTargetPos)
        {
            float   distance = 0f;
            Vector3 origin   = transform.position;

            if (pathSteps_.Count > 0)
            {
                distance = Vector3.Distance(pTargetPos, pathSteps_[pathSteps_.Count - 1].targetPosition_);
                origin   = pathSteps_[pathSteps_.Count - 1].targetPosition_;
            }
            if (pathSteps_.Count == 0 || distance > mAgent.stoppingDistance)
            {
                PathStep ps = new PathStep(pTargetPos, new NavMeshPath());
                if (NavMesh.CalculatePath(origin, pTargetPos, NavMesh.AllAreas, ps.path_))
                {
                    ps.eventBound_ = nextStepEvent_;
                    nextStepEvent_ = 0;
                    pathSteps_.Add(ps);
                    UpdatePathView();
                }
            }
        }