Ejemplo n.º 1
0
    /// <summary>
    /// 同步所有单位的属性
    /// </summary>
    private void SyncAllUnitAttr()
    {
        proto.S2CSyncUnitAttr attrList = new proto.S2CSyncUnitAttr();
        for (int i = 0; i < EntityManager.Instance.AttackUnitList.Count; ++i)
        {
            proto.UnitAttri attr   = new proto.UnitAttri();
            ShipEntity      entity = EntityManager.Instance.AttackUnitList[i] as ShipEntity;
            attr.unitid      = entity.ID;
            attr.durablility = entity.GetDurability();
            attr.armor       = entity.GetArmouredShield();
            attr.energy      = entity.GetEnergyShield();
            attrList.add_unitattrlist(attr);
        }

        for (int i = 0; i < EntityManager.Instance.DefenderUnitList.Count; ++i)
        {
            proto.UnitAttri attr   = new proto.UnitAttri();
            ShipEntity      entity = EntityManager.Instance.DefenderUnitList[i] as ShipEntity;
            attr.unitid      = entity.ID;
            attr.durablility = entity.GetDurability();
            attr.armor       = entity.GetArmouredShield();
            attr.energy      = entity.GetEnergyShield();
            attrList.add_unitattrlist(attr);
        }

        BattleSys.OnSyncUnitAttr(attrList);
    }
Ejemplo n.º 2
0
    public static void OnSyncUnitAttr(proto.S2CSyncUnitAttr msg)
    {
        for (int i = 0; i < msg.unitattrlist_size(); i++)
        {
            proto.UnitAttri attribute = msg.unitattrlist(i);
            //SetShip( true, attribute );
            // TODO::
            // 临时解决办法,待重构
            var teamDisplay = BattleSceneDisplayManager.Instance.GetTeamDisplay(attribute.unitid);
            if (teamDisplay != null)
            {
                teamDisplay.SyncAttr(attribute);
            }
        }

        if (EventOnSyncUnitAttr != null)
        {
            EventOnSyncUnitAttr(msg);
        }
    }