public BattleWeapon_MachineGun(IWeapon weapon) : base(weapon) { m_WeaponFireData = m_CfgEternityProxy.GetWeaponDataOfMachineGun(m_WeaponConfig.TypeDateSheetld); m_SkillVO = m_PlayerSkillProxy.GetSkillByID((int)m_WeaponItem.GetBaseConfig().SkillId); m_CurrentBulletCount = 0; m_State = GunState.Stop; // TEST //SetupStaticWeaponParam_Debug(); TranslateUniformParamToWeaponParam(); // TEST }
/// <summary> /// 技能是否正在CD中, 考虑自身CD和公共CD /// </summary> /// <param name="skillID"></param> /// <returns></returns> public bool IsOnTriggerCD(int skillID) { Debug.Assert(m_SkillIDToSkill.ContainsKey(skillID)); if (!m_SkillIDToSkill.ContainsKey(skillID)) { return(false); } PlayerSkillVO skill = m_SkillIDToSkill[skillID]; // 如果是武器技能, 则不考虑公共CD return(!skill.IsTriggerCDFinished()); }
/// <summary> /// 技能是否正在CD中, 考虑自身CD和公共CD /// </summary> /// <param name="skillID"></param> /// <returns></returns> public bool IsOnCD(int skillID) { Debug.Assert(m_SkillIDToSkill.ContainsKey(skillID)); if (!m_SkillIDToSkill.ContainsKey(skillID)) { return(false); } PlayerSkillVO skill = m_SkillIDToSkill[skillID]; // 如果是武器技能, 则不考虑公共CD return(skill.GetRemainingCD() > 0 || Time.time < m_SkillTypeToGlobalCDEndTime[GetSkillType(skillID)]); }
/// <summary> /// 中心点射线选中的目标 /// </summary> /// <returns></returns> private SpacecraftEntity GetTargetSelectedByCenterRay() { PlayerSkillVO skillVO = m_PlayerSkillProxy.GetCurrentWeaponSkill(); SkillSystemGrow skillGrow = skillVO.GetSkillGrow(); float maxDistance = skillGrow.Range * SceneController.SPACE_ACCURACY_TO_CLIENT; MainCameraComponent mainCam = CameraManager.GetInstance().GetMainCamereComponent(); Ray ray = new Ray(mainCam.GetPosition(), mainCam.GetForward()); RaycastHit hitInfo = new RaycastHit(); if (Physics.Raycast(ray, out hitInfo, maxDistance, LayerUtil.GetLayersIntersectWithSkillProjectile(true))) { return(hitInfo.collider.attachedRigidbody?.GetComponent <SpacecraftEntity>()); } else { return(null); } }
public float GetRemainingCD(int skillID) { Debug.Assert(m_SkillIDToSkill.ContainsKey(skillID)); if (!m_SkillIDToSkill.ContainsKey(skillID)) { return(0f); } PlayerSkillVO skill = m_SkillIDToSkill[skillID]; float skillCD = skill.GetRemainingCD(); float remainingGlobalCD = Mathf.Clamp(m_SkillTypeToGlobalCDEndTime[(SkillType)skill.GetSkillGrow().SkillType] - Time.time, 0, 99999f); if (remainingGlobalCD > skillCD) { skillCD = remainingGlobalCD; } return(skillCD); }
/// <summary> /// 根据这次射击的弹道方向, 计算命中的目标Entity和目标点 /// </summary> /// <param name="camDirAffectedByRecoil"></param> /// <returns></returns> protected SkillTarget CalulateTargetDataByShootingDirection(Vector3 camDirAffectedByRecoil) { // 计算射线碰到的目标点, 并重新计算从Launcher到目标点的方向 PlayerSkillVO skillVO = m_PlayerSkillProxy.GetCurrentWeaponSkill(); SkillSystemGrow skillGrow = skillVO.GetSkillGrow(); float maxDistance = skillGrow.Range * SceneController.SPACE_ACCURACY_TO_CLIENT; Ray ray = new Ray(CameraManager.GetInstance().GetMainCamereComponent().GetPosition(), camDirAffectedByRecoil); RaycastHit hitInfo = new RaycastHit(); if (Physics.Raycast(ray, out hitInfo, maxDistance, LayerUtil.GetLayersIntersectWithSkillProjectile(true))) { return(new SkillTarget(hitInfo.collider.attachedRigidbody?.GetComponent <SpacecraftEntity>(), hitInfo.point)); } else { Vector3 skillReleasingDir = (ray.GetPoint(maxDistance) - m_MainPlayer.GetRootTransform().position).normalized; return(new SkillTarget(null, m_MainPlayer.GetRootTransform().position + skillReleasingDir * maxDistance)); } }
public PlayerSkillVO GetSkillByID(int skillID) { // 蓄力技能, 在蓄力结束后, 释放的是另外一个技能. 这个技能没有配置在船身上 // 实际上客户端存储技能实例的信息只是为了保存冷却时间. 这个逻辑检查留给服务器了 if (!m_SkillIDToSkill.ContainsKey(skillID)) { PlayerSkillVO newSkillVO = PlayerSkillVO.CreateSkillVO(skillID); if (newSkillVO != null) { m_SkillIDToSkill.Add(skillID, newSkillVO); return(m_SkillIDToSkill[skillID]); } else { return(null); } } else { return(m_SkillIDToSkill[skillID]); } }
/// <summary> /// 选中一个新的目标 /// 1. 与上一帧选中的目标不同 /// 2. 上一帧选中的目标已经锁定完成, 进行下一轮锁定 /// </summary> /// <returns>是否有新的目标</returns> private bool PickNewTarget(out SpacecraftEntity newTarget) { PlayerSkillVO skillVO = m_PlayerSkillProxy.GetCurrentWeaponSkill(); SkillSystemGrow skillGrow = skillVO.GetSkillGrow(); float maxDistance = skillGrow.Range * SceneController.SPACE_ACCURACY_TO_CLIENT; MainCameraComponent mainCam = CameraManager.GetInstance().GetMainCamereComponent(); Ray ray = new Ray(mainCam.GetPosition(), mainCam.GetForward()); RaycastHit hitInfo = new RaycastHit(); // UNDONE // 第一版: 使用屏幕中心射线作为目标选取射线. NOW // 第二版: 使用 Physics.BoxCast if (Physics.Raycast(ray, out hitInfo, maxDistance, LayerUtil.GetLayersIntersectWithSkillProjectile(true))) { SpacecraftEntity pickedTarget = hitInfo.collider.attachedRigidbody?.GetComponent <SpacecraftEntity>(); newTarget = pickedTarget; return(true); } else { newTarget = null; return(false); } }
/// <summary> /// 重建技能列表 /// </summary> public void RebuildSkillList() { RefreshShipSkills(); ShipProxy shipProxy = GameFacade.Instance.RetrieveProxy(ProxyName.ShipProxy) as ShipProxy; IShip currentShip = shipProxy.GetAppointWarShip(); if (currentShip != null) { if (m_ShipIDToSkillList == null) { m_ShipIDToSkillList = new Dictionary <uint, List <PlayerSkillVO> >(); } // 缓存飞船自带技能 if (!m_ShipIDToSkillList.ContainsKey(currentShip.GetTID())) { ISkill[] shipSkills = currentShip.GetSkillContainer().GetSkills(); List <PlayerSkillVO> listToCache = new List <PlayerSkillVO>(); for (int iSkill = 0; iSkill < shipSkills.Length; iSkill++) { int skillID = (int)shipSkills[iSkill].GetTID(); PlayerSkillVO newSkill = PlayerSkillVO.CreateSkillVO(skillID); if (newSkill != null) { listToCache.Add(newSkill); if (!m_SkillIDToSkill.ContainsKey(skillID)) { m_SkillIDToSkill.Add(skillID, newSkill); } } } m_ShipIDToSkillList.Add(currentShip.GetTID(), listToCache); } // 缓存武器技能 IWeaponContainer container = currentShip.GetWeaponContainer(); if (container != null) { IWeapon[] weapons = container.GetWeapons(); if (weapons != null) { for (int iWeapon = 0; iWeapon < weapons.Length; iWeapon++) { if (weapons[iWeapon] != null) { int skillID = (int)weapons[iWeapon].GetBaseConfig().SkillId; PlayerSkillVO newSkill = PlayerSkillVO.CreateSkillVO(skillID); if (newSkill != null) { if (!m_SkillIDToSkill.ContainsKey(skillID)) { m_SkillIDToSkill.Add(skillID, newSkill); } if (!m_ShipIDToSkillList[currentShip.GetTID()].Contains(newSkill)) { m_ShipIDToSkillList[currentShip.GetTID()].Add(newSkill); } } } } } } } }
/// <summary> /// 创建一个新的技能 /// </summary> /// <param name="skillID"></param> /// <returns></returns> private SkillBase CreateSkill(int skillID) { SkillCategory skillType = (SkillCategory)m_CfgSkillProxy.GetSkillGrow(skillID).CastWay; SkillBase newSkillInstance = null; switch (skillType) { case SkillCategory.Immediate: case SkillCategory.Immediate_Trigger: newSkillInstance = new SkillImmediate(); break; case SkillCategory.Immediate_MultiShot: newSkillInstance = new SkillImmediateMultiShot(); break; case SkillCategory.Chanting: case SkillCategory.Chanting_Trigger: newSkillInstance = new SkillChanting(); break; case SkillCategory.Charge: newSkillInstance = new SkillCharging(); break; case SkillCategory.AutoChannel: newSkillInstance = new SkillChannellingBeam(SkillChannellingBeam.ChannellingType.Auto); break; case SkillCategory.ManualChannel: newSkillInstance = new SkillChannellingBeam(SkillChannellingBeam.ChannellingType.Manual); break; case SkillCategory.RapidFire: newSkillInstance = new SkillRapidFire(); break; case SkillCategory.Immediate_MultiShot_MultiTarget: newSkillInstance = new SkillImmediateMultiShot_MultiTarget(); break; case SkillCategory.Immediate_MultiTarget: newSkillInstance = new SkillImmediate_MultiTarget(); break; case SkillCategory.SelectSkillByBuff: newSkillInstance = new SkillSelectByBuff(); break; case SkillCategory.MiningBeam: newSkillInstance = new SkillMiningBeam(SkillMiningBeam.ChannellingType.Manual); break; default: newSkillInstance = new SkillBase(); break; } if (newSkillInstance == null) { return(null); } // FIXME 技能, 重构这部分代码 // 消除动态分配, 弄一个池子 if (m_Property.IsMain()) { if (m_SkillProxy.GetSkillByID(skillID) != null) { newSkillInstance.Initialize(m_Property, m_SkillProxy.GetSkillByID(skillID), OnSkillStopped); } else { return(null); } } else { PlayerSkillVO skillVO = PlayerSkillVO.CreateSkillVO(skillID); if (skillVO != null) { newSkillInstance.Initialize(m_Property, skillVO, OnSkillStopped); } else { return(null); } } return(newSkillInstance); }