Example #1
0
            public void ShowDamageEffect(FightEffectHelp.FightEffectType type, long value, float displayTimeScale, Actor actor, bool show_percent, string push_str)
            {
                if (GlobalConst.IsBanshuVersion)
                {
                    if (type == FightEffectHelp.FightEffectType.AddExp)
                    {
                        return;
                    }
                }
                var fightEffectWindow = GetFightEffectWindow();

                if (fightEffectWindow == null)
                {
                    return;
                }
                GameObject damageEffectObject = null;

                damageEffectObject = fightEffectWindow.GetObjectByFightEffectType(type);
                if (damageEffectObject == null)
                {
                    return;
                }
                int level = FightEffectHelp.GetLayoutLevel(type);

                fightEffectWindow.SetGameObjectLayoutLevel(damageEffectObject, level);

                Vector3 worldPosInScene;
                Vector2 screen_abs_offset;
                Vector3 worldPos = xc.ui.ugui.UIFightEffectWindow.GetEffectWorldPosInUIByType(actor, type, out worldPosInScene, out screen_abs_offset);

                damageEffectObject.transform.position      = worldPos;
                damageEffectObject.transform.localPosition = new Vector3(damageEffectObject.transform.localPosition.x,
                                                                         damageEffectObject.transform.localPosition.y, 0);

                Text effectValueLabel = damageEffectObject.transform.Find("Value").GetComponent <Text>();

                if (type == FightEffectHelp.FightEffectType.OurDamage && value > 0)
                {
                    value = -value;
                }

                FightEffectHelp.SetEffectValue(type, effectValueLabel, value, show_percent, push_str);

                float     playTimeBySeconds = 2;
                Animation animation         = damageEffectObject.GetComponentInChildren <Animation>();

                if (animation != null && animation.clip != null)
                {
                    playTimeBySeconds = animation.clip.length;
                    animation[animation.clip.name].speed = displayTimeScale;
                }
                damageEffectObject.SetActive(true);

                var delay_enable = damageEffectObject.GetComponent <DelayEnableComponent>();

                delay_enable.DelayTime = playTimeBySeconds;
                delay_enable.SetEnable = false;
                delay_enable.Start();
            }
Example #2
0
            /// <summary>
            /// 显示伤害数字
            /// </summary>
            public void ShowDamageValue(/*Vector3 headPos, */ int damageValue, float displayTimeScale, EUnitType unitType, bool isLocalPlayer, Actor actor, Vector3 attacker_world_pos, FightEffectHelp.FightEffectType type)
            {
                if (damageValue <= 0)
                {
                    return;
                }

                var fightEffectWindow = GetFightEffectWindow();

                if (fightEffectWindow == null)
                {
                    return;
                }
                GameObject damageEffectObject = null;

                damageEffectObject = fightEffectWindow.GetObjectByFightEffectType(type);
                if (damageEffectObject == null)
                {
                    return;
                }

                //damageEffectObject.transform.localScale = Vector3.one * m_normal_damage_num_scale;

                int level = FightEffectHelp.GetLayoutLevel(type);

                fightEffectWindow.SetGameObjectLayoutLevel(damageEffectObject, level);

                Vector3 worldPosInScene;
                Vector2 screen_abs_offset;
                Vector3 worldPos = xc.ui.ugui.UIFightEffectWindow.GetEffectWorldPosInUIByType(actor, type, out worldPosInScene, out screen_abs_offset);

                damageEffectObject.transform.position      = worldPos;
                damageEffectObject.transform.localPosition = new Vector3(damageEffectObject.transform.localPosition.x,
                                                                         damageEffectObject.transform.localPosition.y, 0);

                if (type == FightEffectHelp.FightEffectType.OneHitKill)
                {
                }
                else
                {
                    Text effectValueLabel = damageEffectObject.transform.Find("Value").GetComponent <Text>();


                    if (effectValueLabel != null)
                    {
                        if (isLocalPlayer)
                        {
                            effectValueLabel.text = (-damageValue).ToString();
                        }
                        else if (type == FightEffectHelp.FightEffectType.OurDamage && damageValue > 0)
                        {
                            effectValueLabel.text = (-damageValue).ToString();
                        }
                        else
                        {
                            effectValueLabel.text = damageValue.ToString();
                        }
                    }
                }
                damageEffectObject.SetActive(true);

                float     playTimeBySeconds = 2;
                Animation animation         = damageEffectObject.GetComponentInChildren <Animation>();

                if (animation != null && animation.clip != null)
                {
                    playTimeBySeconds = animation.clip.length;
                    animation[animation.clip.name].speed = displayTimeScale;
                }

                var delay_enable = damageEffectObject.GetComponent <DelayEnableComponent>();

                delay_enable.DelayTime = 2 * displayTimeScale;
                delay_enable.SetEnable = false;
                delay_enable.Start();

                if (TryShowDamageWordAnim(type))
                {
                    UIFightDamageWordAnimComponent anim_component = damageEffectObject.GetComponent <UIFightDamageWordAnimComponent>();
                    if (anim_component == null)
                    {
                        anim_component = damageEffectObject.AddComponent <UIFightDamageWordAnimComponent>();
                    }
                    anim_component.Show(displayTimeScale, worldPosInScene, attacker_world_pos, actor.transform.position, type, screen_abs_offset);
                }
            }