예제 #1
0
    /// <summary>
    /// 同步HP、MP
    /// </summary>
    /// <param name="buf"></param>
    private void OnHeroHpMpAnger(KProtoBuf buf)
    {
        S2C_SYNC_HERO_HPMP_ANGER msg    = buf as S2C_SYNC_HERO_HPMP_ANGER;
        SpacecraftEntity         entity = m_GameplayProxy.GetEntityById <SpacecraftEntity>(msg.heroID);

        if (entity != null)
        {
            entity.SetAttribute(AttributeName.kHP, msg.hp);
            entity.SetAttribute(AttributeName.kShieldValue, msg.shield_value);
            entity.SetAttribute(AttributeName.kPowerValue, msg.energyPower);
            //新屬性目前沒有
            //entity.SetAttribute(AttributeName.DefenseShield, msg.defense_shield_value);
            //entity.SetAttribute(AttributeName.ManaShield, msg.mana_shield_value);
            //entity.SetAttribute(AttributeName.SuperMagnetic, msg.superMagnetic);

            double oldPeerless = entity.GetAttribute(AttributeName.kConverterValue);             /// entity.GetPeerless();
            /// entity.SetPeerless((uint)msg.current_peerless);
            entity.SetAttribute(AttributeName.kConverterValue, msg.current_peerless);

            if (entity.IsMain() && oldPeerless != entity.GetAttribute(AttributeName.kConverterMax) &&
                entity.GetAttribute(AttributeName.kConverterValue) == entity.GetAttribute(AttributeName.kConverterMax))
            {
                entity.SendEvent(ComponentEventName.MaxPeerlessReached, null);
            }
        }
    }