Beispiel #1
0
        public void FillMapData(bool[] _mapData)
        {
            var minX = mNowFowPos.x - mViewRange;
            var maxX = mNowFowPos.x + mViewRange;
            var minY = mNowFowPos.y - mViewRange;
            var maxY = mNowFowPos.y + mViewRange;

            for (var x = minX; x <= maxX; x++)
            {
                for (var y = minY; y <= maxY; y++)
                {
                    //超出边界范围,不进行运算
                    if (x < 1 || y < 1 || x >= CEFowFacade.instance.fowMapWidth - 1 || y >= CEFowFacade.instance.fowMapHeight - 1)
                    {
                        continue;
                    }

                    //在圆形区域外,不进行运算
                    var disSquare = (x - mNowFowPos.x) * (x - mNowFowPos.x) + (y - mNowFowPos.y) * (y - mNowFowPos.y);
                    if (disSquare > mViewRangeSquare)
                    {
                        continue;
                    }

                    CEFowFacade.SetMap(_mapData, x, y);
                    CEFowFacade.SetMap(CEFowFacade.instance.data.exploreMapData, x, y);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// 更新FogData
        /// 通知Painter重绘RT
        /// </summary>
        private void RunLogic()
        {
            selfViewMapDataList.Clear();
            var minX          = mNowFowPos.x - mViewRange;
            var maxX          = mNowFowPos.x + mViewRange;
            var minY          = mNowFowPos.y - mViewRange;
            var maxY          = mNowFowPos.y + mViewRange;
            var isNeedRepaint = false;

            for (var x = minX; x <= maxX; x++)
            {
                for (var y = minY; y <= maxY; y++)
                {
                    //超出边界范围,不进行运算
                    if (x < 1 || y < 1 || x >= CEFowFacade.instance.fowMapWidth - 1 || y >= CEFowFacade.instance.fowMapHeight - 1)
                    {
                        continue;
                    }

                    //在圆形区域外,不进行运算
                    float disSquare = (x - mNowFowPos.x + 0.5f) * (x - mNowFowPos.x + 0.5f) + (y - mNowFowPos.y + 0.5f) * (y - mNowFowPos.y + 0.5f);
                    if (disSquare > mViewRangeSquare)
                    {
                        continue;
                    }

                    isNeedRepaint = true;
                    selfViewMapDataList.Add(new Vector2Int(x, y));
                    CEFowFacade.SetMap(CEFowFacade.instance.data.exploreMapData, x, y);
                }
            }

            if (!isNeedRepaint)
            {
                return;
            }
            CEFowFacade.instance.painter.MarkDynamicViewDataChange();
            CEFowFacade.instance.painter.MarkExploreDataChange();
        }
        private void RecalculateColorBuffer()
        {
            var tempViewMapData = (bool[])mCacheStaticViewMapData.Clone();

            CEFowFacade.instance.dynamicExplorerList.ForEach(explorer => { explorer.selfViewMapDataList.ForEach(pos => { CEFowFacade.SetMap(tempViewMapData, pos.x, pos.y); }); });
            CEFowFacade.instance.data.viewMapData = tempViewMapData;

            for (var x = 0; x < CEFowFacade.instance.fowMapWidth; x++)
            {
                for (var y = 0; y < CEFowFacade.instance.fowMapHeight; y++)
                {
                    var color = new Color
                    {
                        r = CEFowFacade.GetMap(CEFowFacade.instance.data.exploreMapData, x, y) ? 1 : 0,
                        g = CEFowFacade.GetMap(tempViewMapData, x, y) ? 1 : 0,
                        b = 0,
                    };

                    mColorBuffer[x + y * CEFowFacade.instance.fowMapWidth] = color;
                }
            }
        }