Пример #1
0
        /// <summary>
        /// Default constructor
        /// </summary>
        /// <param name="zoneItem">The zone item/point's information</param>
        /// <param name="userData">User data</param>
        public ZoneItemViewModel(ZoneItem zoneItem, IPlayerService playerService, ZoneCompletionUserData userData)
        {
            this.DistanceFromPlayer        = -1;
            this.ItemModel                 = zoneItem;
            this.playerService             = playerService;
            this.userData                  = userData;
            this.userData.PropertyChanged += (o, e) => this.RefreshVisibility();

            // Set up handling for collection changed events on the unlocked zone items collections
            foreach (CharacterZoneItems charItems in this.userData.UnlockedZoneItems)
            {
                charItems.ZoneItems.CollectionChanged += UnlockedZoneItems_CollectionChanged;
            }
            this.userData.UnlockedZoneItems.CollectionChanged += (o, e) =>
            {
                if (e.Action == NotifyCollectionChangedAction.Add)
                {
                    foreach (CharacterZoneItems itemAdded in e.NewItems)
                    {
                        itemAdded.ZoneItems.CollectionChanged += UnlockedZoneItems_CollectionChanged;
                    }
                }
            };
            this.userData.UnlockedZoneItems.CollectionChanged += UnlockedZoneItems_CollectionChanged;

            this.RefreshVisibility();
        }
Пример #2
0
        protected override TreeViewItem BuildRoot()
        {
            var id       = 0;
            var worlds   = AssetFinder.ListMainAssets <World>();
            var rootItem = new TreeViewItem {
                id = id++, depth = -1, displayName = "Root"
            };

            foreach (var world in worlds)
            {
                var worldItem = new WorldItem {
                    World = world, id = id++, displayName = world.name
                };

                rootItem.AddChild(worldItem);

                foreach (var zone in world.Zones)
                {
                    var name     = worlds.Count > 1 ? string.Format("{0}/{1}", world.name, zone.name) : zone.name;
                    var zoneItem = new ZoneItem {
                        Zone = zone, id = id++, displayName = name
                    };

                    rootItem.AddChild(zoneItem);
                }
            }

            rootItem.children.Sort((left, right) => left.displayName.CompareTo(right.displayName));
            SetupDepthsFromParentsAndChildren(rootItem);

            return(rootItem);
        }
    public void CreateBSP(SubZone subDungeon)
    {
        if (subDungeon.IAmLeaf())
        {
            //partition if the sub-dungeon is too large
            if (subDungeon.rect.width > maxZoneSize || subDungeon.rect.height > maxZoneSize)
            {
                if (subDungeon.Split(minZoneSize, maxZoneSize))
                {
                    CreateBSP(subDungeon.left);
                    CreateBSP(subDungeon.right);
                }
                else
                {
                    Color color = Random.ColorHSV();

                    SetSubTextureColor(subDungeon.rect, color);

                    ZoneItem zone = Instantiate(zonePrefab, transform);

                    zone.colorPicker = color;
                    zone.Rect        = subDungeon.rect;
                    zone.name        = "Zone " + (SpawnZones.Count + 1) + " - " + zone.transform.position;

                    zone.randomizeSpawnSet = RandomizeSpawnSets;

                    SpawnZones.Add(zone);
                }
            }
        }
    }
Пример #4
0
        private void LoadSettings()
        {
            customFieldId = WebUtils.ParseInt32FromQueryString("id", customFieldId);

            if (customFieldId > 0)
            {
                field = new CustomField(customFieldId);
                if (
                    field != null &&
                    field.CustomFieldId > 0 &&
                    field.SiteId == siteSettings.SiteId
                    )
                {
                    lstZoneItems = ZoneItem.GetByItem(field.Guid);
                }
                else
                {
                    field = null;
                }
            }

            HideControls();

            AddClassToBody("customfields-edit");
        }
