public Buff(BuffVO vo, IBuffProperty property) { VO = vo; BuffProperty = property; // Cache m_SkillProxy = GameFacade.Instance.RetrieveProxy(ProxyName.CfgSkillSystemProxy) as CfgSkillSystemProxy; m_GameplayProxy = GameFacade.Instance.RetrieveProxy(ProxyName.GameplayProxy) as GameplayProxy; Leyoutech.Utility.DebugUtility.LogWarning("Buff", string.Format("创建一个Buff ---> 归属entity = {0} , Buff ID = {1}", BuffProperty.EntityId(), VO.ID)); SkillBuff configVO = m_SkillProxy.GetBuff((int)VO.ID); if (configVO.ByteBuffer != null) { BuffEffect = BuffEffectBase.GetBuffEffectByType((BuffEffectType)configVO.BuffEffectId, this); Transform selfTf = BuffProperty.GetRootTransform(); SpacecraftEntity otherEntity = m_GameplayProxy.GetEntityById <SpacecraftEntity>(VO.Link_id) as SpacecraftEntity; Transform otherTf = null; if (otherEntity != null && !otherEntity.IsDead()) { otherTf = otherEntity.GetRootTransform(); } BuffEffect.Init(selfTf, otherTf); } else { BuffEffect = new BuffEffectBase(this); } }
/// <summary> /// 是否已经死亡 /// </summary> /// <returns>bool</returns> private bool IsDead() { SpacecraftEntity entity = m_GameplayProxy.GetEntityById <SpacecraftEntity>(m_GameplayProxy.GetMainPlayerUID()); if (entity) { return(entity.IsDead()); } return(false); }
/// <summary> /// 检测是否已经选中了新的目标 /// 更新已经锁定了的目标的锁定状态 /// </summary> /// <param name="deltaTime"></param> public override void OnUpdate(float deltaTime) { base.OnUpdate(deltaTime); // 调试代码 if (Input.GetKeyDown(KeyCode.Keypad0)) { ResetWeaponRuntimeData(); Debug.LogError("清理武器导弹状态"); } TranslateUniformParamToWeaponParam(); // 调试代码 List <SpacecraftEntity> targetList = new List <SpacecraftEntity>(); // 锁定多目标, 同时让他们描红的逻辑, 还需要仔细考虑. 这里暂时先注释. 选择目标把它描红的逻辑让HUD执行 //bool targetSelected = GetAllEntitySelectedByVirtualCamera(ref targetList); //NotifyHUDTargetSelected(targetSelected ? targetList[0] : null); // 尝试锁定新的目标 if (m_State == State.Lock && IsThereSurplusMissile()) { for (int iTarget = 0; iTarget < targetList.Count; iTarget++) { TryToLockThisTarget(targetList[iTarget]); } } PlayerMissileWeaponTargetSelectionInfo targetInfoNotify = MessageSingleton.Get <PlayerMissileWeaponTargetSelectionInfo>(); // FIXME. 动态内存分配 //targetInfoNotify.TargeList = m_LockTargeMap; GameFacade.Instance.SendNotification(NotificationName.PlayerMissileWeaponTargetSelection, targetInfoNotify); // 更新已有的目标 // iterate all locking and locked target // locking: // once countdown finished, set target state to Locked // locking and locked: // if target is out of range / dead, unlock target List <SpacecraftEntity> cancelLockList = new List <SpacecraftEntity>(); foreach (var pair in m_LockTargeMap) { SpacecraftEntity targetEntity = pair.Key; TargetLockInfo targetLockInfo = pair.Value; if (targetLockInfo.LockState == TargetLockState.Locking) { if (targetLockInfo.LockTimeRemaining <= 0f) { targetLockInfo.LockState = TargetLockState.Locked; targetLockInfo.LockTimeRemaining = 0f; targetLockInfo.LockTimes++; SLog("目标锁定完成. {0}", targetEntity.name); } else { targetLockInfo.LockTimeRemaining -= deltaTime; } } // UNDONE, 检查所有目标是不是已经超出了射程或者已经死了. 如果是的话, 就接触锁定 if (targetEntity == null || targetEntity.IsDead()) { cancelLockList.Add(targetEntity); } } // 接触已经不可用的目标的锁定 for (int iEntity = 0; iEntity < cancelLockList.Count; iEntity++) { m_LockTargeMap.Remove(cancelLockList[iEntity]); SLog("目标因为死亡或者超出视野而失去锁定. {0}", iEntity); } }
/// <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="deltaTime"></param> public override void OnUpdate(float deltaTime) { base.OnUpdate(deltaTime); // 调试代码 if (Input.GetKeyDown(KeyCode.Keypad0)) { ResetWeaponRuntimeData(); Debug.LogError("清理武器导弹状态"); } TranslateUniformParamToWeaponParam(); // 调试代码 if (m_State == State.Lock) { SpacecraftEntity newTarget = GetTargetSelectedByCenterRay(); //NotifyHUDTargetSelected(newTarget); // 尝试锁定新的目标 if (IsThereSurplusMissile()) { TryToLockThisTarget(newTarget); } // 清理已经出框的目标 ClearLockingTargetWhichIsNotInLockingRect(); // 更新已有的目标 // iterate all locking and locked target // locking: // once countdown finished, set target state to Locked // locking and locked: // if target is out of range / dead, unlock target List <SpacecraftEntity> cancelLockList = new List <SpacecraftEntity>(); foreach (var pair in m_LockTargeMap) { SpacecraftEntity targetEntity = pair.Key; // UNDONE, 检查所有目标是不是已经超出了射程或者已经死了. 如果是的话, 就接触锁定 if (targetEntity == null || targetEntity.IsDead()) { cancelLockList.Add(targetEntity); continue; } TargetLockInfo targetLockInfo = pair.Value; if (targetLockInfo.LockState == TargetLockState.Locking && IsThereSurplusMissile()) { if (IsThereSurplusMissile()) //还不够 { if (targetLockInfo.LockTimeRemaining <= 0f) { targetLockInfo.LockState = TargetLockState.Locked; targetLockInfo.LockTimeRemaining = 0f; targetLockInfo.LockTimes++; SLog("目标锁定完成. {0}", targetEntity.name); } else { targetLockInfo.LockTimeRemaining -= deltaTime; } } else //够了,将未完成转圈的 { if (targetLockInfo.LockTimes == 0) { cancelLockList.Add(targetEntity); } else { targetLockInfo.LockState = BattleWeapon_Missile.TargetLockState.Locked; targetLockInfo.LockTimeRemaining = 0; } } } } // 对于那些已经不可用的目标解除锁定 for (int iEntity = 0; iEntity < cancelLockList.Count; iEntity++) { m_LockTargeMap.Remove(cancelLockList[iEntity]); SLog("目标因为死亡或者超出视野而失去锁定. {0}", iEntity); } } // 通知UI当前锁定的所有目标 PlayerMissileWeaponTargetSelectionInfo targetInfoNotify = MessageSingleton.Get <PlayerMissileWeaponTargetSelectionInfo>(); //targetInfoNotify.TargeList = m_LockTargeMap; GameFacade.Instance.SendNotification(NotificationName.PlayerMissileWeaponTargetSelection, targetInfoNotify); }