/// <summary> /// 弹夹信息,只有主角才有 /// </summary> /// <param name="result"></param> private static void DisposeSyncClipInfo(SyncClipInfo result) { //Leyoutech.Utility.DebugUtility.LogWarning("广播", string.Format("弹夹信息, 武器ID = {0}", result.CurWeaponUid)); GameplayProxy m_GameplayProxy = GameFacade.Instance.RetrieveProxy(ProxyName.GameplayProxy) as GameplayProxy; SpacecraftEntity entity = m_GameplayProxy.GetEntityById <SpacecraftEntity>(m_GameplayProxy.GetMainPlayerUID()); if (entity == null) { return; } PlayerSkillProxy m_PlayerSkillProxy = GameFacade.Instance.RetrieveProxy(ProxyName.PlayerSkillProxy) as PlayerSkillProxy; m_PlayerSkillProxy.ChangeCurrentWeaponByServer(result.CurWeaponUid); foreach (WeaponValue info in result.Infos) { ulong weaponUID = info.WeaponUid; WeaponPowerVO power = entity.GetWeaponPower(weaponUID); if (power == null) { entity.SetWeaponPower(weaponUID, new WeaponPowerVO()); power = entity.GetWeaponPower(weaponUID); } power.WeaponUID = info.WeaponUid; power.CurrentValue = info.CurValue; power.MaxValue = info.MaxValue; power.SafeValue = info.SaftyValue; IWeapon weapon = m_PlayerSkillProxy.GetWeaponByUID(power.WeaponUID); if (weapon != null && weapon.GetConfig().ClipType != (int)WeaponL1.Treasure) { if (power.CurrentValue <= 0) { power.ForceCooldown = true; } else if (power.CurrentValue >= power.SafeValue) { power.ForceCooldown = false; } } else { if (power.CurrentValue >= power.MaxValue) { power.ForceCooldown = true; } else if (power.CurrentValue <= power.SafeValue) { power.ForceCooldown = false; } } } GameFacade.Instance.SendNotification(NotificationName.MSG_CHARACTER_WEAPON_POWER_CHANGED); entity.SendEvent(ComponentEventName.WeaponPowerChanged, null); }
private void OnWeaponPowerChanged(KProtoBuf buffer) { S2C_WEAPON_VALUE msg = buffer as S2C_WEAPON_VALUE; SpacecraftEntity entity = m_GameplayProxy.GetEntityById <SpacecraftEntity>(m_GameplayProxy.GetMainPlayerUID()); if (entity == null) { return; } m_PlayerSkillProxy.ChangeCurrentWeaponByServer(msg.cur_weapon_uid); foreach (WEAPONVALUE info in msg.infos) { ulong weaponUID = info.weapon_oid; WeaponPowerVO power = entity.GetWeaponPower(weaponUID); if (power == null) { entity.SetWeaponPower(weaponUID, new WeaponPowerVO()); power = entity.GetWeaponPower(weaponUID); } power.WeaponUID = info.weapon_oid; power.CurrentValue = info.cur_value; power.MaxValue = info.max_value; power.SafeValue = info.safty_valve; IWeapon weapon = m_PlayerSkillProxy.GetWeaponByUID(power.WeaponUID); if (weapon != null && weapon.GetConfig().ClipType != (int)WeaponL1.Treasure) { if (power.CurrentValue <= 0) { power.ForceCooldown = true; } else if (power.CurrentValue >= power.SafeValue) { power.ForceCooldown = false; } } else { if (power.CurrentValue >= power.MaxValue) { power.ForceCooldown = true; } else if (power.CurrentValue <= power.SafeValue) { power.ForceCooldown = false; } } } GameFacade.Instance.SendNotification(NotificationName.MSG_CHARACTER_WEAPON_POWER_CHANGED); entity.SendEvent(ComponentEventName.WeaponPowerChanged, null); }
public WeaponPowerVO GetCurrentWeaponPowerOfMainPlayer() { GameplayProxy gameplayProxy = GameFacade.Instance.RetrieveProxy(ProxyName.GameplayProxy) as GameplayProxy; SpacecraftEntity mainEntity = gameplayProxy.GetEntityById <SpacecraftEntity>(gameplayProxy.GetMainPlayerUID()); IWeapon curWeapon = GetCurrentWeapon(); return(curWeapon != null?mainEntity.GetWeaponPower(curWeapon.GetUID()) : null); }
public WeaponPowerVO GetWeaponPowerOfMainPlayer(int index) { SpacecraftEntity mainEntity = m_GameplayProxy.GetEntityById <SpacecraftEntity>(m_GameplayProxy.GetMainPlayerUID()); if (mainEntity == null) { return(null); } else { IWeapon weapon = GetWeaponByIndex(index); return(weapon != null?mainEntity.GetWeaponPower(weapon.GetUID()) : null); } }
public bool CanWeaponRelease(ulong UID) { SpacecraftEntity mainEntity = m_GameplayProxy.GetEntityById <SpacecraftEntity>(m_GameplayProxy.GetMainPlayerUID()); WeaponPowerVO powerVO = mainEntity.GetWeaponPower(UID); int weaponType = ItemTypeUtil.GetWeaponType(GetWeaponByUID(UID)); // 武器是否有弹药或者是否已经冷却 if (weaponType < 0 || (powerVO != null && powerVO.ForceCooldown)) { Debug.LogFormat("power.current: {0}. ForceCooldown: {1}", powerVO.CurrentValue, powerVO.ForceCooldown); return(false); } return(true); }