Пример #5
0
        protected override TreeViewItem BuildRoot()
        {
            _loadedStyle           = EditorStyles.boldLabel;
            _activeStyle           = new GUIStyle(EditorStyles.boldLabel);
            _activeStyle.fontStyle = FontStyle.BoldAndItalic;

            var id       = 0;
            var rootItem = new TreeViewItem {
                id = id++, depth = -1, displayName = "Root"
            };

            var worldItem = new WorldItem {
                World = WorldManager.Instance, id = id++, displayName = WorldManager.Instance.World.name
            };

            rootItem.AddChild(worldItem);

            foreach (var zone in WorldManager.Instance.Zones)
            {
                if (zone != null)
                {
                    var zoneItem = new ZoneItem {
                        Zone = zone, id = id++, displayName = zone.Zone.name
                    };
                    rootItem.AddChild(zoneItem);
                }
            }

            rootItem.children.Sort((left, right) => left.displayName.CompareTo(right.displayName));
            SetupDepthsFromParentsAndChildren(rootItem);

            return(rootItem);
        }
    public void UnselectAllChildren()
    {
        int length = SpawnZones.Count;

        for (int i = 0; i < length; i++)
        {
            ZoneItem zone = SpawnZones[i];
            zone.Selected = false;
        }
    }
Пример #7
0
    protected Candidate ConnectNewCandidateToConnPoint(ConnPointCandidate lastConnPointCandidate)
    {
        Candidate lastCandidate = lastConnPointCandidate.Owner;

        //LOOK IF ELEMENT IN THE SPAWN ZONE
        ZoneItem zoneItem = GetCandidateSpawnZoneItem(lastConnPointCandidate, lastCandidate.Step);

        //PUT IN SEPARATE FUNCTION
        DungeonSet spawnZoneSet = null;

        if (zoneItem != null)
        {
            spawnZoneSet = zoneItem.spawnSet;

            if (spawnZoneSet == null && zoneItem.randomizeSpawnSet)
            {
                int randomSetIndex = Random.Range(1, factoryOwner.Sets.Count);
                spawnZoneSet      = factoryOwner.Sets[randomSetIndex];
                zoneItem.spawnSet = spawnZoneSet;
            }
        }

        DungeonSet lastCandidateSet = lastCandidate.Set;

        DungeonSet candidatesSet = SetPotentialCandidates(spawnZoneSet, lastCandidateSet);

        //PUT IN SEPARATE FUNCTION
        if (zoneItem != null && zoneItem.emptySpace)
        {
            potentialCandidates = lastCandidateSet.GetAllClosingElementsShuffled(random);
        }
        //

        Candidate newCandidate = null;

        int timesLooped         = 0;
        int maximumLoopsAllowed = potentialCandidates.Length << factoryOwner.loopCheckCount;

        do
        {
            if (timesLooped++ > maximumLoopsAllowed)
            {
                throw new System.Exception("CandidatesManager::Candidate generation takes too long - Possible infinite loop.");
            }

            newCandidate = CreateNewCandidate(lastConnPointCandidate, candidatesSet);
        } while (potentialCandidates.Length > 0 && newCandidate == null);

        if (newCandidate != null)
        {
            AcceptNewCandidate(newCandidate, lastCandidate);
        }

        return(newCandidate);
    }
Пример #8
0
            protected override TreeViewItem BuildRoot()
            {
                _loadedStyle           = EditorStyles.boldLabel;
                _activeStyle           = new GUIStyle(EditorStyles.boldLabel);
                _activeStyle.fontStyle = FontStyle.BoldAndItalic;

                var id       = 0;
                var rootItem = new TreeViewItem {
                    id = id++, depth = -1, displayName = "Root"
                };

                var worldItem = new WorldItem {
                    Store = WorldManager.Instance.Variables, World = WorldManager.Instance, id = id++, displayName = "World"
                };

                rootItem.AddChild(worldItem);

                var playerItem = new PlayerItem {
                    Store = Player.Instance.Variables, Player = Player.Instance, id = id++, displayName = "Player"
                };

                rootItem.AddChild(playerItem);

                var zonesItem = new TreeViewItem {
                    id = id++, displayName = "Zones"
                };

                rootItem.AddChild(zonesItem);

                foreach (var zone in WorldManager.Instance.Zones)
                {
                    if (zone != null)
                    {
                        var zoneItem = new ZoneItem {
                            Store = zone.Variables, Zone = zone, id = id++, displayName = zone.Zone.Name
                        };
                        zonesItem.AddChild(zoneItem);

                        foreach (var npc in zone.Npcs)
                        {
                            var npcItem = new NpcItem {
                                Store = npc.Variables, Npc = npc, id = id++, displayName = string.IsNullOrEmpty(npc.Name) ? "(Npc)" : npc.Name
                            };
                            zoneItem.AddChild(npcItem);
                        }
                    }
                }

                SetExpanded(zonesItem.id, true);
                SetupDepthsFromParentsAndChildren(rootItem);

                return(rootItem);
            }
