void Update() { #if UNITY_EDITOR if (Input.GetKey(KeyCode.F10)) { Buff_obj.SetActive(true); ZEventSystem.Dispatch(EventConst.OnGamePause, true); Time.timeScale = true ? 0 : 1; GetData(0, false); } if (Input.GetKey(KeyCode.F11)) { Buff_obj.SetActive(false); ZEventSystem.Dispatch(EventConst.OnGamePause, false); Time.timeScale = false ? 0 : 1; fighter = null; } #endif float deltaLerp = Time.deltaTime * FIGHTMASKSPEED; deltaLerp *= (MaskState == FightMaskState.None ? 0 : (MaskState == FightMaskState.Forward ? 1 : -1)); _fightMaskLerp += deltaLerp; if (_fightMaskLerp < 0 || _fightMaskLerp > 1) { _fightMaskLerp = Mathf.Clamp01(_fightMaskLerp); MaskState = FightMaskState.None; ZEventSystem.Dispatch(EventConst.OnFightMaskOver); } this.FightMask_img.color = new Color(0, 0, 0, _fightMaskLerp); int timeleft = (int)(FightLogic.Instance.RoundTime - FightLogic.Instance.AccRoundTime); if (_timeleft != timeleft) { this.time_txt.text = string.Format("{0}:{1:D2}", timeleft / 60, timeleft % 60); _timeleft = timeleft; } for (int idx = _treasureEffect.Count - 1; idx >= 0; --idx) { TreasureEffectObj obj = _treasureEffect[idx]; float deltaDis = Time.deltaTime * TreasureEffectSpeed; Vector3 dir = obj.EndPos - obj.TreasureEffect.transform.position; if (dir.sqrMagnitude <= Mathf.Pow(deltaDis, 2)) { GameObject.Destroy(obj.TreasureEffect); _treasureEffect.RemoveAt(idx); ZEventSystem.Dispatch(EventConst.OnTreasureFlyOver); } else { obj.TreasureEffect.transform.position += dir.normalized * deltaDis; } } }
public void CreateTreasureEffect(Vector3 worldPos) { Vector3 followPoint = FightUnitInfoView.OUT_SCREEN; { Vector2 targetScreenPosition = Camera.main.WorldToScreenPoint(worldPos); if (!RectTransformUtility.ScreenPointToWorldPointInRectangle(this.Treasure_rect, targetScreenPosition, CanvasView.Instance.uicamera, out followPoint)) { Debug.LogErrorFormat("计算位置失败:{0}", worldPos); } } TreasureEffectObj obj = new TreasureEffectObj(); obj.TreasureEffect = GameObject.Instantiate(TreasureEffect); obj.TreasureEffect.transform.SetParent(this.Treasure_rect.transform, false); obj.TreasureEffect.transform.position = followPoint; obj.StartPos = followPoint; obj.EndPos = this.treasureicon_rect.transform.position; _treasureEffect.Add(obj); }