コード例 #1
0
        public void UpdateMarkItemCommon(UIUtils.SimplePool markPool, Transform tran, float rate, MiniMapPlayMarkInfo data, Vector2 centerPoint, float centerWidth, Vector2 refePosByPixel)
        {
            if (adapter == null)
            {
                return;
            }

            var tranRT = tran.GetComponent <RectTransform>();
            var offset = new Vector2(tranRT.sizeDelta.x, tranRT.sizeDelta.y) / (2 * rate);
            var result = UIUtils.MathUtil.IsInSquare(centerPoint, centerWidth, centerWidth, offset, true, data.Pos);

            if (!result.IsContact)  //地图内
            {
                MiniMapPlayStatue statue = MiniMapPlayStatue.NONE;
                Color             color  = Color.white;
                foreach (var item in adapter.TeamInfos)
                {
                    if (data.Num == item.Num)
                    {
                        statue = item.Statue;
                        color  = item.Color;
                        break;
                    }
                }

                if (statue == MiniMapPlayStatue.DEAD) //死亡
                {
                    markPool.DespawnGo(tran);
                }
                else
                {
                    var img = tran.GetComponent <Image>();
//                    var temperSprite = SpriteComon.GetInstance().GetSpriteByName("fix_00");
//                    if (temperSprite != null && temperSprite != img.sprite)
//                        img.sprite = temperSprite;
                    img.color = color;

                    var pos = data.Pos * rate;
                    tran.GetComponent <RectTransform>().anchoredPosition = refePosByPixel + pos;                  //更新标记位置
                }
            }
            else
            {
                markPool.DespawnGo(tran);
            }
        }
コード例 #2
0
        private void RefreshDisappearHurtedItem(HurtedTweenData record)
        {
            if (record.Tween == null)
            {
                //新建一个tween
                record.Tween = UIUtils.CallTween(1, 0, (value) =>
                {
                    var image = record.Tran.GetComponent <Image>();
                    if (image)
                    {
                        image.color = new Color(image.color.r, image.color.g, image.color.b, value);
                    }
                    //根据摄像机朝向 设置当前角度
                    var selfPlayer = adapter.GetPlayerEntity();
                    //摄像机朝向
                    var forword   = selfPlayer.cameraObj.MainCamera.transform.forward;
                    var forwordxz = new Vector2(forword.x, forword.z);
                    // Debug.Log("camera:" + forwordxz.ToString());

                    //我的朝向
                    var myPos = selfPlayer.position.Value;
                    //攻击源方向
                    var damageSrcPos = new Vector3(record.Data.DamageSrcPos.x, 0, record.Data.DamageSrcPos.y);
                    var dir          = damageSrcPos - myPos;
                    var dirxz        = new Vector2(dir.x, dir.z);
                    // Debug.Log("source:" + dirxz.ToString());

                    var cross = dirxz.x * forwordxz.y - dirxz.y * forwordxz.x;
                    var angle = Vector2.Angle(dirxz, forwordxz) * -Mathf.Sign(cross);
                    // Debug.Log("angle:" + angle.ToString());

                    var hurtedData      = record.Data;
                    var go              = record.Tran;
                    var temRate         = (hurtedData.HurtedNum / 100);
                    temRate             = Mathf.Clamp01(temRate);
                    image.fillAmount    = temRate * hurtedUnitWidth;
                    var adjustedAngel   = image.fillAmount * 360;
                    go.localEulerAngles = new Vector3(0, 0, angle + adjustedAngel / 2);
                    // Debug.Log("tt:" + go.localEulerAngles.z);
                },
                                                 (value) =>
                {
                    pool.DespawnGo(record.Tran);
                    record.Tran  = null;
                    record.Tween = null;
                    record.Data  = null;
                    hurtedRecord.Remove(record.Num);
                },
                                                 hurtedTweenDuring);
            }
        }