示例#1
0
        private void OnSceneGUI()
        {
            PointOnMap point = target as PointOnMap;

            for (int i = 0; i < 5; i++)
            {
                Handles.color = new Color(pointLight.r, pointLight.g, pointLight.b, 0.06f * (i + 1));
                Handles.SphereHandleCap(0, point.transform.position, point.transform.rotation, 0.3f - 0.03f * i, EventType.Repaint);
            }
            //Handles.color = Color.red;
            //Handles.SphereHandleCap(0, point.transform.position, point.transform.rotation, 0.1f, EventType.Repaint);
        }
示例#2
0
        private void Awake()
        {
            MapManager mapManager = MapManager.GetInstantiate();

            for (int i = 0; i < mapManager.ring.GetTiers().Count; i++)
            {
                for (int j = 0; j < mapManager.ring.GetTiers()[i].GetPoints().Count; j++)
                {
                    if (point == mapManager.ring.GetTiers()[i].GetPoints()[j])
                    {
                        point = mapManager.instanceRing.GetTiers()[i].GetPoints()[j];
                        break;
                    }
                }
            }
        }
示例#3
0
        public Vector3 GetPointOnPath(PointOnMap end, float part)
        {
            Vector3 startPoint;

            if (points[0] == end)
            {
                startPoint = points[1].transform.position;
            }
            else
            {
                startPoint = points[0].transform.position;
            }
            Vector3 endPoint = end.transform.position;
            float   x        = (endPoint.x - startPoint.x) * part;
            float   y        = (endPoint.y - startPoint.y) * part;
            float   z        = (endPoint.z - startPoint.z) * part;

            return(startPoint + new Vector3(x, y, z));
        }
        private void Start()
        {
            MapManager mapManager = MapManager.GetInstantiate();

            point = potentialPoints[Random.Range(0, potentialPoints.Count)];
            for (int i = 0; i < mapManager.ring.GetTiers().Count; i++)
            {
                for (int j = 0; j < mapManager.ring.GetTiers()[i].GetPoints().Count; j++)
                {
                    if (point == mapManager.ring.GetTiers()[i].GetPoints()[j])
                    {
                        point = mapManager.instanceRing.GetTiers()[i].GetPoints()[j];
                        break;
                    }
                }
            }
            mapManager.SetTier(mapManager.GetTierIndex(point));
            point.pointContainer.Add(this);
        }
示例#5
0
        public int GetTierIndex(PointOnMap point)
        {
            List <Tier> tiers     = instanceRing.GetTiers();
            int         tierIndex = -1;

            for (int i = 0; i < tiers.Count; i++)
            {
                List <PointOnMap> points = tiers[i].GetPoints();
                for (int j = 0; j < points.Count; j++)
                {
                    if (points[j] == point)
                    {
                        tierIndex = i;
                        break;
                    }
                }
            }
            return(tierIndex);
        }
示例#6
0
        private void Start()
        {
            MapManager mapManager = MapManager.GetInstantiate();

            for (int i = 0; i < mapManager.ring.GetTiers().Count; i++)
            {
                for (int j = 0; j < mapManager.ring.GetTiers()[i].GetPoints().Count; j++)
                {
                    if (point == mapManager.ring.GetTiers()[i].GetPoints()[j])
                    {
                        point = mapManager.instanceRing.GetTiers()[i].GetPoints()[j];
                        break;
                    }
                }
            }
            mapManager.SetTier(mapManager.GetTierIndex(point));
            point.pointContainer.Add(this);
            //
            CreateLeaseAction();
        }
示例#7
0
        public Way GetWay(WayType type, PointOnMap start, PointOnMap final, Transform parent)
        {
            ClearAllWays();
            GameObject goWay = new GameObject("curWay");

            goWay.transform.parent = parent;
            Way  retVal = goWay.AddComponent <Way>();
            bool end    = false;
            List <PointOnMap> closePoint = new List <PointOnMap>();
            List <PointOnMap> openPoint  = new List <PointOnMap>();

            openPoint.Add(start);
            while (!end)
            {
                foreach (PointOnMap point in openPoint)
                {
                    foreach (Path path in point.GetAvaliablePaths(type))
                    {
                        if (openPoint.Contains(path.points[0]) && !openPoint.Contains(path.points[1]) && !closePoint.Contains(path.points[1]))
                        {
                            closePoint.Add(path.points[1]);
                        }
                        else if (!openPoint.Contains(path.points[0]) && openPoint.Contains(path.points[1]) && !closePoint.Contains(path.points[0]))
                        {
                            closePoint.Add(path.points[0]);
                        }
                    }
                }
                if (closePoint.Count == 0)
                {
                    break;
                }
                PointOnMap minTimePoint = null;
                foreach (PointOnMap point in closePoint)
                {
                    if (!point.shortWay.check)
                    {
                        Path       shortPath   = null;
                        PointOnMap neaborPoint = null;
                        float      shortTime   = 0;
                        foreach (Path path in point.GetAvaliablePaths(type))
                        {
                            if (openPoint.Contains(path.points[0]))
                            {
                                if (shortPath == null || (shortTime > path.timeToWay + path.points[0].shortWay.totalTime))
                                {
                                    shortPath   = path;
                                    neaborPoint = path.points[0];
                                    shortTime   = path.timeToWay + path.points[0].shortWay.totalTime;
                                }
                            }
                            else if (openPoint.Contains(path.points[1]))
                            {
                                if (shortPath == null || (shortTime > path.timeToWay + path.points[1].shortWay.totalTime))
                                {
                                    shortPath   = path;
                                    neaborPoint = path.points[1];
                                    shortTime   = path.timeToWay + path.points[1].shortWay.totalTime;
                                }
                            }
                        }
                        point.shortWay.totalTime = shortTime;
                        foreach (iWayPlace pom in neaborPoint.shortWay.pointsAndPaths)
                        {
                            point.shortWay.pointsAndPaths.Add(pom);
                        }
                        point.shortWay.pointsAndPaths.Add(shortPath);
                        point.shortWay.pointsAndPaths.Add(point);
                        point.shortWay.check = true;
                    }
                    if (minTimePoint == null || minTimePoint.shortWay.totalTime > point.shortWay.totalTime)
                    {
                        minTimePoint = point;
                    }
                }
                if (minTimePoint == final)
                {
                    end = true;
                    retVal.copyFrom(minTimePoint.shortWay);
                }
                else
                {
                    openPoint.Add(minTimePoint);
                    closePoint.Remove(minTimePoint);
                }
            }
            return(retVal);
        }