コード例 #1
0
    /// <summary>
    /// 显示伤害信息板
    /// </summary>
    /// <param name="nType">伤害信息板类型 对应DamageBoardType表ID</param>
    /// <param name="nValue">显示的内容</param>
    public void ShowDamageBoard(int nType, string strValue, Vector3 pos, bool isProfessionSkill = true)
    {
        if (mCurType == DAMAGE_BOARD_TYPE.GPUBILLBOARD)
        {
            Debug.LogWarning(strValue);
            if (!PlayerPreferenceData.SystemDamageBoardEnable)
            {
                return;
            }
            if (!mIsInit)
            {
                mIsInit = true;
                GPUBillboardBuffer.Instance.Init();
                GPUBillboardBuffer.Instance.SetupBillboard(1000);
                Tab_DamageBoardType template = TableManager.GetDamageBoardTypeByID(7, 0);
                GPUBillboardBuffer.Instance.SetPosOffset(new Vector3(template.OriginX, template.OriginY));
                GPUBillboardBuffer.Instance.SetScaleParams(template.ScaleDelayTime, template.ScalePlusTime, template.ScaleMinusTime, template.TextSizeMax, template.TextSizeOver);
            }
            Tab_DamageBoardType tabDamageBoardType = TableManager.GetDamageBoardTypeByID(nType, 0);
            uint color = System.Convert.ToUInt32(tabDamageBoardType.TextColor + "ff", 16);

            DisplayNumerInputParam param = new DisplayNumerInputParam();
            param.RandomXInitialSpeedMin = tabDamageBoardType.VelocityX;
            param.RandomXInitialSpeedMax = tabDamageBoardType.VelocityX;

            param.RandomYInitialSpeedMin = tabDamageBoardType.VelocityY;
            param.RandomYInitialSpeedMax = tabDamageBoardType.VelocityY;

            param.RandomXaccelerationMin = tabDamageBoardType.AccelerationX;
            param.RandomXaccelerationMax = tabDamageBoardType.AccelerationX;

            param.RandomYaccelerationMin = tabDamageBoardType.AccelerationY;
            param.RandomYaccelerationMax = tabDamageBoardType.AccelerationY;

            param.FadeTime   = tabDamageBoardType.FadeTime;
            param.NormalTime = tabDamageBoardType.ShowTime;

            GPUBillboardBuffer.Instance.DisplayNumberRandom(
                strValue,
                tabDamageBoardType.TextSize * 0.2f * Vector3.one,
                pos,
                NGUIMath.HexToColor(color),
                tabDamageBoardType.TextSizeMax > 0, param);
        }
        else if (mCurType == DAMAGE_BOARD_TYPE.NGUI)
        {
            if (false == DebugHelper.m_bShowDamageBoard)
            {
                return;
            }

            if (DamageBoardType.ContainsKey(nType) == false)
            {
                return;
            }

            Tab_DamageBoardType tabDamageBoardType = DamageBoardType[nType][0];
            if (tabDamageBoardType == null)
            {
                tabDamageBoardType = DamageBoardType[0][0];
            }

            int nMaxNum = tabDamageBoardType.MaxNum;                    // 最大显示数量

            DamageBoard damageBoardInfo = null;
            if (m_DisabledDictionary[nType].Count > 0)
            {
                // 若DisabledDictionary对应list中有元素 则不创建新的信息板 直接使用旧的
                damageBoardInfo = m_DisabledDictionary[nType][m_DisabledDictionary[nType].Count - 1];
                damageBoardInfo.Reuse(pos);
                m_DisabledDictionary[nType].RemoveAt(m_DisabledDictionary[nType].Count - 1);
                m_EnabledDictionary[nType].Add(damageBoardInfo);
            }
            else
            {
                // 若DisabledDictionary对应list中没有元素
                if (m_EnabledDictionary[nType].Count < nMaxNum)
                {
                    // 若EnabledDictionary对应list数量未达到最大值 则直接创建
                    //damageBoardInfo = new DamageBoard();
                    //damageBoardInfo.Create(m_Font, gameObject.transform.position);
                    //m_EnabledDictionary[nType].Add(damageBoardInfo);
                    DamageBoardLoadInfo info = new DamageBoardLoadInfo(nType, strValue, pos, isProfessionSkill);
                    UIManager.LoadItem(UIInfo.DamageBoard, OnLoadDamageBoard, info);
                }
                else
                {
                    // 若EnabledDictionary对应list数量已达到最大值 则Remove第一个 再Add出来一个
                    damageBoardInfo = m_EnabledDictionary[nType][m_EnabledDictionary[nType].Count - 1];
                    damageBoardInfo.Reuse(pos);
                    m_EnabledDictionary[nType].RemoveAt(m_EnabledDictionary[nType].Count - 1);
                    m_EnabledDictionary[nType].Add(damageBoardInfo);
                }
            }

            if (null != damageBoardInfo)
            {
                damageBoardInfo.ActiveDamageBoard(nType, strValue, pos, isProfessionSkill);
            }
        }
    }
