Beispiel #1
0
        public bool CheckDistance(double sqrDistance)
        {
            bool complete = (sqrDistance < 0.3);

            if (complete)
            {
                PatrolAction currentPoint = actions[currentPatrolPoint];

                if (currentPoint.type == PatrolActionType.Wait)
                {
                    delta += Time.deltaTime;

                    if (delta > currentPoint.delay)
                    {
                        SetNextPoint();
                        delta = 0;
                    }
                }
                else //move
                {
                    SetNextPoint();
                }
            }

            return(complete);
        }
Beispiel #2
0
        public void FromSave(string patrol)
        {
            try
            {
                //EvaDebug.DebugWarning("Patrol.FromSave()");
                EvaTokenReader reader = new EvaTokenReader(patrol);

                string sAllowRunning       = reader.NextTokenEnd(',');
                string sCurrentPatrolPoint = reader.NextTokenEnd(',');
                string sReferenceBody      = reader.NextTokenEnd(',');
                string sPointlist          = reader.NextToken('{', '}');

                AllowRunning       = bool.Parse(sAllowRunning);
                currentPatrolPoint = int.Parse(sCurrentPatrolPoint);
                referenceBody      = sReferenceBody;

                actions.Clear();

                if (!string.IsNullOrEmpty(sPointlist))
                {
                    reader = new EvaTokenReader(sPointlist);

                    while (!reader.EOF)
                    {
                        PatrolAction action = new PatrolAction();

                        string token = reader.NextToken('(', ')');
                        action.FromSave(token);

                        actions.Add(action);
                    }


                    if (EvaSettings.displayDebugLines)
                    {
                        GenerateLine();
                    }
                }
            }
            catch
            {
                throw new Exception("[EFX] Patrol.FromSave Failed.");
            }
        }
Beispiel #3
0
        public Vector3d GetNextTarget()
        {
            PatrolAction currentPoint = actions[currentPatrolPoint];

            return(Util.GetWorldPos3DLoad(currentPoint.position));
        }
Beispiel #4
0
		public void FromSave(string patrol)
        {
            try
            {
                //EvaDebug.DebugWarning("Patrol.FromSave()");
                EvaTokenReader reader = new EvaTokenReader(patrol);

                string sAllowRunning = reader.NextTokenEnd(',');
                string sCurrentPatrolPoint = reader.NextTokenEnd(',');
                string sReferenceBody = reader.NextTokenEnd(',');
                string sPointlist = reader.NextToken('{', '}');

                AllowRunning = bool.Parse(sAllowRunning);
                currentPatrolPoint = int.Parse(sCurrentPatrolPoint);
                referenceBody = sReferenceBody;

                actions.Clear();

                if (!string.IsNullOrEmpty(sPointlist))
                {
                    reader = new EvaTokenReader(sPointlist);

                    while (!reader.EOF)
                    {
                        PatrolAction action = new PatrolAction();

                        string token = reader.NextToken('(', ')');
                        action.FromSave(token);

                        actions.Add(action);
                    }


                    if (EvaSettings.displayDebugLines)
                        GenerateLine();
                }
            }
            catch
            {
                throw new Exception("[EFX] Patrol.FromSave Failed.");
            }
        }