Example #1
0
 /// <summary>
 /// Converts a region(position) to a world space position
 /// </summary>
 /// <returns>The world space position of the given region.</returns>
 /// <param name="regionViewHex">View of a region.</param>
 public static CCPoint RegionToWorldspace(RegionViewHex regionViewHex)
 {
     return RegionToWorldspace(((Region)regionViewHex.Model).RegionPosition);
 }
Example #2
0
        /// <summary>
        /// Loads the region views.
        /// </summary>
        /// <param name="point">The point.</param>
        private void LoadRegionViews(CCPoint point)
        {
            var position = PositionHelper.WorldspaceToPosition(point);
            var regionManagerController = Core.Controllers.Controller.Instance.RegionManagerController as Client.Common.Manager.RegionManagerController;
            var newKeys = regionManagerController.GetWorldNearRegionPositions(position.RegionPosition);
            var oldKeys = new HashSet<RegionPosition>(m_regionViewHexDic.Keys);
            var deleteKeys = new HashSet<RegionPosition>(m_regionViewHexDic.Keys);
            deleteKeys.ExceptWith(newKeys);

            foreach (var regionPos in deleteKeys)
            {
                foreach (RegionViewHex.LayerTypes layer in Enum.GetValues(typeof(RegionViewHex.LayerTypes)))
                {
                    this.RemoveChild(m_regionViewHexDic[regionPos].GetChildrens(layer));
                }
                m_regionViewHexDic.Remove(regionPos);
            }

            newKeys.ExceptWith(oldKeys);
            foreach (var regionPos in newKeys)
            {
                var region = regionManagerController.GetRegion(regionPos);
                RegionViewHex regionViewHex = (RegionViewHex)region.View;
                if (regionViewHex == null)
                {
                    regionViewHex = new RegionViewHex(region);
                }

                foreach (RegionViewHex.LayerTypes layer in Enum.GetValues(typeof(RegionViewHex.LayerTypes)))
                {
                    if (regionViewHex.GetChildrens(layer) != null)
                    {
                        this.AddChild(regionViewHex.GetChildrens(layer), (int)layer);
                    }
                }
                m_regionViewHexDic.Add(regionPos, regionViewHex);
            }         
        }