Ejemplo n.º 1
0
        public static FloodPathTracer Construct(Vector3 start, FloodPath flood, OnPathDelegate callback = null)
        {
            var p = PathPool.GetPath <FloodPathTracer>();

            p.Setup(start, flood, callback);
            return(p);
        }
    /** Starts a path specified by PathTypesDemo.activeDemo */
    public void DemoPath()
    {
        Path p = null;

        if (activeDemo == 0)
        {
            p = ABPath.Construct(start.position, end.position, OnPathComplete);
        }
        else if (activeDemo == 1)
        {
            MultiTargetPath mp = MultiTargetPath.Construct(multipoints.ToArray(), end.position, null, OnPathComplete);
            p = mp;
        }
        else if (activeDemo == 2)
        {
            RandomPath rp = RandomPath.Construct(start.position, searchLength, OnPathComplete);
            rp.spread        = spread;
            rp.aimStrength   = aimStrength;
            rp.aim           = end.position;
            rp.replaceChance = replaceChance;

            p = rp;
        }
        else if (activeDemo == 3)
        {
            FleePath fp = FleePath.Construct(start.position, end.position, searchLength, OnPathComplete);
            fp.aimStrength   = aimStrength;
            fp.replaceChance = replaceChance;
            fp.spread        = spread;

            p = fp;
        }
        else if (activeDemo == 4)
        {
            ConstantPath constPath = ConstantPath.Construct(end.position, searchLength, OnPathComplete);

            p = constPath;
        }
        else if (activeDemo == 5)
        {
            FloodPath fp = FloodPath.Construct(end.position, null);
            lastFlood = fp;
            p         = fp;
        }
        else if (activeDemo == 6 && lastFlood != null)
        {
            FloodPathTracer fp = FloodPathTracer.Construct(end.position, lastFlood, OnPathComplete);


            p = fp;
        }

        if (p != null)
        {
            AstarPath.StartPath(p);
            lastPath = p;
        }
    }
Ejemplo n.º 3
0
        public FloodPathConstraint(FloodPath path)
        {
            if (path == null)
            {
#if !SERVER
                UnityEngine.Debug.LogWarning("FloodPathConstraint should not be used with a NULL path");
#endif
            }
            this.path = path;
        }
Ejemplo n.º 4
0
        // Token: 0x060029EC RID: 10732 RVA: 0x001C21BC File Offset: 0x001C03BC
        private void DemoPath()
        {
            Path path = null;

            switch (this.activeDemo)
            {
            case PathTypesDemo.DemoMode.ABPath:
                path = ABPath.Construct(this.start.position, this.end.position, new OnPathDelegate(this.OnPathComplete));
                break;

            case PathTypesDemo.DemoMode.MultiTargetPath:
                base.StartCoroutine(this.DemoMultiTargetPath());
                break;

            case PathTypesDemo.DemoMode.RandomPath:
            {
                RandomPath randomPath = RandomPath.Construct(this.start.position, this.searchLength, new OnPathDelegate(this.OnPathComplete));
                randomPath.spread      = this.spread;
                randomPath.aimStrength = this.aimStrength;
                randomPath.aim         = this.end.position;
                path = randomPath;
                break;
            }

            case PathTypesDemo.DemoMode.FleePath:
            {
                FleePath fleePath = FleePath.Construct(this.start.position, this.end.position, this.searchLength, new OnPathDelegate(this.OnPathComplete));
                fleePath.aimStrength = this.aimStrength;
                fleePath.spread      = this.spread;
                path = fleePath;
                break;
            }

            case PathTypesDemo.DemoMode.ConstantPath:
                base.StartCoroutine(this.DemoConstantPath());
                break;

            case PathTypesDemo.DemoMode.FloodPath:
                path = (this.lastFloodPath = FloodPath.Construct(this.end.position, null));
                break;

            case PathTypesDemo.DemoMode.FloodPathTracer:
                if (this.lastFloodPath != null)
                {
                    path = FloodPathTracer.Construct(this.end.position, this.lastFloodPath, new OnPathDelegate(this.OnPathComplete));
                }
                break;
            }
            if (path != null)
            {
                AstarPath.StartPath(path, false);
                this.lastPath = path;
            }
        }
