Esempio n. 1
0
        private static void SetWest(Road west)
        {
            west.east = null;
            //road.west = null;

            switch (west.type)
            {
            case RoadType.Corner:   west.SetTypeAndDirection(RoadType.End, west.direction == RoadDirection.NorthEast ? RoadDirection.North : RoadDirection.South); break;

            case RoadType.Straight: west.SetTypeAndDirection(RoadType.End, RoadDirection.West); break;

            case RoadType.End:
                if (!WorldMap.IsOwnerTypeOf(typeof(EntranceBuilding), west.Position))
                {
                    WorldMap.ClearTile(west.Position);
                    Object.Destroy(west.gameObject);
                }
                break;

            case RoadType.Cross_T:
                if (west.direction == RoadDirection.North)
                {
                    west.SetTypeAndDirection(RoadType.Corner, RoadDirection.NorthWest);
                }
                else if (west.direction == RoadDirection.South)
                {
                    west.SetTypeAndDirection(RoadType.Corner, RoadDirection.SouthWest);
                }
                else
                {
                    west.SetTypeAndDirection(RoadType.Straight, RoadDirection.Vertical);
                }
                break;

            case RoadType.Cross_X: west.SetTypeAndDirection(RoadType.Cross_T, RoadDirection.West); break;
            }

            //DelayedOpsManager.AddOperation(() => { RouteSetWP.RecalculateRoutes(west); });
            //RouteSetWP.RecalculateRoutes(west);
        }
Esempio n. 2
0
        private static void SetSouth(Road south)
        {
            south.north = null;
            //road.south = null;

            switch (south.type)
            {
            case RoadType.Corner:   south.SetTypeAndDirection(RoadType.End, south.direction == RoadDirection.NorthWest ? RoadDirection.West : RoadDirection.East); break;

            case RoadType.Straight: south.SetTypeAndDirection(RoadType.End, RoadDirection.South); break;

            case RoadType.End:
                if (!WorldMap.IsOwnerTypeOf(typeof(EntranceBuilding), south.Position))
                {
                    WorldMap.ClearTile(south.Position);
                    Object.Destroy(south.gameObject);
                }
                break;

            case RoadType.Cross_T:
                if (south.direction == RoadDirection.North)
                {
                    south.SetTypeAndDirection(RoadType.Straight, RoadDirection.Horizontal);
                }
                else if (south.direction == RoadDirection.West)
                {
                    south.SetTypeAndDirection(RoadType.Corner, RoadDirection.SouthWest);
                }
                else
                {
                    south.SetTypeAndDirection(RoadType.Corner, RoadDirection.SouthEast);
                }
                break;

            case RoadType.Cross_X: south.SetTypeAndDirection(RoadType.Cross_T, RoadDirection.South); break;
            }

            //DelayedOpsManager.AddOperation(() => { RouteSetWP.RecalculateRoutes(south); });
            //RouteSetWP.RecalculateRoutes(south);
        }
Esempio n. 3
0
        private static void DestroyRoad(Road road)
        {
            WorldMap.ClearTile(road.transform.position);
            Object.Destroy(road.gameObject);

            Road north = road.north;
            Road south = road.south;
            Road west  = road.west;
            Road east  = road.east;

            //Timer timer = new Timer();
            //timer.Start();

            switch (road.type)
            {
            case RoadType.Corner:

                switch (road.direction)
                {
                case RoadDirection.NorthWest:

                    SetNorth(north);
                    SetWest(west);

                    break;

                case RoadDirection.NorthEast:

                    SetNorth(north);
                    SetEast(east);

                    break;

                case RoadDirection.SouthWest:

                    SetSouth(south);
                    SetWest(west);

                    break;

                case RoadDirection.SouthEast:

                    SetSouth(south);
                    SetEast(east);

                    break;
                }
                break;

            case RoadType.Straight:

                switch (road.direction)
                {
                case RoadDirection.Horizontal:

                    SetWest(west);
                    SetEast(east);

                    break;

                case RoadDirection.Vertical:

                    SetNorth(north);
                    SetSouth(south);

                    break;
                }
                break;

            case RoadType.End:

                switch (road.direction)
                {
                case RoadDirection.North:

                    SetNorth(north);

                    break;

                case RoadDirection.South:

                    SetSouth(south);

                    break;

                case RoadDirection.West:

                    SetWest(west);

                    break;

                case RoadDirection.East:

                    SetEast(east);

                    break;
                }
                break;

            case RoadType.Cross_T:

                switch (road.direction)
                {
                case RoadDirection.North:

                    SetNorth(north);
                    SetWest(west);
                    SetEast(east);

                    break;

                case RoadDirection.South:

                    SetSouth(south);
                    SetWest(west);
                    SetEast(east);

                    break;

                case RoadDirection.West:

                    SetNorth(north);
                    SetSouth(south);
                    SetWest(west);

                    break;

                case RoadDirection.East:

                    SetNorth(north);
                    SetSouth(south);
                    SetEast(east);

                    break;
                }
                break;

            case RoadType.Cross_X:

                SetNorth(north);
                SetSouth(south);
                SetWest(west);
                SetEast(east);

                break;
            }

            //DelayedOpsManager.AddOperation(() => { RouteSetWP.RecalculateRoutes(road); });
            //RouteSetWP.RecalculateRoutes(road);

            //Debug.Log("<color=orange>Routes Recalculation:</color> " + timer.ElapsedTime(Timer.Units.Milliseconds) + " ms.");
        }