예제 #1
0
    // Update is called once per frame
    void Update()
    {
        if (m_bCanLoadMap == false)
        {
            return;
        }

        m_fCurTime   = GlobalVarFun.GetTime();
        m_fDeltaTime = GlobalVarFun.GetSmoothDeltaTime();

        // 地图更新 (包括普通的Collider)
        if (MapManager.Instance != null)
        {
            MapManager.Instance.Update(m_fDeltaTime, m_fCurTime);
        }
        // Role更新 TODO
        if (RoleManager.Instance != null)
        {
            RoleManager.Instance.Update(m_fDeltaTime, m_fCurTime);
        }
        // 时间事件更新 TODO
        // 伤害体更新 TODO
        if (DamageBodyManager.Instance != null)
        {
            DamageBodyManager.Instance.Update(m_fDeltaTime, m_fCurTime);
        }
    }
예제 #2
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);
    }