Ejemplo n.º 5
0
        /// <summary>Starts a path specified by PathTypesDemo.activeDemo</summary>
        void DemoPath()
        {
            Path p = null;

            switch (activeDemo)
            {
            case DemoMode.ABPath:
                p = ABPath.Construct(start.position, end.position, OnPathComplete);
                break;

            case DemoMode.MultiTargetPath:
                StartCoroutine(DemoMultiTargetPath());
                break;

            case DemoMode.ConstantPath:
                StartCoroutine(DemoConstantPath());
                break;

            case DemoMode.RandomPath:
                RandomPath rp = RandomPath.Construct(start.position, searchLength, OnPathComplete);
                rp.spread      = spread;
                rp.aimStrength = aimStrength;
                rp.aim         = end.position;

                p = rp;
                break;

            case DemoMode.FleePath:
                FleePath fp = FleePath.Construct(start.position, end.position, searchLength, OnPathComplete);
                fp.aimStrength = aimStrength;
                fp.spread      = spread;

                p = fp;
                break;

            case DemoMode.FloodPath:
                p = lastFloodPath = FloodPath.Construct(end.position, null);
                break;

            case DemoMode.FloodPathTracer:
                if (lastFloodPath != null)
                {
                    FloodPathTracer fpt = FloodPathTracer.Construct(end.position, lastFloodPath, OnPathComplete);
                    p = fpt;
                }
                break;
            }

            if (p != null)
            {
                AstarPath.StartPath(p);
                lastPath = p;
            }
        }
Ejemplo n.º 6
0
        protected void Setup(Vector3 start, FloodPath flood, OnPathDelegate callback)
        {
            this.flood = flood;

            if (flood == null || flood.PipelineState < PathState.Returned)
            {
                throw new System.ArgumentException("You must supply a calculated FloodPath to the 'flood' argument");
            }

            base.Setup(start, flood.originalStartPoint, callback);
            nnConstraint = new FloodPathConstraint(flood);
        }
Ejemplo n.º 7
0
    /** Starts a path specified by PathTypesDemo.activeDemo */
    void DemoPath()
    {
        Path p = null;

        if (activeDemo == DemoMode.ABPath)
        {
            p = ABPath.Construct(start.position, end.position, OnPathComplete);

            if (agents != null && agents.Length > 0)
            {
                List <Vector3> pts = Pathfinding.Util.ListPool <Vector3> .Claim(agents.Length);

                Vector3 avg = Vector3.zero;
                for (int i = 0; i < agents.Length; i++)
                {
                    pts.Add(agents[i].transform.position);
                    avg += pts[i];
                }
                avg /= pts.Count;
                for (int i = 0; i < agents.Length; i++)
                {
                    pts[i] -= avg;
                }

                Pathfinding.PathUtilities.GetPointsAroundPoint(end.position, AstarPath.active.graphs[0] as IRaycastableGraph, pts, 0, 0.2f);
                for (int i = 0; i < agents.Length; i++)
                {
                    if (agents[i] == null)
                    {
                        continue;
                    }

                    agents[i].target.position = pts[i];
                    agents[i].UpdatePath();
                }
            }
        }
        else if (activeDemo == DemoMode.MultiTargetPath)
        {
            MultiTargetPath mp = MultiTargetPath.Construct(multipoints.ToArray(), end.position, null, OnPathComplete);
            p = mp;
        }
        else if (activeDemo == DemoMode.RandomPath)
        {
            RandomPath rp = RandomPath.Construct(start.position, searchLength, OnPathComplete);
            rp.spread      = spread;
            rp.aimStrength = aimStrength;
            rp.aim         = end.position;

            p = rp;
        }
        else if (activeDemo == DemoMode.FleePath)
        {
            FleePath fp = FleePath.Construct(start.position, end.position, searchLength, OnPathComplete);
            fp.aimStrength = aimStrength;
            fp.spread      = spread;

            p = fp;
        }
        else if (activeDemo == DemoMode.ConstantPath)
        {
            StartCoroutine(CalculateConstantPath());
            p = null;
        }
        else if (activeDemo == DemoMode.FloodPath)
        {
            FloodPath fp = FloodPath.Construct(end.position, null);
            lastFlood = fp;
            p         = fp;
        }
        else if (activeDemo == DemoMode.FloodPathTracer && lastFlood != null)
        {
            FloodPathTracer fp = FloodPathTracer.Construct(end.position, lastFlood, OnPathComplete);

            p = fp;
        }

        if (p != null)
        {
            AstarPath.StartPath(p);
            lastPath = p;
        }
    }
		public static FloodPathTracer Construct (Vector3 position , FloodPath floodPath , OnPathDelegate callback)
        { return null; }
