Exemplo n.º 1
0
        private void UpdateOppositeAccessPoints()
        {
            foreach (AccessPoint ap in tempLocation.AccessPoints)
            {
                string dir          = ap.Direction;
                string oppositeDir  = AccessPoint.ReturnOppositeDirection(dir);
                string locToChange  = ap.DestLoc;
                string zoneToChange = ap.DestZone;

                Zone     targetZone     = world.GetZoneFromString(zoneToChange);
                Location targetLocation = targetZone.GetLocationByName(locToChange);
                if (targetLocation.AccessPoints == null)
                {
                    targetLocation.AccessPoints = new List <AccessPoint>();
                }
                if (targetLocation.AccessPoints.Count > 0)
                {
                    foreach (AccessPoint apTarget in targetLocation.AccessPoints)
                    {
                        if (apTarget.Direction == oppositeDir)
                        {
                            apTarget.DestZone = currentZone.Name;
                            apTarget.DestLoc  = tempLocation.Title;
                            return;
                        }
                    }
                }
                else
                {
                    AccessPoint tempAp = new AccessPoint(oppositeDir, currentZone.Name, tempLocation.Title);
                    targetLocation.AccessPoints.Add(tempAp);
                }
            }
        }
        private void RemoveOppositeAccessPointFromLocation(AccessPoint ap, Location loc)
        {
            bool apRemoved = false;

            foreach (AccessPoint oppositeAp in loc.AccessPoints)
            {
                if (AccessPoint.ReturnOppositeDirection(ap.Direction) == oppositeAp.Direction &&
                    currentZone.Name == oppositeAp.DestZone &&
                    currentLocation.Title == oppositeAp.DestLoc)
                {
                    loc.AccessPoints.Remove(oppositeAp);
                    apRemoved = true;
                }
                if (apRemoved)
                {
                    break;
                }
            }
        }