/// <summary> /// 在武器变化的时候, 更新当前实装的武器的准星信息 /// </summary> private void UpdateBattleWeapons(IComponentEvent entityEvent) { PlayerSkillProxy m_SkillProxy = GameFacade.Instance.RetrieveProxy(ProxyName.PlayerSkillProxy) as PlayerSkillProxy; for (int iWeapon = 0; iWeapon < BATTLE_WEAPON_COUNT; iWeapon++) { IWeapon weapon = m_SkillProxy.GetWeaponByIndex(iWeapon); if (weapon == null) { continue; } ulong uid = weapon.GetUID(); if (!m_IPerceptronTarget.HaveWeaponAndCrossSight(uid)) { WeaponAndCrossSight weaponAndCross = WeaponAndCrossSightFactory.CreatTWeapon(uid, weapon.GetConfig().Id, weapon.GetBaseConfig().SkillId, (WeaponAndCrossSight.WeaponAndCrossSightTypes)weapon.GetConfig().Reticle); //Debug.LogError(string.Format("创建准星 uid = {0}, tid = {1} , type = {2}, null? {3}", uid, weapon.GetConfig().Id, weapon.GetConfig().Reticle , (weaponAndCross== null))); if (weaponAndCross == null) { continue; } m_IPerceptronTarget.AddWeaponAndCrossSight(uid, weaponAndCross); } } }
/// <summary> /// 获取当前武器武器准星对象 /// </summary> /// <returns></returns> public WeaponAndCrossSight GetCurrentWeaponAndCrossSight() { SpacecraftEntity mainPlayer = m_GameplayProxy.GetEntityById <SpacecraftEntity>(m_GameplayProxy.GetMainPlayerUID()); if (mainPlayer == null) { return(null); } WeaponAndCrossSight result = null; if (UsingReformer()) { //转化炉武器 IReformer reformer = GetReformer(); if (reformer != null && mainPlayer.HaveWeaponAndCrossSight(reformer.GetUID())) { result = mainPlayer.GetWeaponAndCrossSight(reformer.GetUID()); } } else { //普通武器 IWeapon weapon = GetCurrentWeapon(); if (weapon != null && mainPlayer.HaveWeaponAndCrossSight(weapon.GetUID())) { result = mainPlayer.GetWeaponAndCrossSight(weapon.GetUID()); } } return(result); }
/// <summary> ///通知武器准星Size变化 /// </summary> private void ChangeCrossSightSize(IComponentEvent entityEvent) { //武器&准星循环 WeaponAndCrossSight weaponCS = m_SkillProxy.GetCurrentWeaponAndCrossSight(); if (weaponCS != null) { weaponCS.ChangeCrossSightSize(); } }
public override void OnUpdate(float delta) { base.OnUpdate(delta); m_PerceptronTarget.OnUpdata(); if (m_IPerceptronTarget.GetOwner().IsMain()) { //武器&准星循环 WeaponAndCrossSight weapon = m_SkillProxy.GetCurrentWeaponAndCrossSight(); if (weapon != null) { weapon.OnUpdate(delta); } } }
/// <summary> /// 武器热键响应 /// </summary> private void WeaponHotKeyOperation(IComponentEvent entityEvent) { SkillHotkey skillHotkey = entityEvent as SkillHotkey; IWeapon weapon = m_SkillProxy.GetCurrentWeapon(); if (weapon == null) { return; } //武器&准星循环 WeaponAndCrossSight weaponCS = m_SkillProxy.GetCurrentWeaponAndCrossSight(); if (weaponCS != null) { weaponCS.OnHotKey(skillHotkey); } }
/// <summary> ///武器释放的技能结束 /// </summary> private void WeaponSkillFinish(IComponentEvent entityEvent) { WeaponSkillFinish weaponskillfinish = entityEvent as WeaponSkillFinish; if (!weaponskillfinish.IsMain) { return; } PlayerShipSkillVO skillVO = m_SkillProxy.GetCurrentWeaponSkillVO(); if (skillVO != null && skillVO.GetID() == weaponskillfinish.skillId && weaponskillfinish.skillId > 0) { WeaponAndCrossSight weaponCS = m_SkillProxy.GetCurrentWeaponAndCrossSight(); if (weaponCS != null) { weaponCS.WeaponSkillFinish(); } } }
/// <summary> /// 转化炉切换 /// </summary> /// <param name="entityEvent"></param> private void ReformerWeapons(IComponentEvent entityEvent) { if (m_IPerceptronTarget.GetCurrentState().IsHasSubState(EnumSubState.Peerless)) { //转化炉模式 if (!m_SkillProxy.UsingReformer()) { return; } IReformer reformer = m_SkillProxy.GetReformer(); if (reformer == null) { return; } ulong uid = reformer.GetUID(); if (!m_IPerceptronTarget.HaveWeaponAndCrossSight(uid)) { WeaponAndCrossSight weaponAndCross = WeaponAndCrossSightFactory.CreatTWeapon(uid, reformer.GetConfig().Id, reformer.GetBaseConfig().SkillId, (WeaponAndCrossSight.WeaponAndCrossSightTypes)reformer.GetConfig().Reticle); //Debug.LogError(string.Format("创建准星 uid = {0}, tid = {1} , type = {2}, null? {3}", uid, weapon.GetConfig().Id, weapon.GetConfig().Reticle , (weaponAndCross== null))); if (weaponAndCross == null) { return; } m_IPerceptronTarget.AddWeaponAndCrossSight(uid, weaponAndCross); } } else { //非转化炉模式 m_IPerceptronTarget.DeleReformerWeaponAndCrossSight(); } }
/// <summary> /// 创建武器 /// </summary> /// <param name="crosssightinfo"></param> public static WeaponAndCrossSight CreatTWeapon(ulong uId, uint tId, ulong skillId, WeaponAndCrossSight.WeaponAndCrossSightTypes type) { WeaponAndCrossSight result = null; if (type == WeaponAndCrossSight.WeaponAndCrossSightTypes.MachineGun) //速射抢 { result = new WeaponAndCrossSight_MachineGun(uId, tId, skillId); result.Init(); } if (type == WeaponAndCrossSight.WeaponAndCrossSightTypes.Missile)//导弹 { result = new WeaponAndCrossSight_Missile(uId, tId, skillId); result.Init(); } if (type == WeaponAndCrossSight.WeaponAndCrossSightTypes.ShotGun)//导弹 { result = new WeaponAndCrossSight_ShotGun(uId, tId, skillId); result.Init(); } if (type == WeaponAndCrossSight.WeaponAndCrossSightTypes.Reformer)//转化炉 { result = new WeaponAndCrossSight_Reformer(uId, tId, skillId); result.Init(); } if (type == WeaponAndCrossSight.WeaponAndCrossSightTypes.Mining)//矿枪, 采用持续引导激光类型 { result = new WeaponAndCrossSight_Mining(uId, tId, skillId); result.Init(); } return(result); }
public void AddWeaponAndCrossSight(ulong uid, WeaponAndCrossSight Weapon) { throw new System.NotImplementedException(); }
/// <summary> /// 获取当前感知到的所有单位 /// </summary> /// <param name="direction"> 返回目标计算方式的,依据方向</param> //准星镜头正方向(主相机正方向)or 抖动的随机方向 /// <returns></returns> private List <CCrossSightLoic.Target> GetCurrentEntity(out Vector3 direction, SkillTagercalculationType TagercalculationType = SkillTagercalculationType.CrossSightLens) { List <CCrossSightLoic.Target> result = new List <CCrossSightLoic.Target>(); direction = CameraManager.GetInstance().GetMainCamereComponent().GetForward(); if (m_OwnerEntity.IsMain()) { //武器&准星 WeaponAndCrossSight m_weaponCS = GetCurrWeaponAndCrossSight(); if (m_weaponCS != null) { List <CCrossSightLoic.Target> targets = null; if (TagercalculationType == SkillTagercalculationType.CrossSightLens) //准星镜头内的目标 { targets = m_weaponCS.GetTargets(); } else if (TagercalculationType == SkillTagercalculationType.Formula) //公式计算的目标,比如抖动 { m_weaponCS.GetBallisticTargetAndOutDirection(out targets, out direction, null); } if (targets != null) { result.AddRange(targets); } } } else { for (int i = 0; i < m_BroadCastTargets.Count; i++) { BaseEntity entity = GameplayManager.Instance.GetEntityManager().GetEntityById <BaseEntity>((uint)m_BroadCastTargets[i]); if (entity == null) { continue; } CCrossSightLoic.Target cct = new CCrossSightLoic.Target(); cct.target_entityId = m_BroadCastTargets[i]; cct.target_pos = entity.GetRootTransform().position; result.Add(cct); } Vector3 worldPosition = m_GameplayProxy.ServerAreaOffsetToClientPosition(m_BroadCastDirection); //服务器坐标,转 Unity 坐标 direction = (worldPosition - m_OwnerEntity.GetRootTransform().position).normalized; //Leyoutech.Utility.DebugUtility.LogError("第三方最远点方向", string.Format("计算方向 -----> ,self = {0} , m_BroadCastDirection = {1}, worldPosition = {2} , PlayPos = {3} , direction = {4}", // m_OwnerEntity.EntityId(), // m_BroadCastDirection, // worldPosition, // m_OwnerEntity.GetRootTransform().position, // direction // )); } // Leyoutech.Utility.DebugUtility.LogWarning("目标队列", "准星 List: " + string.Join(",", result)); return(result); }