Ejemplo n.º 9
0
    public void DemoPath()
    {
        Path path = null;

        if (this.activeDemo == 0)
        {
            path = ABPath.Construct(this.start.position, this.end.position, new OnPathDelegate(this.OnPathComplete));
            if (this.agents != null && this.agents.Length > 0)
            {
                List <Vector3> list = ListPool <Vector3> .Claim(this.agents.Length);

                Vector3 vector = Vector3.zero;
                for (int i = 0; i < this.agents.Length; i++)
                {
                    list.Add(this.agents[i].transform.position);
                    vector += list[i];
                }
                vector /= (float)list.Count;
                for (int j = 0; j < this.agents.Length; j++)
                {
                    List <Vector3> list2;
                    int            index;
                    (list2 = list)[index = j] = list2[index] - vector;
                }
                PathUtilities.GetPointsAroundPoint(this.end.position, AstarPath.active.graphs[0] as IRaycastableGraph, list, 0f, 0.2f);
                for (int k = 0; k < this.agents.Length; k++)
                {
                    if (!(this.agents[k] == null))
                    {
                        this.agents[k].target.position = list[k];
                        this.agents[k].UpdatePath();
                    }
                }
            }
        }
        else if (this.activeDemo == 1)
        {
            MultiTargetPath multiTargetPath = MultiTargetPath.Construct(this.multipoints.ToArray(), this.end.position, null, new OnPathDelegate(this.OnPathComplete));
            path = multiTargetPath;
        }
        else if (this.activeDemo == 2)
        {
            RandomPath randomPath = RandomPath.Construct(this.start.position, this.searchLength, new OnPathDelegate(this.OnPathComplete));
            randomPath.spread      = this.spread;
            randomPath.aimStrength = this.aimStrength;
            randomPath.aim         = this.end.position;
            path = randomPath;
        }
        else if (this.activeDemo == 3)
        {
            FleePath fleePath = FleePath.Construct(this.start.position, this.end.position, this.searchLength, new OnPathDelegate(this.OnPathComplete));
            fleePath.aimStrength = this.aimStrength;
            fleePath.spread      = this.spread;
            path = fleePath;
        }
        else if (this.activeDemo == 4)
        {
            base.StartCoroutine(this.Constant());
            path = null;
        }
        else if (this.activeDemo == 5)
        {
            FloodPath floodPath = FloodPath.Construct(this.end.position, null);
            this.lastFlood = floodPath;
            path           = floodPath;
        }
        else if (this.activeDemo == 6 && this.lastFlood != null)
        {
            FloodPathTracer floodPathTracer = FloodPathTracer.Construct(this.end.position, this.lastFlood, new OnPathDelegate(this.OnPathComplete));
            path = floodPathTracer;
        }
        if (path != null)
        {
            AstarPath.StartPath(path, false);
            this.lastPath = path;
        }
    }
Ejemplo n.º 10
0
 protected override void Reset()
 {
     base.Reset();
     flood = null;
 }