예제 #1
0
 private void OnDelete()
 {
     // We first add selected road to the deleted roads because when we do Remove() on "Roads", the next selected road will be the one after previous selected one
     RoadsObs.Instance.DeletedRoads.Add(SelectedRoad);
     Roads.Remove(SelectedRoad);
     serializer.SerializeObject <ObservableCollection <Road> >(Roads, "roads.xml");
 }
예제 #2
0
    IEnumerator UnfadeToNormal(GameObject road)
    {
        yield return(new WaitForSeconds(2f));

        Glow glow = GetRoadFromAngle(transform.rotation.eulerAngles.y).GetComponent <Glow> ();

        if (glow.GetColor() == commandColor)
        {
            glow.SetColor(glow.originalColor);
            Roads.Remove(road);
        }
    }
예제 #3
0
        void objope()
        {
            if (MarksAvaiInitCount > MarksAvaiInitMax)
            {
                if (ClearPoint.X != -1)   //オブジェクト削除
                {
                    int id = GetNearistRoad(ClearPoint, false)[0];
                    for (int i = 0; i < Roads.Count; i++)
                    {
                        if (Roads[i].GetObjectID() == id)
                        {
                            Roads.Remove(Roads[i]);
                            break;
                        }
                    }
                }

                foreach (int i in RoadMarkersNumber)   // 道を追加
                {
                    if (RoadMarkersAvailable[i])
                    {
                        List <int> l = GetNearistRoad(RoadMarkers[i], true);
                        if (l.Count != 0)   //Roadが一つ以上ある場合。
                        //-1、つまり、近くにオブジェクトがない場合はコネクトのidはなしでOK!
                        {
                            foreach (BaseRoadClass o in Roads)
                            {
                                if (l.Contains(o.GetObjectID()))
                                {
                                    o.Add(Roads.Count);
                                }
                            }
                            Roads.Add(new BaseRoadClass(Roads.Count, RoadMarkers[i], "Road", l));
                        }
                        RoadMarkersAvailable[i] = false;
                    }
                }

                foreach (KeyValuePair <int, Point> kv in BuildPoint) //建物追加
                {
                    Builds.Add(new BaseBuildClass(Builds.Count, kv.Value, "Build"));
                    BuildPoint = new Dictionary <int, Point>();
                }

                MarksAvaiInitCount = 0;
            }
        }
        /// <summary>
        /// Remove road from the world
        /// </summary>
        public void RemoveRoad(Road road)
        {
            // Remove any vehicles that may be on the road
            foreach (Lane l in road.InLanes)
            {
                while (l.Vehicles.Count > 0)
                {
                    RemoveCar(l.Vehicles[0]);
                }
            }

            foreach (Lane l in road.OutLanes)
            {
                while (l.Vehicles.Count > 0)
                {
                    RemoveCar(l.Vehicles[0]);
                }
            }

            road.Remove();
            Roads.Remove(road);
        }
예제 #5
0
    private bool DeleteObject <T> (T node)
    {
        if (node is Zone zone)
        {
            try
            {
                var _z = Zones.SingleOrDefault(a => a.ID == zone.ID);

                _z.KillMe();

                RemoveChild(zone);
                Zones.Remove(_z);

                return(true);
            }
            catch (System.Exception)
            {
                return(false);
            }
        }
        else if (node is Building building)
        {
            try
            {
                var _z = Buildings.SingleOrDefault(a => a.Position == building.Position);

                _z.QueueFree();

                RemoveChild(building);
                Buildings.Remove(_z);

                return(true);
            }
            catch (System.Exception)
            {
                return(false);
            }
        }
        else if (node is Road road)
        {
            try
            {
                var _z = Roads.SingleOrDefault(a => a.Position == road.Position);

                _z.QueueFree();

                RemoveChild(road);
                Roads.Remove(_z);

                return(true);
            }
            catch (System.Exception)
            {
                return(false);
            }
        }
        else
        {
            return(false);
        }
    }