Пример #9
0
 public static void SetZoneItemType(ZoneItem zoneItem)
 {
     try
     {
         zoneItem.Type = EnumHelper.GetIdByName<LayoutElementType>(zoneItem.TypeName);
         zoneItem.DockType = EnumHelper.GetIdByName<ControlDockType>(zoneItem.DockTypeName);
     }
     catch (Exception ex)
     {
         throw new ArgumentException("\n>> " + TypeName + ".SetZoneItemType Error: " + ex.Message);
     }
 }
 public void ZoneItemRendering(ZoneRenderContext context, ZoneItem item)
 {
     #if DEBUG
     //info: doesn't cover all ZoneItem types
     var writer = context.Html.ViewContext.Writer;
     if (item is RenderPartialZoneItem)
         writer.WriteLine(T("<!-- begin: {0} -->", (item as RenderPartialZoneItem).TemplateName));
     else if (item is ContentPartDisplayZoneItem)
         writer.WriteLine(T("<!-- begin: {0} -->", (item as ContentPartDisplayZoneItem).TemplateName));
     else if (item is ContentPartEditorZoneItem)
         writer.WriteLine(T("<!-- begin: {0} -->", (item as ContentPartEditorZoneItem).TemplateName));
     #endif
 }
    void OnDrawGizmos()
    {
        if (rootZone == null)
        {
            return;
        }

        Gizmos.color = Color.cyan;

        int length = SpawnZones.Count;

        for (int i = 0; i < length; i++)
        {
            ZoneItem zone = SpawnZones[i];

            if (zone.Selected)
            {
                continue;
            }

            Rect rect = zone.GizmoRect;

            Vector3 size = new Vector3(rect.width, zoneHeight, rect.height);
            Vector3 pos  = new Vector3(rect.x, 0f, rect.y);

            Gizmos.DrawWireCube(pos, size);
        }

        Gizmos.color = Color.yellow;

        for (int i = 0; i < length; i++)
        {
            ZoneItem zone = SpawnZones[i];

            if (!zone.Selected)
            {
                continue;
            }

            Rect bounds = zone.GizmoRect;

            Vector3 size = new Vector3(bounds.width, zoneHeight, bounds.height);
            Vector3 pos  = new Vector3(bounds.x, 0f, bounds.y);

            Gizmos.DrawWireCube(pos, size);
        }
    }
Пример #12
0
        public static List<ZoneItem> ToZoneProgress()
        {
            List<_Zone> _zonelist = new List<_Zone>();
            using (var db = new dbEntities())
            {
                _zonelist = db.vZones.Select(x => new _Zone()
                {
                    ZoneId = x.ZoneId,
                    ZoneName = x.ZoneName,
                    ZoneTypeId = (int)x.ZoneTypeId,
                    x = (double)x.x,
                    y = (double)x.y,
                }).ToList();
            }

            string currentzone = string.Empty;
            List<ZoneItem> znplist = new List<ZoneItem>();
            ZoneItem zone = new ZoneItem();
            foreach (var z in _zonelist)
            {
                if (z.ZoneId != currentzone && currentzone != string.Empty)
                {
                    znplist.Add(zone);
                    currentzone = z.ZoneId;
                    zone = new ZoneItem(z.ZoneId);
                    zone.DisplayName = z.ZoneName;
                    zone.Type = z.ZoneTypeId;
                }
                if (currentzone == string.Empty)
                {
                    currentzone = z.ZoneId;
                    zone.Id = z.ZoneId;
                    zone.DisplayName = z.ZoneName;
                    zone.Type = z.ZoneTypeId;
                }
                zone.AddPoint(z.x, z.y);
            }

            return znplist;
        }
