Exemple #1
0
        public void Initialize(UIBattleTipInfo info, int sortingOrder)
        {
            SortingOrder    = sortingOrder;
            UIBattleTipInfo = info;
            disappearTick   = 0;

            transform.localScale = Vector3.one * info.Scale * CameraManager.Instance.MainCameraFollow.GetScaleForBattleUI();

            if (info.RandomRange.magnitude > 0)
            {
                offsetPos.x += Random.Range(-UIBattleTipInfo.RandomRange.x, UIBattleTipInfo.RandomRange.x);
                offsetPos.y += Random.Range(-UIBattleTipInfo.RandomRange.y, UIBattleTipInfo.RandomRange.y);
            }

            transform.localPosition = UIBattleTipInfo.StartPos;
            Vector3 diff         = transform.position - CameraManager.Instance.MainCamera.transform.position;
            Ray     ray          = CameraManager.Instance.MainCamera.ScreenPointToRay(new Vector2(Screen.width / 2f, Screen.height / 2f));
            float   distance     = Vector3.Dot(ray.direction, diff);
            Vector3 cameraCenter = CameraManager.Instance.MainCamera.transform.position + ray.direction * distance;
            Vector3 offset       = transform.position - cameraCenter;

            transform.rotation = Quaternion.LookRotation(transform.position - (CameraManager.Instance.MainCamera.transform.position + offset));

            SetTextType(TextType);
            SetTextContext(TextContent, info.DiffHP);
            SetElementTextContext(TextElementContent, info.ElementHP);

            Animator.SetTrigger("Play");
            float duration_ori = CommonUtils.GetClipLength(Animator, "AttackNumberTip");

            Animator.speed = Animator.speed * duration_ori / info.DisappearTime;
        }
Exemple #2
0
        private void ResetTip()
        {
            Animator.speed  = 1;
            UIBattleTipInfo = null;
            disappearTick   = 0;
            if (TextType)
            {
                TextType.transform.localPosition = default_TextTypeLocalPos;
                TextType.color = new Color(0, 0, 0, 0);
            }

            if (TextContent)
            {
                TextContent.transform.localPosition = default_TextContextLocalPos;
                TextContent.color = new Color(0, 0, 0, 0);
            }

            if (TextElementContent)
            {
                TextElementContent.transform.localPosition = default_TextElementContextLocalPos;
                TextElementContent.color = new Color(0, 0, 0, 0);
            }

            if (Icon)
            {
                Icon.transform.localPosition = default_IconLocalPos;
                Icon.color = new Color(0, 0, 0, 0);
            }
        }
        private void HandleCommonTip(uint mcGUID, BattleTipType battleTipType)
        {
            if (!EnableUIBattleTip)
            {
                return;
            }
            if ((int)battleTipType >= (int)BattleTipType.FollowDummySeparate)
            {
                return;
            }

            AttackerType attackerType = AttackerType.None;

            MechaComponent mc_owner = ClientBattleManager.Instance.FindMechaComponent(mcGUID);

            if (ClientBattleManager.Instance.PlayerMecha != null && mc_owner != null)
            {
                attackerType = GetAttackerType(mc_owner.Mecha.MechaInfo, ClientBattleManager.Instance.PlayerMecha.MechaInfo, battleTipType);
            }

            if (attackerType == AttackerType.NoTip)
            {
                return;
            }

            UIBattleTipInfo info = new UIBattleTipInfo(
                0,
                battleTipType,
                attackerType,
                0,
                0,
                0.13f,
                0,
                "",
                mc_owner.transform.position + Vector3.up * 1f,
                Vector2.zero,
                Vector2.one,
                0.5f);

            CreateTip(info);
        }
        private void HandleAttackTip(AttackData attackData)
        {
            if (!EnableUIBattleTip)
            {
                return;
            }
            UIBattleTipInfo info = new UIBattleTipInfo(
                0,
                attackData.BattleTipType,
                GetAttackerType(attackData.AttackerMCI.MechaInfo, attackData.HitterMCB.Mecha.MechaInfo, attackData.BattleTipType),
                attackData.DecHp,
                attackData.ElementHP,
                0.13f,
                attackData.ElementType,
                "",
                attackData.HitterMCB.transform.position + Vector3.up * 1f,
                Vector2.zero,
                Vector2.one,
                0.5f);

            CreateTip(info);
        }
        private void CreateTip(UIBattleTipInfo info)
        {
            int maxSortingOrder = 0;

            foreach (UIBattleTip uiBattleTip in UIBattleTipList)
            {
                if (uiBattleTip.SortingOrder > maxSortingOrder)
                {
                    maxSortingOrder = uiBattleTip.SortingOrder;
                }
            }

            BattleTipPrefabType btType = BattleTipPrefabType.SelfAttack;

            if (info.AttackerType == AttackerType.LocalPlayer)
            {
                if (info.BattleTipType == BattleTipType.CriticalAttack)
                {
                    btType = BattleTipPrefabType.SelfCriticalAttack;
                }
                else if (info.BattleTipType == BattleTipType.Attack)
                {
                    btType = BattleTipPrefabType.SelfAttack;
                }
            }
            else if (info.AttackerType == AttackerType.LocalPlayerSelfDamage)
            {
                if (info.BattleTipType == BattleTipType.Attack)
                {
                    btType = BattleTipPrefabType.SelfDamage;
                }
            }

            UIBattleTip tip = GameObjectPoolManager.Instance.BattleUIDict[btType].AllocateGameObject <UIBattleTip>(UIManager.Instance.UI3DRoot);

            tip.Initialize(info, maxSortingOrder + 1);
            UIBattleTipList.Add(tip);
        }