/// <summary> /// 在武器变化的时候, 更新当前实装的武器的准星信息 /// </summary> private void UpdateBattleWeapons(IComponentEvent entityEvent) { ItemOperateEvent itemEvent = entityEvent as ItemOperateEvent; Dictionary <ulong, BattleWeaponBase> newBattleWeapons = new Dictionary <ulong, BattleWeaponBase>(); for (int iWeapon = 0; iWeapon < BATTLE_WEAPON_COUNT; iWeapon++) { IWeapon weapon = m_SkillProxy.GetWeaponByIndex(iWeapon); if (weapon == null) { continue; } // 获取iWeapon对应武器的UID ulong uid = weapon.GetUID(); // 查看当前是否有这把武器的准星信息 if (m_Property.HaveBattleWeapon(uid)) { newBattleWeapons.Add(uid, m_Property.GetBattleWeapon(uid)); } else { BattleWeaponBase.BattleWeaponType weaponType = BattleWeaponBase.GetBattleWeaponTypeByReticle(weapon.GetConfig().Reticle); newBattleWeapons.Add(uid, CreateNewBattleWeapon(weaponType, weapon)); } } m_Property.ResetBattleWeapons(newBattleWeapons); }
/// <summary> /// 武器技能发射, 对武器造成影响. 计算新的弹道散布和后坐力 /// </summary> private void PostWeaponFire(IComponentEvent entityEvent) { // 临时代码. 只有准星类型是1的武器, 才扩散弹道 IWeapon weapon = m_SkillProxy.GetCurrentWeapon(); BattleWeaponBase currentBattleWeapon = m_SkillProxy.GetCurrentBattleWeapon(); currentBattleWeapon?.PostWeaponFire(); }
/// <summary> /// 武器技能结束 /// </summary> private void WeaponSkillFinished(IComponentEvent entityEvent) { WeaponSkillFinishedEvent finishEvent = entityEvent as WeaponSkillFinishedEvent; IWeapon weapon = m_SkillProxy.GetCurrentWeapon(); BattleWeaponBase currentBattleWeapon = m_SkillProxy.GetCurrentBattleWeapon(); currentBattleWeapon?.OnWeaponSkillFinished(finishEvent.Success); }
private void OnWeaponToggled(IComponentEvent entityEvent) { IWeapon weapon = m_SkillProxy.GetCurrentWeapon(); BattleWeaponBase battleWeapon = m_Property.GetBattleWeapon(weapon.GetUID()); if (battleWeapon != null) { battleWeapon.OnToggledToMainWeapon(); } }
public override void OnDrawGizmo() { BattleWeaponBase battleWeapon = m_SkillProxy.GetCurrentBattleWeapon(); BattleWeapon_Missile missile = battleWeapon as BattleWeapon_Missile; if (missile == null) { return; } MainCameraComponent mainCam = CameraManager.GetInstance().GetMainCamereComponent(); Gizmos.color = Color.red; Gizmos.matrix = mainCam.transform.localToWorldMatrix; Gizmos.DrawFrustum(Vector3.zero, missile.m_Gizmo_FOV, 10, 0.5f, 1); Gizmos.matrix = Matrix4x4.identity; }
private void OnWeaponOperation(IComponentEvent entityEvent) { SkillHotkey skillHotkey = entityEvent as SkillHotkey; IWeapon weapon = m_SkillProxy.GetCurrentWeapon(); if (weapon == null) { return; } // 获取iWeapon对应武器的UID ulong uid = weapon.GetUID(); BattleWeaponBase battleWeapon = m_Property.GetBattleWeapon(uid); if (battleWeapon != null) { battleWeapon.WeaponOperation(skillHotkey); } }