private void RefreshPowerGroup() { if (adapter != null) { if (powerConfigList.Count < 5) { return; } float curPower = adapter.CurPower; if (curPower <= 0) //能量值小于0时候 隐藏能量条 { _viewModel.PowerGroupActive = false; } else { _viewModel.PowerGroupActive = true; if (curPower != lastPower) { if (powerTween != null) { powerTween.Kill(); powerTween = null; } powerTween = UIUtils.CallTween(curtTweenPower, curPower, (value) => { UpdateFunc(value); }, (value) => { CompleteFunc(value); }, 1f); lastPower = curPower; } } } }
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); } }
//OnUiRender public void RefreshGui() { if (isGameObjectCreated) { var info = adapter.RangeInfo; if (info != null) { if (InView(info.contactPos)) { _viewModel.rootActiveSelf = true; //刷新距离 var distance = info.distance > 999 ? 999 : info.distance; _viewModel.titleText = distance + I2.Loc.ScriptLocalization.client_common.word17; contactPos = info.contactPos; if (disappearTween != null) { disappearTween.Kill(); } //开始倒计时 disappearTween = UIUtils.CallTween(1, 0, null, (value) => { disappearTween = null; _viewModel.rootActiveSelf = false; }, disappearTime); } else { Debug.Log("out in view"); } adapter.RangeInfo = null; } } }
private void UpdatePlayStatue(ref Vector2 referPos, MiniMapTeamPlayInfo data, MapLevel mapLevel) { var shiftVec = data.Pos.ShiftedUIVector2(); if (referPos.Equals(_referPos) && data.Statue.Equals(_miniMapPlayStatue) && shiftVec.Equals(_infoPos) && data.ShootingCount.Equals(_shootingCount)) { return; } _referPos = referPos; _miniMapPlayStatue = data.Statue; _infoPos = shiftVec; _shootingCount = data.ShootingCount; switch (data.Statue) { case MiniMapPlayStatue.NORMAL: //常态 { UIUtils.SetActive(number, !MapLevel.Min.Equals(mapLevel)); UIUtils.SetActive(stateIcon, false); if (data.IsPlayer) { UIUtils.SetActive(loftIcon, false); } else { // UIUtils.SetActive(loftIcon, true); // var temperSprite = SpriteComon.GetInstance().GetSpriteByName("Loft_icon"); // if (temperSprite != null && loftIconImage.sprite != temperSprite) // { // loftIconImage.sprite = temperSprite; // } // // if (data.Pos.y > referPos.y) //上方 // { // if (loftIcon.transform.localScale != Vector3.one) // loftIcon.transform.localScale = Vector3.one; // } // else if (data.Pos.y <= referPos.y) //下方 // { // if (loftIcon.transform.localScale != new UnityEngine.Vector3(1, -1, 1)) // loftIcon.transform.localScale = new UnityEngine.Vector3(1, -1, 1); // } } if (data.ShootingCount > 0) //在射击状态下 { if (!tranCTween.ContainsKey(tran) || tranCTween[tran] == null) { var temperTween = UIUtils.CallTween(1, 1.5f, (value) => { bgRectTf.localScale = new UnityEngine.Vector3((float)value, (float)value, 1.0f); }, (value) => { bgRectTf.localScale = Vector3.one; data.ShootingCount--; tranCTween[tran].Kill(); tranCTween[tran] = null; }, 0.1f); if (!tranCTween.ContainsKey(tran)) { tranCTween.Add(tran, temperTween); } else { tranCTween[tran] = temperTween; } } } else { if (tranCTween.ContainsKey(tran) && tranCTween[tran] != null) { tranCTween[tran].Kill(); tranCTween[tran] = null; } if (bgRectTf.localScale != Vector3.one) { bgRectTf.localScale = Vector3.one; } } } break; case MiniMapPlayStatue.TIAOSAN: //跳伞 { UIUtils.SetActive(number, false); UIUtils.SetActive(loftIcon, false); UIUtils.SetActive(stateIcon, true); var temperSprite = SpriteComon.GetInstance().GetSpriteByName("icon_parachute"); if (temperSprite != null && stateIconImage.sprite != temperSprite) { stateIconImage.sprite = temperSprite; } } break; case MiniMapPlayStatue.ZAIJU: //载具 { UIUtils.SetActive(number, false); UIUtils.SetActive(loftIcon, false); UIUtils.SetActive(stateIcon, true); var temperSprite = SpriteComon.GetInstance().GetSpriteByName("icon_drive"); if (temperSprite != null && stateIconImage.sprite != temperSprite) { stateIconImage.sprite = temperSprite; } } break; case MiniMapPlayStatue.HURTED: //受伤 { UIUtils.SetActive(number, false); UIUtils.SetActive(loftIcon, false); UIUtils.SetActive(stateIcon, true); var temperSprite = SpriteComon.GetInstance().GetSpriteByName("icon_hurt"); if (temperSprite != null && stateIconImage.sprite != temperSprite) { stateIconImage.sprite = temperSprite; } } break; case MiniMapPlayStatue.DEAD: //死亡 { UIUtils.SetActive(number, false); UIUtils.SetActive(loftIcon, false); UIUtils.SetActive(stateIcon, true); var temperSprite = SpriteComon.GetInstance().GetSpriteByName("icon_die"); if (temperSprite != null && stateIconImage.sprite != temperSprite) { stateIconImage.sprite = temperSprite; } } break; default: { UIUtils.SetActive(number, false); UIUtils.SetActive(loftIcon, false); UIUtils.SetActive(stateIcon, false); } break; } }
private void RefreshAttack() { var number = adapter.AttackNum; if (number > 0) { if (disAppearRedTween != null) { disAppearRedTween.Kill(); disAppearRedTween = null; _viewModel.ImageRedColor = Color.white; } if (disAppearWhiteTween != null) { disAppearWhiteTween.Kill(); disAppearWhiteTween = null; _viewModel.ImageWhiteColor = Color.white; } float imgSize = 0; if (number >= 75) { imgSize = 100; } else if (number >= 50 && number < 75) { imgSize = 50 * 1.7f; } else if (number >= 25 && number < 50) { imgSize = 50 * 1.4f; } else if (number >= 0 && number < 25) { imgSize = 50; } if (adapter.IsBurstHeart) //爆头 { _viewModel.ImageWhiteActive = false; _viewModel.ImageRedActive = true; //更新大小 if (lastAttackNum != number) { _viewModel.ImageRedSize = new Vector2(imgSize, imgSize); } } else { _viewModel.ImageWhiteActive = true; _viewModel.ImageRedActive = false; //更新大小 if (lastAttackNum != number) { _viewModel.ImageWhiteSize = new Vector2(imgSize, imgSize); } } lastAttackNum = number; } else { _viewModel.ImageWhiteActive = false; _viewModel.ImageRedActive = false; //淡出 if (_viewModel.ImageRedActive && disAppearRedTween == null) { _viewModel.ImageRedColor = Color.white; disAppearRedTween = UIUtils.CallTween(1, 0, (value) => { _viewModel.ImageRedColor = new Color(_viewModel.ImageRedColor.r, _viewModel.ImageRedColor.g, _viewModel.ImageRedColor.b, value); }, (value) => { disAppearRedTween = null; _viewModel.ImageRedColor = Color.white; _viewModel.ImageRedActive = false; }, disAppearTweenTime); } else if (_viewModel.ImageWhiteActive && disAppearWhiteTween == null) { _viewModel.ImageWhiteColor = Color.white; disAppearWhiteTween = UIUtils.CallTween(1, 0, (value) => { _viewModel.ImageWhiteColor = new Color(_viewModel.ImageWhiteColor.r, _viewModel.ImageWhiteColor.g, _viewModel.ImageWhiteColor.b, value); }, (value) => { disAppearWhiteTween = null; _viewModel.ImageWhiteColor = Color.white; _viewModel.ImageWhiteActive = false; }, disAppearTweenTime); } } }
private void RefreshCrossHair(float interval) { SelectTypePanel(adapter.Type); switch (adapter.Type) { case CrossHairType.Normal: { SetNormalCrossType(adapter.WeaponAvatarId); //根据weapon不同过得subtype 设置不同的准心图片 float startPos = Mathf.Abs(sTopRt.localPosition.y); float endPos = Mathf.Abs(YEndPosOffset); #if UNITY_EDITOR if (GlobalConst.EnableWeaponLog) { DebugUtil.MyLog("SpreadUI EndPos:" + endPos + "||" + "currPos:" + startPos); } #endif if (Mathf.Abs(YHistoryEndPosOffset - endPos) > 0.1f || YMoveTween == null) { YHistoryEndPosOffset = endPos; YMoveTween = UIUtils.CallTween(startPos, endPos, UpdateYLinesPos, (value) => { YMoveTween = null; }, adapter.SpreadDuration); //Mathf.Abs(startPos - endPos)/speed); } startPos = Mathf.Abs(hRight.localPosition.x); endPos = Mathf.Abs(XEndPosOffset); if (Mathf.Abs(XHistoryEndPosOffset - endPos) > 0.1f || XMoveTween == null) { XHistoryEndPosOffset = endPos; XMoveTween = UIUtils.CallTween(startPos, endPos, UpdateXLinesPos, (value) => { XMoveTween = null; }, adapter.SpreadDuration); //Mathf.Abs(startPos - endPos)/speed); } // CleanTween(adapter.Statue); // switch (adapter.Statue) // { // case CrossHairNormalTypeStatue.Move: // { // if (moveTween == null) //想外移动 0.5秒内到达 endPos // { // float startPos = sTopRt.localPosition.y; // float endPos = normalTypeEndPos; // moveTween = UIUtils.CallTween(startPos, endPos, UpdateNormalLinePos, (value) => { moveTween = null; }, 0.5f); // } // } // break; // case CrossHairNormalTypeStatue.Shot: //每颗子弹会使准星向外移动1像素,最大移动至自身长度*3的距离(10像素的线段会移动20像素)。 // { // if (lastShootNum != adapter.ShootNum) // { // float startPos = sTopRt.localPosition.y; // float temperPos = startPos + (adapter.ShootNum - lastShootNum) * 1; // UpdateNormalLinePos(temperPos); // lastShootNum = adapter.ShootNum; // } // } // break; // case CrossHairNormalTypeStatue.StopShot: //0.3秒内,十字的每一条线段,会向内移动(准星中心点方向)移动到默认位置 // { // if (shootTween == null) // { // float startPos = sTopRt.localPosition.y; // float endPos = ConstStartPosOffset; // shootTween = UIUtils.CallTween(startPos, endPos, UpdateNormalLinePos, (value) => { shootTween = null; }, 0.3f); // } // } // break; // } } break; case CrossHairType.AddBlood: { } break; case CrossHairType.Novisible: { } break; } _lastType = adapter.Type; }
public void UpdatePlayNumAndColor(Transform tran, ref Vector2 referPos, MiniMapTeamPlayInfo data, bool isMimiMap) { var numberBg = tran.Find("bg"); if (numberBg) { //刷新编号 var number = numberBg.Find("number"); if (number) { if (MapLevel.Min.Equals(adapter.MapLevel)) { number.gameObject.SetActive(false); } else { number.gameObject.SetActive(true); var numberText = number.GetComponent <Text>(); if (numberText) { if (data.IsPlayer) { if (isNoTeamPlayer) { numberText.text = ""; } else { numberText.text = data.Num.ToString(); } } else { numberText.text = data.Num.ToString(); } } } } var numberBgCom = numberBg.GetComponent <Image>(); var stateIcon = numberBg.Find("icon"); var loftIcon = numberBg.Find("loftIcon"); if (numberBgCom == null || stateIcon == null || loftIcon == null) { return; } var stateIconCom = stateIcon.GetComponent <Image>(); var loftIconCom = loftIcon.GetComponent <Image>(); //刷新编号背景图 // var temperBgSprite = SpriteComon.GetInstance().GetSpriteByName("mark"); // if (numberBgCom.sprite != temperBgSprite) // { // numberBgCom.sprite = temperBgSprite; // } numberBgCom.color = data.Color; switch (data.Statue) { case MiniMapPlayStatue.NORMAL: //常态 { UIUtils.SetActive(number, true); UIUtils.SetActive(stateIcon, false); if (data.IsPlayer) { UIUtils.SetActive(loftIcon, false); } else { UIUtils.SetActive(loftIcon, true); var temperSprite = SpriteComon.GetInstance().GetSpriteByName("Loft_icon"); if (temperSprite != null && loftIconCom.sprite != temperSprite) { loftIconCom.sprite = temperSprite; } var wpos = data.Pos.ShiftedUIVector2(); if (wpos.y > referPos.y) //上方 { if (loftIcon.transform.localScale != Vector3.one) { loftIcon.transform.localScale = Vector3.one; } } else if (wpos.y <= referPos.y) //下方 { if (loftIcon.transform.localScale != new UnityEngine.Vector3(1, -1, 1)) { loftIcon.transform.localScale = new UnityEngine.Vector3(1, -1, 1); } } } if (data.ShootingCount > 0) //在射击状态下 { if (!tranCTween.ContainsKey(tran) || tranCTween[tran] == null) { var temperTween = UIUtils.CallTween(1, 1.5f, (value) => { numberBg.GetComponent <RectTransform>().localScale = new UnityEngine.Vector3((float)value, (float)value, 1.0f); }, (value) => { numberBg.GetComponent <RectTransform>().localScale = Vector3.one; data.ShootingCount--; tranCTween[tran].Kill(); tranCTween[tran] = null; }, 0.1f); if (!tranCTween.ContainsKey(tran)) { tranCTween.Add(tran, temperTween); } else { tranCTween[tran] = temperTween; } } } else { if (tranCTween.ContainsKey(tran) && tranCTween[tran] != null) { tranCTween[tran].Kill(); tranCTween[tran] = null; } if (numberBg.GetComponent <RectTransform>().localScale != Vector3.one) { numberBg.GetComponent <RectTransform>().localScale = Vector3.one; } } } break; case MiniMapPlayStatue.TIAOSAN: //跳伞 { UIUtils.SetActive(number, false); UIUtils.SetActive(loftIcon, false); UIUtils.SetActive(stateIcon, true); var temperSprite = SpriteComon.GetInstance().GetSpriteByName("icon_parachute"); if (temperSprite != null && stateIconCom.sprite != temperSprite) { stateIconCom.sprite = temperSprite; } } break; case MiniMapPlayStatue.ZAIJU: //载具 { UIUtils.SetActive(number, false); UIUtils.SetActive(loftIcon, false); UIUtils.SetActive(stateIcon, true); var temperSprite = SpriteComon.GetInstance().GetSpriteByName("icon_drive"); if (temperSprite != null && stateIconCom.sprite != temperSprite) { stateIconCom.sprite = temperSprite; } } break; case MiniMapPlayStatue.HURTED: //受伤 { UIUtils.SetActive(number, false); UIUtils.SetActive(loftIcon, false); UIUtils.SetActive(stateIcon, true); var temperSprite = SpriteComon.GetInstance().GetSpriteByName("icon_hurt"); if (temperSprite != null && stateIconCom.sprite != temperSprite) { stateIconCom.sprite = temperSprite; } } break; case MiniMapPlayStatue.DEAD: //死亡 { UIUtils.SetActive(number, false); UIUtils.SetActive(loftIcon, false); UIUtils.SetActive(stateIcon, true); var temperSprite = SpriteComon.GetInstance().GetSpriteByName("icon_die"); if (temperSprite != null && stateIconCom.sprite != temperSprite) { stateIconCom.sprite = temperSprite; } } break; default: { UIUtils.SetActive(number, false); UIUtils.SetActive(loftIcon, false); UIUtils.SetActive(stateIcon, false); } break; } } }
private void RefreshCrossHair(float interval) { adapter.UpdateSpread(); SelectTypePanel(adapter.Type); switch (adapter.Type) { case CrossHairType.Normal: { // SpreadRootTrans.localPosition = new Vector3(adapter.XSpreadOffset*GMVariable.SpreadOffsetFactor,adapter.YSpreadOffset*GMVariable.SpreadOffsetFactor,0); SetNormalCrossType(adapter.WeaponAvatarId); //根据weapon不同过得subtype 设置不同的准心图片 float startPos = Mathf.Abs(sTopRt.localPosition.y); float endPos = Mathf.Abs(YEndPosOffset); float spreadDuration = 1f; // DebugUtil.MyLog("SpreadUI spreadDuration:"+spreadDuration+" startPos:"+ startPos+" | EndPos:" + endPos+"|"+"currPos:"+sTopRt.localPosition.x); if (Mathf.Abs(YHistoryEndPosOffset - endPos) > 0.1f) { if (YMoveTween != null) { YMoveTween.Kill(); } YHistoryEndPosOffset = endPos; spreadDuration = adapter.SpreadDuration; YMoveTween = UIUtils.CallTween(startPos, endPos, UpdateYLinesPos, (value) => { YMoveTween.Kill(); YMoveTween = null; }, spreadDuration); //Mathf.Abs(startPos - endPos)/speed); } endPos = Mathf.Abs(XEndPosOffset); if (Mathf.Abs(XHistoryEndPosOffset - endPos) > 0.1f) { if (XMoveTween != null) { XMoveTween.Kill(); } startPos = Mathf.Abs(hLeftRt.localPosition.x); XHistoryEndPosOffset = endPos; XMoveTween = UIUtils.CallTween(startPos, endPos, UpdateXLinesPos, (value) => { XMoveTween.Kill(); XMoveTween = null; }, spreadDuration); //Mathf.Abs(startPos - endPos)/speed); } // CleanTween(adapter.Statue); // switch (adapter.Statue) // { // case CrossHairNormalTypeStatue.Move: // { // if (moveTween == null) //想外移动 0.5秒内到达 endPos // { // float startPos = sTopRt.localPosition.y; // float endPos = normalTypeEndPos; // moveTween = UIUtils.CallTween(startPos, endPos, UpdateNormalLinePos, (value) => { moveTween = null; }, 0.5f); // } // } // break; // case CrossHairNormalTypeStatue.Shot: //每颗子弹会使准星向外移动1像素,最大移动至自身长度*3的距离(10像素的线段会移动20像素)。 // { // if (lastShootNum != adapter.ShootNum) // { // float startPos = sTopRt.localPosition.y; // float temperPos = startPos + (adapter.ShootNum - lastShootNum) * 1; // UpdateNormalLinePos(temperPos); // lastShootNum = adapter.ShootNum; // } // } // break; // case CrossHairNormalTypeStatue.StopShot: //0.3秒内,十字的每一条线段,会向内移动(准星中心点方向)移动到默认位置 // { // if (shootTween == null) // { // float startPos = sTopRt.localPosition.y; // float endPos = ConstStartPosOffset; // shootTween = UIUtils.CallTween(startPos, endPos, UpdateNormalLinePos, (value) => { shootTween = null; }, 0.3f); // } // } // break; // } } break; case CrossHairType.AddBlood: { } break; case CrossHairType.Novisible: { } break; } _lastType = adapter.Type; }
private void RefreshEquipGroup() { if (adapter != null) { var isDead = adapter.IsDead; var curHValue = adapter.maxHelmet - adapter.curHelmet; var maxHValue = adapter.maxHelmet; if (adapter.maxHelmet > 0 && adapter.curHelmet > 0 && !isDead) { _viewModel.HelmetActive = true; if (adapter.maxHelmet == adapter.curHelmet) { _viewModel.HelmetFillAmount = 0; } if (lastHelmet != curHValue) { if (helmetTween != null) { helmetTween.Kill(); helmetTween = null; } helmetTween = UIUtils.CallTween(lastHelmet, curHValue, (value) => { _viewModel.HelmetFillAmount = (value / maxHValue); }, (value) => { helmetTween.Kill(); helmetTween = null; }, 0.5f); lastHelmet = curHValue; } } else { _viewModel.HelmetActive = false; } var curBValue = adapter.maxArmor - adapter.curArmor; var maxBValue = adapter.maxArmor; if (adapter.maxArmor > 0 && adapter.curArmor > 0 && !isDead) { _viewModel.BulletproofActive = true; if (adapter.maxArmor == adapter.curArmor) { _viewModel.BulletproofFillAmount = 0; } if (lastBulletproof != curBValue) { if (bulletproofTween != null) { bulletproofTween.Kill(); bulletproofTween = null; } bulletproofTween = UIUtils.CallTween(lastBulletproof, curBValue, (value) => { _viewModel.BulletproofFillAmount = (value / maxBValue); }, (value) => { bulletproofTween.Kill(); bulletproofTween = null; }, 0.5f); lastBulletproof = curBValue; } } else { _viewModel.BulletproofActive = false; } } }