Пример #13
0
    protected ZoneItem GetCandidateSpawnZoneItem(ConnPointCandidate lastConnPointCandidate, Vector3 step)
    {
        Vector3 connPointCandidateStep   = lastConnPointCandidate.Rotation * step;
        Vector3 oldConnPointWorldPostion = lastConnPointCandidate.WorldPosition;
        Vector3 oldConnPointStepVoxel    = (oldConnPointWorldPostion + connPointCandidateStep).RoundVec3ToInt();

        List <ZoneItem> spawnZones = zonesGenerator.SpawnZones;

        int spawnZonesCount = spawnZones.Count;

        for (int i = 0; i < spawnZonesCount; i++)
        {
            ZoneItem zoneItem = spawnZones[i];

            bool candidateInSpawnZone = zoneItem.ContainsPoint(oldConnPointStepVoxel);
            if (candidateInSpawnZone)
            {
                return(zoneItem);
            }
        }

        return(null);
    }
Пример #14
0
        void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (!ProductPermission.CanDelete)
                {
                    SiteUtils.RedirectToEditAccessDeniedPage();
                    return;
                }

                bool isDeleted = false;

                foreach (GridDataItem data in grid.SelectedItems)
                {
                    int     productId = Convert.ToInt32(data.GetDataKeyValue("ProductId"));
                    Product product   = new Product(siteSettings.SiteId, productId);

                    if (product != null && product.ProductId != -1 && !product.IsDeleted)
                    {
                        if (product.ZoneId.ToString() != ddZones.SelectedValue && ddZones.SelectedValue != "-1")
                        {
                            ZoneSettings objZone = new ZoneSettings(siteSettings.SiteId, Convert.ToInt32(ddZones.SelectedValue));
                            if (objZone != null && objZone.ZoneId > 0)
                            {
                                ZoneItem zoneNews = new ZoneItem(objZone.ZoneGuid, product.ProductGuid);
                                ZoneItem.Delete(zoneNews.ZoneGuid, zoneNews.ItemGuid);
                            }
                        }
                        else
                        {
                            ContentDeleted.Create(siteSettings.SiteId, product.Title, "Product", typeof(ProductDeleted).AssemblyQualifiedName, product.ProductId.ToString(), Page.User.Identity.Name);

                            product.IsDeleted = true;

                            product.ContentChanged += new ContentChangedEventHandler(product_ContentChanged);

                            product.SaveDeleted();
                            LogActivity.Write("Delete product", product.Title);
                        }

                        //ContentDeleted.Create(siteSettings.SiteId, product.Title, "Product", typeof(ProductDeleted).AssemblyQualifiedName, product.ProductId.ToString(), Page.User.Identity.Name);

                        //product.IsDeleted = true;

                        //product.ContentChanged += new ContentChangedEventHandler(product_ContentChanged);

                        //product.SaveDeleted();
                        //LogActivity.Write("Delete product", product.Title);

                        isDeleted = true;
                    }
                }

                if (isDeleted)
                {
                    SiteUtils.QueueIndexing();
                    grid.Rebind();

                    message.SuccessMessage = ResourceHelper.GetResourceString("Resource", "DeleteSuccessMessage");
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
        }
