Beispiel #1
0
    /// <summary>
    /// 添加伤害体 TODO
    /// </summary>
    /// <param name="damageBodyObj"></param>
    /// <param name="skillId"></param>
    /// <param name="damageId"></param>
    /// <returns></returns>
    public DamageBody AddDamageBody(BaseRole host, int dirX, int dirY, int skillId, int damageId)
    {
        if (MapManager.Instance == null || MapManager.Instance.HasCurMap == false)
        {
            return(null);
        }
        DamageBodyInfo dbInfo = DamageDataManager.Instance.GetDamageBodyInfo(damageId);

        if (dbInfo == null)
        {
            return(null);
        }

        GameObject obj = new GameObject();

        if (obj == null)
        {
            return(null);
        }
        string handleName = skillId + "_" + GetHandleIndex(); // 没想好

        obj.name = handleName;
        GlobalVarFun.AttachChild(m_rootObj, obj);
        DamageBody db = obj.AddComponent <DamageBody>();

        db.InitDamage(host, handleName, dirX, dirY, skillId, dbInfo);
        m_damageBodyDic.Add(handleName, db);
        return(db);
    }
Beispiel #2
0
    /// <summary>
    /// 初始化DamageDataManager 其实是加载DamageData文件
    /// </summary>
    public void Init()
    {
        // 读取数据
        InfoNodeList viList = InfoNodeHelper.ReadFromCSV(GlobalVarFun.m_streamAssets + "Battle/DamageBodyData.csv");

        if (null == viList)
        {
            m_bIsInited = false;
            return;
        }

        string[] arrKeys = viList.m_nodeList.Keys.ToArray();
        for (int i = 0; i < viList.Count; i++)
        {
            InfoNode vi = viList.m_nodeList[arrKeys[i]];
            if (vi != null)
            {
                DamageBodyInfo dbData = new DamageBodyInfo(vi);
                m_damageDataDic.Add(dbData.ID, dbData);

                UnityEngine.Debug.Log("DamageDataManager.cs  ---  LoadAllDamageBodyData : " + dbData.ID + " : " + dbData.Name);
            }
        }
        m_bIsInited = true;
    }
Beispiel #3
0
    /// <summary>
    /// 设置伤害体初始数据
    /// </summary>
    /// <returns></returns>
    public bool InitDamage(BaseRole host, string handleName, int dirX, int dirY, int skillId, DamageBodyInfo node)
    {
        if (host == null || node == null)
        {
            m_bStarted = false;
            return(false);
        }
        m_host           = host;
        m_sHandleName    = handleName;
        m_iSkillID       = skillId;
        m_eDamageType    = (eDamageBodyType)node.DamageType;
        m_eMoveType      = (eDamageMoveType)node.MoveType;
        m_damageBodyInfo = node;
        // TODO 可能有很多个?
        GameObject prefabObj = Resource.LoadObj(m_damageBodyInfo.PrefabName) as GameObject;

        if (null == prefabObj)
        {
            m_bStarted = false;
            return(false);
        }
        GameObject showObj = GameObject.Instantiate(prefabObj);

        showObj.name = "node";
        GlobalVarFun.AttachChild(gameObject, showObj);
        m_fWidth       = m_damageBodyInfo.Width;
        m_fHeight      = m_damageBodyInfo.Height;
        m_fEsTime      = m_damageBodyInfo.EsTime;
        m_iDamageCount = m_damageBodyInfo.DamageCount;
        m_iDamage      = m_damageBodyInfo.DamageValue;
        m_fPosX        = host.m_fPositionX + m_damageBodyInfo.OffsetX;
        m_fPosY        = host.m_fPositionY + m_damageBodyInfo.OffsetY;
        m_iDirX        = dirX;
        m_iDirY        = dirY;
        m_fVelocityX   = dirX * m_damageBodyInfo.MoveVelocity;
        m_fVelocityY   = dirY * m_damageBodyInfo.MoveVelocity;
        m_velocity.x   = m_fVelocityX;
        m_velocity.y   = m_fVelocityY;

        if (m_mapDamage == null)
        {
            m_mapDamage = new MapDamage(this);
        }
        m_mapDamage.InitB2Body(MapManager.Instance.curMapWorld, m_fPosX, m_fPosY, m_fWidth, m_fHeight);
        m_mapDamage.SetCurVelocityX(m_fVelocityX);
        m_mapDamage.SetCurVelocityY(m_fVelocityY);

        Clear();
        m_bStarted   = true;
        m_fBeginTime = GlobalVarFun.GetTime();
        return(true);
    }
Beispiel #4
0
    public void TestAddDamageInfo()
    {
        DamageBodyInfo dbData = new DamageBodyInfo(null);

        m_damageDataDic.Add(dbData.ID, dbData);
    }