public void updateStatus(SFMsgDataUserSyncInfo info)
    {
        bool lifeChanged = m_curLife != info.life;

        m_curPosX     = info.posX;
        m_curPosY     = info.posY;
        m_curRotation = info.rotation;
        m_curSpeedX   = info.speedX;
        m_curSpeedY   = info.speedY;
        m_curLife     = info.life;
        m_maxLife     = info.maxLife;

        if (info.skillId > 0)
        {
            this.skill(info.skillId, info.skillData);
        }

        if (lifeChanged)
        {
            var data = new SFUnitLifeChange();
            data.uid     = uid;
            data.curLife = m_curLife;
            data.maxLife = m_maxLife;
            SFBattleData.instance.dispatcher.dispatchEvent(SFEvent.EVENT_UNIT_LIFE_CHANGE, data);
        }
    }
示例#2
0
    public void updateStatus(SFMsgDataUserSyncInfo info)
    {
        bool lifeChanged = m_curLife != info.life;

        m_curPosX     = info.posX;
        m_curPosY     = info.posY;
        m_curRotation = info.rotation;
        m_curSpeedX   = info.speedX;
        m_curSpeedY   = info.speedY;
        m_curLife     = info.life;
        m_maxLife     = info.maxLife;

        if (info.skillId > 0)
        {
            this.skill(info.skillId, info.skillData);
        }

        if (lifeChanged)
        {
            var data = new SFUnitLifeChange();
            data.uid     = uid;
            data.curLife = m_curLife;
            data.maxLife = m_maxLife;
            SFBattleData.instance.dispatcher.dispatchEvent(SFEvent.EVENT_UNIT_LIFE_CHANGE, data);
            if (uid == SFUserData.instance.uid && m_curLife <= 0)
            {
                // 死亡,游戏结束
                SFUtils.log("游戏结束");
                m_curSpeedX = 0;
                m_curSpeedY = 0;
                body.SetActive(false);
                // 播放爆炸动画
                explodeFX.Play();
                GameObject.Destroy(gameObject, 1.5f);
                // 显示结束UI
                SFSceneManager.addView("vwGameOver");
                SFBattleData.instance.isGameOver = true;
            }
        }
    }