/// <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); } } }
/// <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 void WeaponOperationByHotKey(SkillHotkey skillHotkey) { if (m_PlayerSkillProxy.UsingReformer()) { SkillCastEvent castSkillEvent = new SkillCastEvent(); castSkillEvent.IsWeaponSkill = true; castSkillEvent.SkillIndex = skillHotkey.SkillIndex; castSkillEvent.KeyPressed = skillHotkey.ActionPhase == HotkeyPhase.Started; //#if NewSkill //#else m_MainPlayer.SendEvent(ComponentEventName.CastSkill, castSkillEvent); //#endif } else { WeaponOperationImplementation(skillHotkey); } }
/// <summary> /// 创建掉落物协议 /// </summary> /// <param name="respond"></param> public void CreateDropItemByRespond(s2cSyncPersonalDrop respond) { if (respond.DropList.Count <= 0) { /// Debug.Log("CreateDropItemByRespond:the drop_list.Count <= 0"); return; } if (respond.IsMapSync == false) { int index = Random.Range(0, 2); WwiseUtil.PlaySound(WwiseManager.voiceComboID, index == 0 ? WwiseMusicSpecialType.SpecialType_Voice_minera_event3 : WwiseMusicSpecialType.SpecialType_Voice_minera_event4, WwiseMusicPalce.Palce_1st, false, null); } ulong parentid = 0; foreach (var item in respond.DropList) { string key = item.MapId.ToString() + item.AreaUid.ToString() + item.ChestNpcUid.ToString(); if (!m_GatherDropItemInfos.ContainsKey(key)) { MineDropItemInfo mineDropItemInfo = new MineDropItemInfo(); mineDropItemInfo.mapid = item.MapId; mineDropItemInfo.areaid = item.AreaUid; mineDropItemInfo.uid = item.ChestNpcUid; mineDropItemInfo.tid = item.ChestNpcTid; mineDropItemInfo.item_tid = item.DropItemTid; mineDropItemInfo.ship_tlv = item.ShipTlv; mineDropItemInfo.parentid = item.FromHeroUid; mineDropItemInfo.positon_x = item.PositonX; mineDropItemInfo.positon_y = item.PositonY; mineDropItemInfo.positon_z = item.PositonZ; if (parentid == 0) { parentid = mineDropItemInfo.parentid; } uint mapId = m_CfgEternityProxy.GetCurrentMapData().GamingmapId; ulong aredId = m_GameplayProxy.GetCurrentAreaUid(); if (mapId == item.MapId && aredId == item.AreaUid) { CreateDropItem(key, mineDropItemInfo, respond.IsMapSync == false); } } } /// 新掉落播音效 if (respond.IsDieDrop == false && respond.IsMapSync == false && parentid != 0) { SpacecraftEntity spacecraftEntity = m_GameplayProxy.GetEntityById <SpacecraftEntity>((uint)parentid); spacecraftEntity.SendEvent(ComponentEventName.PlayDropSound, null); } }
/// <summary> /// 连线特效回调函数 /// </summary> /// <param name="obj"></param> private void OnLineEffectLoad(EffectController effect, System.Object usedata) { if (usedata != null) { SpacecraftAvatarComponent component = (SpacecraftAvatarComponent)usedata; uint ownerHeroID = component.m_Property.GetOwner().m_EntityFatherOwnerID; if (ownerHeroID != 0 && component.m_Property.GetHeroType() == KHeroType.htDisturbor) { SpacecraftEntity target = component.m_GameplayProxy.GetEntityById <SpacecraftEntity>(ownerHeroID) as SpacecraftEntity; effect.SetBeamTarget(component.m_Property.GetSkinTransform(), target.GetSkinTransform(), Vector3.zero, false, target.GetAllColliders()); /// TODO. /// 时间配合特效里的动画时间 UIManager.Instance.StartCoroutine(Excute(0.25f, () => { target.SendEvent(ComponentEventName.LineEffectEnd, null); })); } } }
//private void OnCollisionEnter(Collision obj) //{ // OnSpacecraftSlidingEnd(); //} //private void OnCollisionStay(Collision obj) //{ //} //private void OnCollisionExit(Collision obj) //{ //} //private void OnRelive(IComponentEvent obj) //{ // m_DeadFxState = DeadState.None; // RealTimerUtil.Instance.Unregister(m_ShowDeadFxTimerId); //} private void OnDead(IComponentEvent obj) { DeadEvent deadEvent = obj as DeadEvent; if (!m_SpacecraftDeadProperty.IsDead()) { return; } m_DropInfoList = deadEvent.DropList; /// TODO.宝藏特殊处理 /// 服务器创建后立马死亡 //if (m_SpacecraftDeadProperty.IsNotHaveAva()) //{ // if (m_DropInfoList != null && m_DropInfoList.Count > 0) // { // DropItemManager.Instance.SetDropItemInfoByDeath(m_SpacecraftDeadProperty.UId(), m_DropInfoList); // } // return; //} /// npc死亡 if (m_SpacecraftDeadProperty.GetHeroType() != KHeroType.htPlayer) { Npc npcVO = m_SpacecraftDeadProperty.GetNPCTemplateVO(); if (npcVO.SoundDead > 0) { SendEvent(ComponentEventName.PlaySound, new PlaySound() { SoundID = (int)npcVO.SoundDead }); } /// 导演死检查音乐盒子 if (m_SpacecraftDeadProperty.GetHeroType() == KHeroType.htPlotMonster) { MSAIBossProxy msab = GameFacade.Instance.RetrieveProxy(ProxyName.MSAIBossProxy) as MSAIBossProxy; msab.DestroySoundBox(m_SpacecraftDeadProperty.UId()); } /// TODO.干扰器死亡 else if (m_SpacecraftDeadProperty.GetHeroType() == KHeroType.htDisturbor) { /// 自己的停掉 SpacecraftEntity ownerEntity = m_SpacecraftDeadProperty.GetOwner(); ownerEntity.SendEvent(ComponentEventName.PlaySound, new PlaySound() { SoundID = (int)WwiseMusic.Treasure_Disturbor_Sound5, Transform = ownerEntity.GetSkinTransform() }); TreasureHuntProxy treasure = GameFacade.Instance.RetrieveProxy(ProxyName.TreasureHuntProxy) as TreasureHuntProxy; treasure.DisturborSoundEffect(m_SpacecraftDeadProperty.GetOwner().m_EntityFatherOwnerID); } } m_SpacecraftDeadProperty.SetTarget(null, null); #region 待服务器在new_hero协议中添加复活状态逻辑后删除 if (m_SpacecraftDeadProperty.IsMain()) { m_GameplayProxy = GameFacade.Instance.RetrieveProxy(ProxyName.GameplayProxy) as GameplayProxy; if (m_SpacecraftDeadProperty.IsMain()) { CfgEternityProxy eternityProxy = GameFacade.Instance.RetrieveProxy(ProxyName.CfgEternityProxy) as CfgEternityProxy; m_GameplayProxy.SetDeadMapID(eternityProxy.GetCurrentMapData().GamingmapId); } } #endregion ShowRelivePanel(deadEvent); SpacecraftPresentation presentation = m_SpacecraftDeadProperty.GetPresentation(); if (presentation != null) { if (presentation.SpacecraftDeadType != SpacecraftPresentation.SpacecraftType.Warship) { OnDeviceDead(deadEvent); } } }
/// <summary> /// 干扰器与封印守卫的音效 /// 和干扰器数量相关 /// </summary> public void DisturborSoundEffect(uint ownerHeroID) { if (ownerHeroID == 0) { return; } SpacecraftEntity ownerEntity = m_GameplayProxy.GetEntityById <SpacecraftEntity>(ownerHeroID); /// WwiseUtil.PlaySound((int)WwiseMusic.Treasure_Disturbor_Sound5, false, ownerEntity.GetSkinTransform()); ownerEntity.SendEvent(ComponentEventName.PlaySound, new PlaySound() { SoundID = (int)WwiseMusic.Treasure_Disturbor_Sound5, Transform = ownerEntity.GetSkinTransform() }); List <SpacecraftEntity> entites = m_GameplayProxy.GetEntities <SpacecraftEntity>(); List <SpacecraftEntity> entitesCache = new List <SpacecraftEntity>(); int count = 0; for (int i = 0; i < entites.Count; i++) { SpacecraftEntity entity = entites[i]; if (!entity.IsDead() && entity.GetHeroType() == KHeroType.htDisturbor && entity.m_EntityFatherOwnerID == ownerHeroID) { count++; entitesCache.Add(entity); } } Debug.Log("KHeroType.htDisturbor count" + count); /// TODO. int soundId = 0; if (count == 6) { soundId = (int)WwiseMusic.Treasure_Disturbor_Sound1; } else if (count == 5 || count == 4) { soundId = (int)WwiseMusic.Treasure_Disturbor_Sound2; } else if (count == 3 || count == 2) { soundId = (int)WwiseMusic.Treasure_Disturbor_Sound3; } else if (count == 1) { soundId = (int)WwiseMusic.Treasure_Disturbor_Sound4; } if (soundId != 0) { entitesCache.Add(ownerEntity); for (int i = 0; i < entitesCache.Count; i++) { /// WwiseUtil.PlaySound(soundId, false, entitesCache[i].GetSkinTransform()); entitesCache[i].SendEvent(ComponentEventName.PlaySound, new PlaySound() { SoundID = soundId, Transform = entitesCache[i].GetSkinTransform() }); } } }
/// <summary> /// 技能命中效果 /// </summary> /// <param name="buf"></param> private void OnSkillEffect_ServerMessage(IComponentEvent componentEvent) { S2C_SKILL_EFFECT_Event respond = componentEvent as S2C_SKILL_EFFECT_Event; uint MainID = m_GameplayProxy.GetMainPlayerUID(); SpacecraftEntity caster = m_GameplayProxy.GetEntityById <SpacecraftEntity>(respond.msg.wCasterID) as SpacecraftEntity; SpacecraftEntity target = m_GameplayProxy.GetEntityById <SpacecraftEntity>(respond.msg.wTargetHeroID) as SpacecraftEntity; if ((caster != null && caster.IsMain()) || (target != null && target.IsMain()) || (caster != null && caster.GetEntityFatherOwnerID() == MainID) || (target != null && target.GetEntityFatherOwnerID() == MainID) ) { SkillHurtInfo hurtInfo = MessageSingleton.Get <SkillHurtInfo>(); hurtInfo.TargetID = respond.msg.wTargetHeroID; hurtInfo.IsCrit = respond.msg.crit_type != 0; hurtInfo.PenetrationDamage = (int)respond.msg.PenetrationDamage; hurtInfo.IsDodge = respond.msg.isdoge != 0; hurtInfo.EffectID = (int)(respond.msg.byAttackEvent == (byte)EffectType.TriggerAnomaly ? respond.msg.wTriggerID : 0); hurtInfo.IsWeak = respond.msg.crit_type == 3; for (int iDamage = 0; iDamage < respond.msg.count; iDamage++) { hurtInfo.Damage = (int)(respond.msg.wDamage / respond.msg.count); GameFacade.Instance.SendNotification(NotificationName.SkillHurt, hurtInfo); } // 采矿的表现 (矿物碎裂) SpacecraftEntity currentTargetEntity = m_Property.GetTarget(); if (currentTargetEntity != null && currentTargetEntity.GetHeroType() == KHeroType.htMine && caster.GetTargetCollider() != null) { MineDamage mineEvent = new MineDamage(); mineEvent.HitCollider = caster.GetTargetCollider(); mineEvent.Damage = respond.msg.wDamage; currentTargetEntity.SendEvent(ComponentEventName.MineDamage, mineEvent); } } if (target && target.IsMain()) { if (m_Property.GetUnderAttackWarningToneCountdown() == 0) { WwiseUtil.PlaySound(WwiseManager.voiceComboID, WwiseMusicSpecialType.SpecialType_Voice_Be_Attacked, WwiseMusicPalce.Palce_1st, false, null); } float countDown = m_CfgEternityProxy.GetGamingConfig(1).Value.Sound.Value.CountDown.Value.UnderAttackWarningTone; m_Property.SetUnderAttackWarningToneCountdown(countDown); } /// 播放弱点攻击声音提示 /// TODO.crit_type暂时没有枚举 if (caster && caster.IsMain()) { if (m_WeakSoundTmpCD >= m_WeakSoundCD && respond.msg.crit_type == 3) { float val = Random.value; if (val <= m_WeakSoundProbability) { SendEvent(ComponentEventName.PlayVideoSound, new PlayVideoSound() { GroupID = (int)m_CfgEternityProxy.GetGamingConfig(1).Value.Mine.Value.Sound.Value.WeaknessSoundVideo }); m_WeakSoundTmpCD = 0; } } } }
/// <summary> /// 道具各种操作 /// </summary> /// <param name="buf"></param> private void OnItemChange(KProtoBuf buf) { S2C_ITEM_OPERATE_LIST msg = buf as S2C_ITEM_OPERATE_LIST; if (msg.errcode == 0) { ItemOperateInfoTemp.OperateType weaponOperate = 0; Category category = 0; int pos = 0; ulong uid = 0; List <ulong> ships = new List <ulong>(); for (int i = 0; i < msg.op_list.Count; i++) { ItemOperate itemMsg = msg.op_list[i]; switch ((ItemProcessType)itemMsg.type) { case ItemProcessType.IPTAddItem: //操作顺序不可修改 Category mainType = GetPackageProxy().AddItem(false, itemMsg.uid, itemMsg.tid, itemMsg.parent, itemMsg.pos, itemMsg.count, itemMsg.cur_capacity, itemMsg.reference, itemMsg.create_time); GetPackageProxy().ChangeItemAttr(itemMsg.uid, itemMsg.lv, itemMsg.exp); category = GetPackageProxy().CheckMarkItemAdd(msg.mark, itemMsg.uid); if (category == Category.Weapon) { if (weaponOperate == ItemOperateInfoTemp.OperateType.Remove) { weaponOperate = ItemOperateInfoTemp.OperateType.Replace; pos = itemMsg.pos; uid = itemMsg.uid; } else { weaponOperate = ItemOperateInfoTemp.OperateType.Add; pos = itemMsg.pos; uid = itemMsg.uid; } } if (mainType == Category.Warship) { ships.Add(itemMsg.uid); } // break; case ItemProcessType.IPTDeleteItem: //操作顺序不可修改 category = GetPackageProxy().CheckMarkItemRemove(msg.mark, itemMsg.uid); GetPackageProxy().RemoveItem(itemMsg.uid); if (category == Category.Weapon) { weaponOperate = ItemOperateInfoTemp.OperateType.Remove; pos = itemMsg.pos; uid = itemMsg.uid; } // break; case ItemProcessType.IPTStackChange: GetPackageProxy().ChangeStackCount(itemMsg.uid, itemMsg.count); break; case ItemProcessType.IPTPositionChange: GetPackageProxy().ChangePosition(itemMsg.uid, itemMsg.parent, itemMsg.pos); break; case ItemProcessType.IPTCapacityChange: GetPackageProxy().ChangeContainerSize(itemMsg.uid, itemMsg.cur_capacity); break; } } switch ((ItemOperateType)msg.op_type) { case ItemOperateType.IOTAddItem: GameFacade.Instance.SendNotification(NotificationName.MSG_PACKAGE_ITEM_ADD); break; case ItemOperateType.IOTDestoryItem: GameFacade.Instance.SendNotification(NotificationName.MSG_PACKAGE_ITEM_DESTORY); break; case ItemOperateType.IOTConsumeItem: GameFacade.Instance.SendNotification(NotificationName.MSG_PACKAGE_ITEM_CONSUME); break; case ItemOperateType.IOTMoveItem: GameFacade.Instance.SendNotification(NotificationName.MSG_PACKAGE_ITEM_MOVE); break; case ItemOperateType.IOTSkillChanged: { PlayerSkillProxy skillProxy = GameFacade.Instance.RetrieveProxy(ProxyName.PlayerSkillProxy) as PlayerSkillProxy; skillProxy.RefreshShipSkills(); } break; } if (weaponOperate != 0) { ItemOperateInfoTemp info = new ItemOperateInfoTemp(); info.Category = Category.Weapon; info.Type = weaponOperate; info.Pos = pos; info.UID = uid; GameFacade.Instance.SendNotification(NotificationName.MSG_PACKAGE_ITEM_OPERATE, info); ItemOperateEvent itemEvent = new ItemOperateEvent(); info.Category = Category.Weapon; info.Type = weaponOperate; info.Pos = pos; info.UID = uid; GameplayProxy gameplayProxy = GameFacade.Instance.RetrieveProxy(ProxyName.GameplayProxy) as GameplayProxy; SpacecraftEntity entity = gameplayProxy.GetMainPlayer(); entity?.SendEvent(ComponentEventName.ItemInPackageChanged, itemEvent); } if (ships.Count > 0) { ShipProxy shipProxy = GameFacade.Instance.RetrieveProxy(ProxyName.ShipProxy) as ShipProxy; foreach (ulong id in ships) { shipProxy.ChangeShipPackage(id); } } } }