Пример #15
0
        /// <summary>
        /// Retrieves a collection of zone items located in the given continent
        /// </summary>
        /// <param name="continentId">ID of the continent</param>
        /// <returns></returns>
        public IEnumerable <ZoneItem> GetZoneItemsByContinent(int continentId)
        {
            ConcurrentDictionary <int, ZoneItem> pointsOfInterest = new ConcurrentDictionary <int, ZoneItem>();
            ConcurrentDictionary <int, ZoneItem> tasks            = new ConcurrentDictionary <int, ZoneItem>();
            ConcurrentDictionary <int, ZoneItem> heroPoints       = new ConcurrentDictionary <int, ZoneItem>();

            try
            {
                // Get the continents (used later in determining the location of items)
                var continent = this.GetContinent(continentId);

                Parallel.ForEach(continent.FloorIds, floorId =>
                {
                    var floor = this.GetFloor(continentId, floorId);
                    if (floor != null && floor.Regions != null)
                    {
                        foreach (var region in floor.Regions)
                        {
                            foreach (var subRegion in region.Value.Maps)
                            {
                                var continentRectangle = new Rectangle()
                                {
                                    X      = subRegion.Value.ContinentRectangle.X,
                                    Y      = subRegion.Value.ContinentRectangle.Y,
                                    Height = subRegion.Value.ContinentRectangle.Height,
                                    Width  = subRegion.Value.ContinentRectangle.Width
                                };
                                var mapRectangle = new Rectangle()
                                {
                                    X      = subRegion.Value.MapRectangle.X,
                                    Y      = subRegion.Value.MapRectangle.Y,
                                    Height = subRegion.Value.MapRectangle.Height,
                                    Width  = subRegion.Value.MapRectangle.Width
                                };

                                // Points of Interest
                                foreach (var item in subRegion.Value.PointsOfInterest)
                                {
                                    // If we haven't already added the item, get it's info and add it
                                    if (!pointsOfInterest.ContainsKey(item.PointOfInterestId))
                                    {
                                        // Determine the location
                                        var location = MapsHelper.ConvertToMapPos(
                                            continentRectangle,
                                            mapRectangle,
                                            new Point(item.Coordinates.X, item.Coordinates.Y));

                                        ZoneItem zoneItem          = new ZoneItem();
                                        zoneItem.ID                = item.PointOfInterestId;
                                        zoneItem.Name              = item.Name;
                                        zoneItem.ContinentLocation = new Point(item.Coordinates.X, item.Coordinates.Y);
                                        zoneItem.Location          = new Point(location.X, location.Y);
                                        zoneItem.MapId             = subRegion.Value.MapId;
                                        zoneItem.MapName           = this.MapNamesCache[subRegion.Value.MapId];
                                        var mapChatLink            = item.GetMapChatLink();
                                        if (mapChatLink != null)
                                        {
                                            zoneItem.ChatCode = mapChatLink.ToString();
                                        }

                                        // Translate the item's type
                                        if (item is GW2NET.Maps.Vista)
                                        {
                                            zoneItem.Type = ZoneItemType.Vista;
                                        }
                                        else if (item is GW2NET.Maps.Waypoint)
                                        {
                                            zoneItem.Type = ZoneItemType.Waypoint;
                                        }
                                        else if (item is GW2NET.Maps.Dungeon)
                                        {
                                            zoneItem.Type = ZoneItemType.Dungeon;
                                        }
                                        else
                                        {
                                            zoneItem.Type = ZoneItemType.PointOfInterest;
                                        }

                                        if (!pointsOfInterest.TryAdd(zoneItem.ID, zoneItem))
                                        {
                                            logger.Warn("Failed to add {0} to PointsOfInterest collection", zoneItem);
                                        }
                                    }
                                }

                                // Iterate over every Task in the map (Tasks are the same as HeartQuests)
                                foreach (var task in subRegion.Value.Tasks)
                                {
                                    // If we haven't already added the item, get it's info and add it
                                    if (!tasks.ContainsKey(task.TaskId))
                                    {
                                        // Determine the location
                                        var location = MapsHelper.ConvertToMapPos(
                                            continentRectangle,
                                            mapRectangle,
                                            new Point(task.Coordinates.X, task.Coordinates.Y));

                                        ZoneItem zoneItem          = new ZoneItem();
                                        zoneItem.ID                = task.TaskId;
                                        zoneItem.Name              = task.Objective;
                                        zoneItem.Level             = task.Level;
                                        zoneItem.ContinentLocation = new Point(task.Coordinates.X, task.Coordinates.Y);
                                        zoneItem.Location          = new Point(location.X, location.Y);
                                        zoneItem.MapId             = subRegion.Value.MapId;
                                        zoneItem.MapName           = this.MapNamesCache[subRegion.Value.MapId];
                                        zoneItem.Type              = ZoneItemType.HeartQuest;

                                        if (!tasks.TryAdd(zoneItem.ID, zoneItem))
                                        {
                                            logger.Warn("Failed to add {0} to Tasks collection", zoneItem);
                                        }
                                    }
                                }

                                // Iterate over every skill challenge in the map
                                foreach (var skillChallenge in subRegion.Value.SkillChallenges)
                                {
                                    // Determine the location, this serves an internally-used ID for skill challenges
                                    var location = MapsHelper.ConvertToMapPos(
                                        continentRectangle,
                                        mapRectangle,
                                        new Point(skillChallenge.Coordinates.X, skillChallenge.Coordinates.Y));

                                    // Use a custom-generated ID
                                    int id = (int)(subRegion.Value.MapId + location.X + location.Y);

                                    // If we havn't already added the item, get it's info and add it
                                    if (!heroPoints.ContainsKey(id))
                                    {
                                        ZoneItem zoneItem          = new ZoneItem();
                                        zoneItem.ID                = id;
                                        zoneItem.ContinentLocation = new Point(skillChallenge.Coordinates.X, skillChallenge.Coordinates.Y);
                                        zoneItem.Location          = new Point(location.X, location.Y);
                                        zoneItem.MapId             = subRegion.Value.MapId;
                                        zoneItem.MapName           = this.MapNamesCache[subRegion.Value.MapId];
                                        zoneItem.Type              = Data.Enums.ZoneItemType.HeroPoint;

                                        if (!heroPoints.TryAdd(zoneItem.ID, zoneItem))
                                        {
                                            logger.Warn("Failed to add {0} to HeroPoints collection", zoneItem);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    logger.Debug("{0}-{1} done", continentId, floorId);
                });
            }
            catch (Exception ex)
            {
                // Don't crash if something goes wrong, but log the error
                logger.Error(ex);
            }
            return(pointsOfInterest.Values.Concat(tasks.Values).Concat(heroPoints.Values));
        }
Пример #16
0
        /// <summary>
        /// Retrieves a collection of ZoneItems located in the zone with the given mapID
        /// </summary>
        /// <param name="mapId">The mapID of the zone to retrieve zone items for</param>
        /// <returns>a collection of ZoneItems located in the zone with the given mapID</returns>
        public IEnumerable <ZoneItem> GetZoneItems(int mapId)
        {
            List <ZoneItem> zoneItems = new List <ZoneItem>();

            try
            {
                // Get the continents (used later in determining the location of items)
                var continents = this.service.GetContinents();

                // Get the current map info
                var map = this.service.GetMap(mapId);
                if (map != null)
                {
                    // Find the map's continent
                    var continent = continents[map.ContinentId];
                    map.Continent = continent;

                    // Retrieve details of items on every floor of the map
                    foreach (var floorId in map.Floors)
                    {
                        var floor = this.service.GetMapFloor(map.ContinentId, floorId);
                        if (floor != null && floor.Regions != null)
                        {
                            // Find the region that this map is located in
                            var region = floor.Regions.Values.FirstOrDefault(r => r.Maps.ContainsKey(mapId));
                            if (region != null)
                            {
                                if (region.Maps.ContainsKey(mapId))
                                {
                                    var regionMap = region.Maps[mapId];

                                    // Points of Interest
                                    foreach (var item in regionMap.PointsOfInterest)
                                    {
                                        // If we haven't already added the item, get it's info and add it
                                        if (!zoneItems.Any(zi => zi.ID == item.PointOfInterestId))
                                        {
                                            // Determine the location
                                            var location = MapsHelper.ConvertToMapPos(map, new Point(item.Coordinates.X, item.Coordinates.Y));

                                            ZoneItem zoneItem = new ZoneItem();
                                            zoneItem.ID       = item.PointOfInterestId;
                                            zoneItem.Name     = item.Name;
                                            zoneItem.Location = new Point(location.X, location.Y);
                                            zoneItem.MapId    = mapId;
                                            zoneItem.MapName  = map.MapName;
                                            var mapChatLink = item.GetMapChatLink();
                                            if (mapChatLink != null)
                                            {
                                                zoneItem.ChatCode = mapChatLink.ToString();
                                            }

                                            // Translate the item's type
                                            if (item is GW2DotNET.Entities.Maps.Vista)
                                            {
                                                zoneItem.Type = ZoneItemType.Vista;
                                            }
                                            else if (item is GW2DotNET.Entities.Maps.Waypoint)
                                            {
                                                zoneItem.Type = ZoneItemType.Waypoint;
                                            }
                                            else if (item is GW2DotNET.Entities.Maps.Dungeon)
                                            {
                                                zoneItem.Type = ZoneItemType.Dungeon;
                                            }
                                            else
                                            {
                                                zoneItem.Type = ZoneItemType.PointOfInterest;
                                            }

                                            zoneItems.Add(zoneItem);
                                        }
                                    }

                                    // Iterate over every Task in the map (Tasks are the same as HeartQuests)
                                    foreach (var task in regionMap.Tasks)
                                    {
                                        // If we haven't already added the item, get it's info and add it
                                        if (!zoneItems.Any(zi => zi.ID == task.TaskId))
                                        {
                                            // Determine the location
                                            var location = MapsHelper.ConvertToMapPos(map, new Point(task.Coordinates.X, task.Coordinates.Y));

                                            ZoneItem zoneItem = new ZoneItem();
                                            zoneItem.ID       = task.TaskId;
                                            zoneItem.Name     = task.Objective;
                                            zoneItem.Level    = task.Level;
                                            zoneItem.Location = new Point(location.X, location.Y);
                                            zoneItem.MapId    = mapId;
                                            zoneItem.MapName  = map.MapName;
                                            zoneItem.Type     = ZoneItemType.HeartQuest;

                                            zoneItems.Add(zoneItem);
                                        }
                                    }

                                    // Iterate over every skill challenge in the map
                                    foreach (var skillChallenge in regionMap.SkillChallenges)
                                    {
                                        // Determine the location, this serves an internally-used ID for skill challenges
                                        var location = MapsHelper.ConvertToMapPos(map, new Point(skillChallenge.Coordinates.X, skillChallenge.Coordinates.Y));

                                        // Use a custom-generated ID
                                        int id = (int)(mapId + location.X + location.Y);

                                        // If we havn't already added the item, get it's info and add it
                                        if (!zoneItems.Any(zi => zi.ID == id))
                                        {
                                            ZoneItem zoneItem = new ZoneItem();
                                            zoneItem.ID       = id;
                                            zoneItem.Location = new Point(location.X, location.Y);
                                            zoneItem.MapId    = mapId;
                                            zoneItem.MapName  = map.MapName;
                                            zoneItem.Type     = Data.Enums.ZoneItemType.SkillChallenge;

                                            zoneItems.Add(zoneItem);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                // Don't crash if something goes wrong, but log the error
                logger.Error(ex);
            }
            return(zoneItems);
        }
Пример #17
0
 public void ZoneItemRendering(ZoneRenderContext context, ZoneItem item)
 {
 }
Пример #18
0
        private int SaveData()
        {
            if (!Page.IsValid)
            {
                return(-1);
            }

            try
            {
                if (field == null || field.CustomFieldId == -1)
                {
                    field        = new CustomField();
                    field.SiteId = siteSettings.SiteId;
                }

                if (!IsLanguageTab())
                {
                    field.Name           = txtName.Text.Trim();
                    field.DisplayName    = txtDisplayName.Text.Trim();
                    field.InvalidMessage = txtInvalidMessage.Text.Trim();
                }

                field.FeatureGuid          = Product.FeatureGuid;
                field.DataType             = Convert.ToInt32(ddlDataType.SelectedValue);
                field.FilterType           = Convert.ToInt32(ddlFilterType.SelectedValue);
                field.FieldType            = Convert.ToInt32(ddlFieldType.SelectedValue);
                field.Options              = chlOptions.Items.SelectedItemsToBinaryOrOperator();
                field.IsEnabled            = chkIsEnabled.Checked;
                field.IsRequired           = chkIsRequired.Checked;
                field.AllowComparing       = chkAllowComparing.Checked;
                field.ValidationExpression = txtValidationExpression.Text.Trim();

                if (field.Save())
                {
                    SaveContentLanguage(field.Guid);
                }

                if (customFieldId > 0)
                {
                    LogActivity.Write("Update custom field", field.Name);
                    message.SuccessMessage = ResourceHelper.GetResourceString("Resource", "UpdateSuccessMessage");
                }
                else
                {
                    LogActivity.Write("Create new custom field", field.Name);
                    message.SuccessMessage = ResourceHelper.GetResourceString("Resource", "InsertSuccessMessage");
                }

                foreach (ListItem li in cobZones.Items)
                {
                    Guid itemGuid = Guid.Empty;
                    foreach (ZoneItem item in lstZoneItems)
                    {
                        if (li.Value == item.ZoneGuid.ToString())
                        {
                            itemGuid = item.ItemGuid;
                            break;
                        }
                    }

                    if (li.Selected)
                    {
                        if (itemGuid == Guid.Empty)
                        {
                            ZoneItem zoneItem = new ZoneItem();
                            zoneItem.ItemGuid = field.Guid;
                            zoneItem.ZoneGuid = new Guid(li.Value);
                            zoneItem.Save();
                        }
                    }
                    else
                    {
                        if (itemGuid != Guid.Empty)
                        {
                            ZoneItem.Delete(new Guid(li.Value), itemGuid);
                        }
                    }
                }

                return(field.CustomFieldId);
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
            }

            return(-1);
        }