Пример #1
0
        public void Update(BombAreaInfo curBombAreaInfo, Vector2 selfPlayPos, float rate, float windowWidthByRice, bool isMiniMap = true)
        {
            Vector2 referPosByPixel = Vector2.zero;

            var temperVec = curBombAreaInfo.Center.ShiftedUIVector2();

            if (curBombAreaInfo.Radius.Equals(0) || curBombAreaInfo.Num.Equals(0) || Vector2.Distance(selfPlayPos, temperVec) > 1.414f * windowWidthByRice / 2 + curBombAreaInfo.Radius) //不在地图视野内
            {
                UIUtils.SetActive(tran, false);
            }
            else
            {
                UIUtils.SetActive(tran, true);
                var material = img.material;
                //设置大小
                float beishu      = (curBombAreaInfo.Radius * rate) / (rectTransform.rect.width / 2);
                float beishuDaosu = (rectTransform.rect.width / 2) / (curBombAreaInfo.Radius * rate);
                var   tilingX     = Mathf.Max(beishuDaosu, 0);
                float tilingY     = tilingX;
                material.SetTextureScale("_MainTex", new Vector2(tilingX, tilingY));

                //设置位置
                Vector2 startPoint = referPosByPixel + (temperVec - selfPlayPos) * rate;
                var     halfW      = rectTransform.rect.width / 2;
                Vector2 endPoint   = referPosByPixel - new Vector2(halfW, halfW) + new Vector2(beishu * halfW, beishu * halfW);
                var     deltaX     = (endPoint.x - startPoint.x) / (beishu * rectTransform.rect.width);
                var     deltaY     = (endPoint.y - startPoint.y) / (beishu * rectTransform.rect.width);
                material.SetTextureOffset("_MainTex", new Vector2(deltaX, deltaY));

                UnityEngine.Color bColor = Color.white;
                if (isMiniMap)
                {
                    bColor = new Color(255 / 255f, 9 / 255f, 5 / 255f, 102 / 255f);
                }
                else
                {
                    bColor = new Color(255 / 255f, 9 / 255f, 5 / 255f, 102 / 255f);
                }
                material.SetColor("_BoundColor", bColor);
                material.SetFloat("_BoundWidth", rectTransform.rect.width);
                material.SetFloat("_ComponentWidth", rectTransform.rect.width);
            }
        }
Пример #2
0
        public void UpdateDuQuanAndSafe(Transform curDuquanRoot, Transform safeDuquanRoot, Transform miniDisTran, Transform curBombAreaRoot)
        {
            var data = adapter;

            if (data != null)
            {
                curDuquan  = data.CurDuquan;
                safeDuquan = data.NextDuquan;

                if (SharedConfig.IsOffline)
                {
//                    UIUtils.SetActive(curDuquanRoot, true);
//                    UIUtils.SetActive(safeDuquanRoot, true);
                    UIUtils.SetActive(miniDisTran, true);
//                    if(UpdateSafe != null)
//                        UpdateSafe();
//                    if(UpdateDuquan != null)
//                        UpdateDuquan();
                    if (UpdataMiniDis != null)
                    {
                        UpdataMiniDis();
                    }
                }
                else
                {
//                    if (curDuquan.Level != adapter.OffLineNum && curDuquan.Radius != 0)
//                    {
//                        UIUtils.SetActive(curDuquanRoot, true);
//                        if (UpdateDuquan != null)  UpdateDuquan();
//                    }
//                    else
//                        UIUtils.SetActive(curDuquanRoot, false);
//
//                    if (safeDuquan.Level != adapter.OffLineNum && safeDuquan.Radius != 0)
//                    {
//                        UIUtils.SetActive(safeDuquanRoot, true);
//                        if (UpdateSafe != null) UpdateSafe();
//                    }
//                    else
//                        UIUtils.SetActive(safeDuquanRoot, false);

                    if (safeDuquan.Level != adapter.OffLineNum && safeDuquan.Radius != 0)
                    {
                        UIUtils.SetActive(miniDisTran, true);
                        if (UpdataMiniDis != null)
                        {
                            UpdataMiniDis();
                        }
                    }
                    else
                    {
                        UIUtils.SetActive(miniDisTran, false);
                    }
                }

                //轰炸区
                if (curBombAreaInfo == null || data.BombArea.Num != curBombAreaInfo.Num)
                {
                    curBombAreaInfo = data.BombArea;
                }

                if (SharedConfig.IsOffline)
                {
                    UIUtils.SetActive(curBombAreaRoot, true);
                    if (UpdateBombArea != null)
                    {
                        UpdateBombArea();
                    }
                }
                else
                {
                    if (curBombAreaInfo.Num != -1 && curBombAreaInfo.Radius != 0)
                    {
                        UIUtils.SetActive(curBombAreaRoot, true);
                        if (UpdateBombArea != null)
                        {
                            UpdateBombArea();
                        }
                    }
                    else
                    {
                        UIUtils.SetActive(curBombAreaRoot, false);
                    }
                }
            }
        }