Ejemplo n.º 1
0
        /// <summary>
        /// 换算放大操作
        ///
        /// 因遮罩图尺寸大于视界数组尺寸,需对视界变动数据进行放大操作
        /// </summary>
        private void Enlarge(FogDataFixList fixList, float ratio)
        {
            float _tmp = 1 / ratio;
            int   xMin, xMax, yMin, yMax;
            Color c = clear;

            for (int i = 0; i < fixList.Count; i++)
            {
                c = fixList [i].transparent ? clear : black;

                xMin = (int)(fixList [i].x * _tmp);
                xMax = (int)((fixList [i].x + 1) * _tmp);
                xMax = xMax > mask_w ? mask_w : xMax;

                yMin = (int)(fixList [i].y * _tmp);
                yMax = (int)((fixList [i].y + 1) * _tmp);
                yMax = yMax > mask_h ? mask_h : yMax;

                for (int x = xMin, y = 0; x < xMax; x++)
                {
                    for (y = yMin; y < yMax; y++)
                    {
                        fixGroup.Add(x, y, c);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:BabelTime.GD.UI.BattleUISub.FogAbout.FogBaseData"/> class.
        /// </summary>
        /// <param name="w">世界地图数据存储宽度.</param>
        /// <param name="h">世界地图数据存储高度.</param>
        public FogBaseData(int w, int h)
        {
            this.w = w;
            this.h = h;

            array_w = (int)System.Math.Ceiling((double)w / AlphaArraySize);
            array_h = (int)System.Math.Ceiling((double)h / AlphaArraySize);

            totalAlphaArray = new ulong[array_w, array_h];

            FTools.FogDebug.LogAllocSize("[BaseData]", default(ulong), array_w * array_h);

            fogRangeDic  = new Dictionary <int, FogTransparentRange> ();
            fixList      = new FogDataFixList();
            fixGroupList = new FogDataFixList();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 换算缩小操作
        /// </summary>
        private void Shrink(FogDataFixList fixList, float ratio)
        {
            // TODO:ERROR!!!
            float _tmp = 1 / ratio;
            Dictionary <long, int> fixDic = new Dictionary <long, int> ();
            int  x, y;
            long posId;

            for (int i = 0; i < fixList.Count; i++)
            {
                x = (int)(fixList [i].x * _tmp /* + 0.44445f*/);
                y = (int)(fixList [i].y * _tmp /* + 0.44445f*/);
                if (x < mask_w && y < mask_h)
                {
                    posId = (((long)x) << 32) + y;
                    if (!fixDic.ContainsKey(posId))
                    {
                        fixDic [posId] = fixList [i].transparent ? ClearCount : BlackCount;
                    }
                    else
                    {
                        fixDic [posId] += fixList [i].transparent ? ClearCount : BlackCount;
                    }
                }
            }
            int clearCount, blackCount;

            foreach (var item in fixDic)
            {
                x          = (int)(item.Key >> 32);
                y          = (int)(item.Key & IntMask);
                clearCount = item.Value >> 16;
                blackCount = item.Value & BlackMask;
                if (clearCount > blackCount)
                {
                    fixGroup.Add(x, y, clear);
                }
                else
                {
                    fixGroup.Add(x, y, black);
                }
            }
        }
Ejemplo n.º 4
0
        public FogViewBaseData(int w, int h)
        {
            this.real_w = w;
            this.real_h = h;
            /// 多存储两个单元数据以解决视野偏移的情况
            this.array_w = (w / FogBaseData.AlphaArraySize) + 2;
            this.array_h = (h / FogBaseData.AlphaArraySize) + 2;

            array_real_w = this.array_w * FogBaseData.AlphaArraySize;
            array_real_h = this.array_h * FogBaseData.AlphaArraySize;

            view_size_x = (float)real_w / array_real_w;
            view_size_y = (float)real_h / array_real_h;

            this.array = new ulong[array_w, array_h];

#if UNITY_EDITOR
            FTools.FogDebug.LogAllocSize("[ViewData]", default(ulong), array_w * array_h);
#endif

            fixList = new FogDataFixList();
        }