コード例 #2
0
    //在创建或者复用完成后,调用该接口,显示伤害信息
    public bool ActiveDamageBoard(int nType, string strValue, Vector3 pos, bool isPlayerSkill = true)
    {
//		bool isCriticalDamage = nType == (int)(Games.GlobeDefine.GameDefine_Globe.DAMAGEBOARD_TYPE.PLAYER_ATTACK_CRITICAL) ||
//			nType == (int)(Games.GlobeDefine.GameDefine_Globe.DAMAGEBOARD_TYPE.PLAYER_ATTACK_CRITICAL_PARTNER) ||
//				nType == (int)(Games.GlobeDefine.GameDefine_Globe.DAMAGEBOARD_TYPE.TARGET_ATTACK_CRITICAL);


        Tab_DamageBoardType tabDamageBoardType = DamageBoardManager.DamageBoardType[nType][0];

        if (tabDamageBoardType == null)
        {
            tabDamageBoardType = DamageBoardManager.DamageBoardType[0][0];
        }
        m_run = true;
        // 读取该类型的表格项
        // 初始位置 初速度 加速度
        //Vector3 vecOrigin = new Vector3(tabDamageBoardType.OriginX, tabDamageBoardType.OriginY, 0);
        Vector3 vecVelocity     = new Vector3(tabDamageBoardType.VelocityX, tabDamageBoardType.VelocityY, 0);
        Vector3 vecAcceleration = new Vector3(tabDamageBoardType.AccelerationX, tabDamageBoardType.AccelerationY, 0);
        float   fShowTime       = tabDamageBoardType.ShowTime;      // 正常显示时间
        float   fFadeTime       = tabDamageBoardType.FadeTime;      // 渐变消失时间

        m_totalShowTime = fShowTime + fFadeTime;                    // 总运动时间
        string strTextColor = tabDamageBoardType.TextColor;         // 字体颜色
        //string strOutlineColor = tabDamageBoardType.OutlineColor;   // 描边颜色
        float fTextSize       = tabDamageBoardType.TextSize;        // 文字大小
        float fScaleDelayTime = tabDamageBoardType.ScaleDelayTime;  // 尺寸变化延迟时间
        float fTextSizeMax    = tabDamageBoardType.TextSizeMax;     // 最大尺寸
        float fScalePlusTime  = tabDamageBoardType.ScalePlusTime;   // 放大时间
        float fTextSizeOver   = tabDamageBoardType.TextSizeOver;    // 结束尺寸
        float fScaleMinusTime = tabDamageBoardType.ScaleMinusTime;  // 缩小时间

        if (null == m_DamageBoardRootTransform)
        {
            m_DamageBoardRootTransform = gameObject.transform;
        }

        if (null == m_DamageBoardLabel)
        {
            m_DamageBoardLabel = gameObject.GetComponent <UILabel>();
            if (null != m_DamageBoardLabel)
            {
                m_DamageBoardLabel.effectStyle = UILabel.Effect.None;
                m_DamageBoardLabel.color       = Color.white;
            }
        }

        if (null == m_UAMotion)
        {
            m_UAMotion = gameObject.AddComponent <UniformAcceleratedMotion>();
        }

        if (null == m_TweenScalePlus)
        {
            m_TweenScalePlus = gameObject.AddComponent <TweenScale>();
        }

        if (null == m_TweenScaleMinus)
        {
            m_TweenScaleMinus = gameObject.AddComponent <TweenScale>();
        }
        if (m_TweenAlpha == null)
        {
            m_TweenAlpha = gameObject.AddComponent <TweenAlpha>();
        }

        // 使用旧的TweenAlpha需要Reset
        m_TweenAlpha.Reset();
        m_TweenScalePlus.Reset();
        m_TweenScaleMinus.Reset();
        //LogModule.ErrorLog(fFadeTime+"_" + fShowTime);
        if (fFadeTime > 0)
        {
            m_TweenAlpha.from     = 1;
            m_TweenAlpha.to       = 0.001f;
            m_TweenAlpha.delay    = fShowTime;
            m_TweenAlpha.duration = fFadeTime;
            m_TweenAlpha.Play();
        }

        // 设置Label控件
//         string strText = "[" + strTextColor + "]";
//         strText += strValue;
//         m_DamageBoardLabel.text = strText;
        m_DamageBoardLabel.text = StrDictionary.GetClientDictionaryString("#{10003}", strTextColor, strValue);
        if (isPlayerSkill)
        {
            m_DamageBoardLabel.font = m_PlayerSkillDamageFont;
        }
        else
        {
            m_DamageBoardLabel.font = m_OtherSkillDamageFont;
        }
        //damageBoardLabel.effectColor = Utils.GetColorByString(strOutlineColor);

        // 匀变速运动 传入初速度 加速度 运动时间
        m_UAMotion.Init(vecVelocity, vecAcceleration, m_totalShowTime);

        // TweenScale动画
        m_TweenScalePlus.from     = fTextSize * Vector3.one;
        m_TweenScalePlus.to       = fTextSizeMax * Vector3.one;
        m_TweenScalePlus.delay    = fScaleDelayTime;
        m_TweenScalePlus.duration = fScalePlusTime;

        m_TweenScaleMinus.from     = fTextSizeMax * Vector3.one;
        m_TweenScaleMinus.to       = fTextSizeOver * Vector3.one;
        m_TweenScaleMinus.delay    = fScalePlusTime;
        m_TweenScaleMinus.duration = fScaleMinusTime;

        // 两个动作开始播放
        m_UAMotion.Go();
        if (fScaleDelayTime >= 0 && fTextSizeMax > 0 && fScalePlusTime >= 0 && fTextSizeOver > 0 && fScaleMinusTime >= 0)
        {
            m_TweenScalePlus.enabled  = true;
            m_TweenScaleMinus.enabled = true;
            m_TweenScalePlus.Play();
            m_TweenScaleMinus.Play();
        }
        else
        {
            m_TweenScalePlus.enabled  = false;
            m_TweenScaleMinus.enabled = false;
        }

        //  最后设置位置 大小
        //Add by Lijia,伤害数字高度统一进行2.0的修正,如果以后发现有非2.0的情况,可以找我协商
        pos.y += 2.0f;
        m_DamageBoardRootTransform.position      = pos;
        m_DamageBoardRootTransform.localScale    = fTextSize * Vector3.one;
        m_DamageBoardRootTransform.localRotation = Quaternion.LookRotation(Vector3.forward, Vector3.up);

        //伤害板面向当前摄像机
        Vector3 vecUp = Camera.main.transform.rotation * Vector3.up;

        m_DamageBoardRootTransform.LookAt(m_DamageBoardRootTransform.position + Camera.main.transform.rotation * Vector3.back, vecUp);
        m_DamageBoardRootTransform.Rotate(Vector3.up * 180);

        ShowTime = Time.time;
        m_DamageBoardLabel.color = Color.white;

        return(true);
    }