コード例 #1
0
    static void OnLoadDamageBoard(GameObject resObj, object param)
    {
        if (PlayerPreferenceData.SystemDamageBoardEnable == false)
        {
            return;
        }
        if (null == resObj || null == param)
        {
            return;
        }

        if (null == GameManager.gameManager.ActiveScene ||
            null == GameManager.gameManager.ActiveScene.DamageBoardRoot)
        {
            return;
        }

        GameObject resInst = GameObject.Instantiate(resObj) as GameObject;

        resInst.transform.parent = GameManager.gameManager.ActiveScene.DamageBoardRoot.transform;

        DamageBoard board = resInst.GetComponentInChildren <DamageBoard>();

        if (null == board)
        {
            return;
        }

        DamageBoardLoadInfo info = param as DamageBoardLoadInfo;

        if (board.ActiveDamageBoard(info.Type, info.Value, info.Pos, info.IsProfessionSkill) && m_EnabledDictionary.ContainsKey(info.Type))
        {
            m_EnabledDictionary[info.Type].Add(board);
        }
    }
コード例 #2
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);
            }
        }
    }