public bool CheckEquipmentAmmunition() { if (!(m_ActiveableEquipment is IWeapon)) { return(true); } IWeapon weapon = m_ActiveableEquipment as IWeapon; PEGun gun = weapon as PEGun; if (null != gun) { if (gun.m_AmmoType == AmmoType.Bullet) { return(null != m_Package && m_Package.GetItemCount(gun.curItemID) > 0); } return(gun.magazineValue > PETools.PEMath.Epsilon || Entity.GetAttribute(AttribType.Energy) > PETools.PEMath.Epsilon); } PEBow bow = weapon as PEBow; if (null != bow) { return(null != m_Package && m_Package.GetItemCount(bow.curItemID) > 0); } return(true); }
public void CopyTo(PEGun target) { target.m_AimAttr.m_AimTrans = m_AimTrans; target.m_AimAttr.m_AimPointType = m_AimPointType; target.m_AimAttr.m_FireStability = m_FireStability; target.m_AimAttr.m_AccuracyDiffusionRate = m_AccuracyDiffusionRate; target.m_AimAttr.m_CenterUpDisPerShoot = m_CenterUpDisPerShoot; target.m_ChargeEffectGo = m_ChargeEffectGo; target.m_ShellCaseEffectID = m_ShellCaseEffectID; target.m_ShootMode = m_ShootMode; target.m_AmmoType = m_AmmoType; target.m_AmmoItemIDList = m_AmmoItemIDList; target.m_ChargeEnergySpeed = m_ChargeEnergySpeed; target.m_RechargeEnergySpeed = m_RechargeEnergySpeed; target.m_RechargeDelay = m_RechargeDelay; target.m_ChargeTime = m_ChargeTime; target.m_EnergyPerShoot = m_EnergyPerShoot; target.m_SkillIDList = m_SkillIDList; target.m_FireRate = m_FireRate; target.m_ChargeSoundID = m_ChargeSoundID; target.m_ChargeLevelUpSoundID = m_ChargeLevelUpSoundID; target.m_DryFireSoundID = m_DryFireSoundID; target.m_ShootSoundID = m_ShootSoundID; target.m_ChargeLevelUpEffectID = m_ChargeLevelUpEffectID; target.m_AttackMode = new AttackMode[m_AttackMode.Length]; System.Array.Copy(m_AttackMode, target.m_AttackMode, m_AttackMode.Length); }
void SetGun(PEEquipment gun) { m_Gun = gun as PEGun; m_GunFire.gun = m_Gun; m_GunHold.aimAbleEquip = m_Gun; m_GunReload.gun = m_Gun; m_GunMelee.gun = m_Gun; m_ActiveableEquipment = m_Gun; }
public bool WeaponCanUse(IWeapon weapon) { if (!isMainPlayer && null != m_NPC && !m_NPC.HasConsume) { return(true); } PeSword sword = weapon as PeSword; if (null != sword) { return(true); } PEGun gun = weapon as PEGun; if (null != gun) { if (m_GunFire.m_IgnoreItem) { return(true); } if (gun.m_AmmoType == AmmoType.Bullet) { return(gun.durability > PETools.PEMath.Epsilon && (gun.magazineValue > PETools.PEMath.Epsilon || null == m_Package || m_Package.GetItemCount(gun.curItemID) > 0)); } return(gun.durability > PETools.PEMath.Epsilon && (gun.magazineValue > PETools.PEMath.Epsilon || Entity.GetAttribute(AttribType.Energy) > PETools.PEMath.Epsilon)); } PEBow bow = weapon as PEBow; if (null != bow) { if (m_BowShoot.m_IgnoreItem) { return(true); } return(bow.durability > PETools.PEMath.Epsilon && null == m_Package || m_Package.GetItemCount(bow.curItemID) > 0); } return(true); }
public void CopyTo(PEGun target) { target.m_RemoveEndAction = m_RemoveEndAction; target.m_HandChangeAttr = m_HandChangeAttr; target.m_AimAttr.m_AccuracyMin = m_AccuracyMin; target.m_AimAttr.m_AccuracyMax = m_AccuracyMax; target.m_AimAttr.m_AccuracyPeriod = m_AccuracyPeriod; target.m_AimAttr.m_AccuracyShrinkSpeed = m_AccuracyShrinkSpeed; target.m_AimAttr.m_CenterUpDisMax = m_CenterUpDisMax; target.m_AimAttr.m_CenterUpShrinkSpeed = m_CenterUpShrinkSpeed; target.m_ReloadAnim = m_ReloadAnim; target.m_MagazineObj = m_MagazineObj; target.m_MagazinePos = m_MagazinePos; target.m_MagazineEffectID = m_MagazineEffectID; target.m_Magazine = new Magazine(); target.m_Magazine.m_Size = m_MagazineSize; target.m_Magazine.m_Value = m_MagazineSize; target.m_ReloadSoundID = m_ReloadSoundID; target.showOnVehicle = showOnVehicle; }
/// <summary> /// lz-2017.12.29 为了优化新枪第一枪特效加载卡顿,因此在装备枪的时候就预加载粒子特效和音效 /// </summary> /// <param name="equipment"></param> void PreLoadEquipmentEffect(PEEquipment equipment) { if (equipment is PEGun) { PEGun gun = equipment as PEGun; SkData skData = null; //音效 SkData.s_SkillTbl.TryGetValue(gun.m_ShootSoundID, out skData); if (skData != null && skData._effMainOneTime != null && skData._effMainOneTime._seId > 0) { int soundEffectID = skData._effMainOneTime._seId; SoundAsset.SESoundBuff buff = SoundAsset.SESoundBuff.GetSESoundData(soundEffectID); if (buff != null && AudioManager.instance != null) { AudioManager.instance.GetAudioClip(buff.mName); } } skData = null; //粒子特效 SkData.s_SkillTbl.TryGetValue(gun.GetSkillID(0), out skData); if (skData != null && skData._effMainOneTime != null && skData._effMainOneTime._effId != null && skData._effMainOneTime._effId.Length > 0) { int[] effectArray = skData._effMainOneTime._effId; for (int i = 0; i < effectArray.Length; i++) { int id = effectArray[i]; if (id > 0) { Effect.EffectData data = Effect.EffectData.GetEffCastData(id); if (data != null && !string.IsNullOrEmpty(data.m_path) && Effect.EffectBuilder.Instance != null) { Effect.EffectBuilder.Instance.GetEffect(data.m_path); } } } } } }
void AddWeaponInfo(ItemProto itemProto, GameObject obj) { AttackMode attackMode; switch (m_Attribute.m_Type) { case ECreation.Sword: case ECreation.SwordLarge: case ECreation.SwordDouble: PeSword[] swords = obj.GetComponentsInChildren <PeSword>(true); if (null != swords && swords.Length > 0) { PeSword sword = swords[0]; attackMode = new AttackMode(); itemProto.weaponInfo = new ItemProto.WeaponInfo(); itemProto.weaponInfo.attackModes = new AttackMode[1]; itemProto.weaponInfo.attackModes[0] = attackMode; attackMode.type = sword.m_AttackMode[0].type; attackMode.minRange = sword.m_AttackMode[0].minRange; attackMode.maxRange = sword.m_AttackMode[0].maxRange; attackMode.minSwitchRange = sword.m_AttackMode[0].minSwitchRange; attackMode.maxSwitchRange = sword.m_AttackMode[0].maxSwitchRange; attackMode.minAngle = sword.m_AttackMode[0].minAngle; attackMode.maxAngle = sword.m_AttackMode[0].maxAngle; attackMode.frequency = sword.m_AttackMode[0].frequency; attackMode.damage = itemProto.propertyList.GetProperty(Pathea.AttribType.Atk); } break; case ECreation.Bow: PEBow[] bows = obj.GetComponentsInChildren <PEBow>(true); if (null != bows && bows.Length > 0) { PEBow bow = bows[0]; attackMode = new AttackMode(); itemProto.weaponInfo = new ItemProto.WeaponInfo(); itemProto.weaponInfo.attackModes = new AttackMode[1]; itemProto.weaponInfo.attackModes[0] = attackMode; attackMode.type = bow.m_AttackMode[0].type; attackMode.minRange = bow.m_AttackMode[0].minRange; attackMode.maxRange = bow.m_AttackMode[0].maxRange; attackMode.minSwitchRange = bow.m_AttackMode[0].minSwitchRange; attackMode.maxSwitchRange = bow.m_AttackMode[0].maxSwitchRange; attackMode.minAngle = bow.m_AttackMode[0].minAngle; attackMode.maxAngle = bow.m_AttackMode[0].maxAngle; attackMode.frequency = bow.m_AttackMode[0].frequency; attackMode.damage = itemProto.propertyList.GetProperty(Pathea.AttribType.Atk); itemProto.weaponInfo.costItem = bow.m_CostItemID[0]; } break; case ECreation.HandGun: case ECreation.Rifle: PEGun[] guns = obj.GetComponentsInChildren <PEGun>(true); if (null != guns && guns.Length > 0) { PEGun gun = guns[0]; attackMode = new AttackMode(); itemProto.weaponInfo = new ItemProto.WeaponInfo(); itemProto.weaponInfo.attackModes = new AttackMode[1]; itemProto.weaponInfo.attackModes[0] = attackMode; attackMode.type = gun.m_AttackMode[0].type; attackMode.minRange = gun.m_AttackMode[0].minRange; attackMode.maxRange = gun.m_AttackMode[0].maxRange; attackMode.minSwitchRange = gun.m_AttackMode[0].minSwitchRange; attackMode.maxSwitchRange = gun.m_AttackMode[0].maxSwitchRange; attackMode.minAngle = gun.m_AttackMode[0].minAngle; attackMode.maxAngle = gun.m_AttackMode[0].maxAngle; attackMode.frequency = gun.m_AttackMode[0].frequency; attackMode.damage = itemProto.propertyList.GetProperty(Pathea.AttribType.Atk); itemProto.weaponInfo.costItem = gun.m_AmmoItemIDList.Length > 0 ? gun.m_AmmoItemIDList[0] : 0; itemProto.weaponInfo.useEnergry = gun.m_AmmoType == AmmoType.Energy; itemProto.weaponInfo.costPerShoot = itemProto.weaponInfo.useEnergry ? (int)gun.m_EnergyPerShoot : 1; } break; } }
private void BuildCreation() { #region Root Transform // [VCCase] - Set creation root Transform if (m_Attribute.m_Type == ECreation.Sword) { Transform pivot = null; foreach (VCComponentData cdata in m_IsoData.m_Components) { if (cdata.m_Type == EVCComponent.cpSwordHilt || cdata.m_Type == EVCComponent.cpLgSwordHilt) { pivot = cdata.m_Entity.transform; break; } } m_Root.transform.localRotation = Quaternion.Inverse(pivot.rotation); m_Root.transform.Rotate(Vector3.up, -90, Space.World); m_Root.transform.Rotate(Vector3.right, 90, Space.World); m_Root.transform.localPosition = -pivot.position; } else if (m_Attribute.m_Type == ECreation.SwordLarge) { Transform pivot = null; foreach (VCComponentData cdata in m_IsoData.m_Components) { if (cdata.m_Type == EVCComponent.cpLgSwordHilt) { pivot = cdata.m_Entity.transform; break; } } m_Root.transform.localRotation = Quaternion.Inverse(pivot.rotation); m_Root.transform.Rotate(Vector3.up, -90, Space.World); m_Root.transform.Rotate(Vector3.right, 90, Space.World); m_Root.transform.localPosition = -pivot.position; } else if (m_Attribute.m_Type == ECreation.SwordDouble) { Transform pivot = null; int cdcnt = 0; foreach (VCComponentData cdata in m_IsoData.m_Components) { if (cdata.m_Type == EVCComponent.cpDbSwordHilt && (cdata as VCFixedHandPartData).m_LeftHand) { pivot = cdata.m_Entity.transform; //SingleHandSword Transform go = cdata.m_Entity.transform.FindChild("SingleHandSword");//VCConfig.s_Parts[cdata.m_ComponentId].m_ResObj go.gameObject.name = "SingleHandSwordL"; m_RootL.transform.localRotation = Quaternion.Inverse(pivot.rotation); m_RootL.transform.Rotate(Vector3.up, -90, Space.World); m_RootL.transform.Rotate(Vector3.right, 90, Space.World); m_RootL.transform.Rotate(Vector3.up, 180, Space.World); m_RootL.transform.Rotate(Vector3.forward, 180, Space.World); m_RootL.transform.localPosition = -pivot.position; cdcnt++; } if (cdata.m_Type == EVCComponent.cpDbSwordHilt && !(cdata as VCFixedHandPartData).m_LeftHand) { pivot = cdata.m_Entity.transform; Transform go = cdata.m_Entity.transform.FindChild("SingleHandSword"); go.gameObject.name = "SingleHandSwordR"; //m_Root.transform.localRotation = Quaternion.Inverse(pivot.rotation); //m_Root.transform.Rotate(Vector3.up, -90, Space.World); //m_Root.transform.Rotate(Vector3.right, 90, Space.World); //m_Root.transform.localPosition = pivot.position; m_Root.transform.localRotation = Quaternion.Inverse(pivot.rotation); m_Root.transform.Rotate(Vector3.up, -90, Space.World); m_Root.transform.Rotate(Vector3.right, 90, Space.World); m_Root.transform.Rotate(Vector3.up, 180, Space.World); m_Root.transform.Rotate(Vector3.forward, 180, Space.World); m_Root.transform.localPosition = -pivot.position; cdcnt++; } if (cdcnt == 2) { break; } } } else if (m_Attribute.m_Type == ECreation.Bow) { Transform pivot = null; foreach (VCComponentData cdata in m_IsoData.m_Components) { if (cdata.m_Type == EVCComponent.cpBowGrip) { pivot = cdata.m_Entity.transform; break; } } AlignPivotInChild(m_Root.transform, pivot); } else if (m_Attribute.m_Type == ECreation.Axe) { Transform pivot = null; foreach (VCComponentData cdata in m_IsoData.m_Components) { if (cdata.m_Type == EVCComponent.cpAxeHilt) { pivot = cdata.m_Entity.transform; break; } } m_Root.transform.localRotation = Quaternion.Inverse(pivot.rotation); m_Root.transform.Rotate(Vector3.up, -90, Space.World); m_Root.transform.Rotate(Vector3.right, 90, Space.World); m_Root.transform.localPosition = -pivot.position; } else if (m_Attribute.m_Type == ECreation.Shield) { Transform pivot = null; foreach (VCComponentData cdata in m_IsoData.m_Components) { if (cdata.m_Type == EVCComponent.cpShieldHandle) { pivot = cdata.m_Entity.GetComponent <VCPShieldHandle>().m_PivotPoint; break; } } m_Root.transform.localRotation = Quaternion.Inverse(pivot.rotation); m_Root.transform.Rotate(Vector3.right, 90, Space.World); m_Root.transform.localPosition = -pivot.position; } else if (m_Attribute.m_Type == ECreation.HandGun || m_Attribute.m_Type == ECreation.Rifle) { Transform pivot = null; foreach (VCComponentData cdata in m_IsoData.m_Components) { if (cdata.m_Type == EVCComponent.cpGunHandle) { pivot = cdata.m_Entity.GetComponent <VCPGunHandle>().m_FirstHandPoint; break; } } m_Root.transform.localRotation = Quaternion.Inverse(pivot.rotation); m_Root.transform.Rotate(Vector3.up, -90, Space.World); m_Root.transform.Rotate(Vector3.right, 90, Space.World); m_Root.transform.localPosition = -pivot.position; } else if (m_Attribute.m_Type == ECreation.Vehicle) { Vector3 pivot = m_Attribute.m_CenterOfMass; float sum_y = 0; int wheel_cnt = 0; foreach (VCComponentData cdata in m_IsoData.m_Components) { if (cdata.m_Type == EVCComponent.cpVehicleWheel) { sum_y += cdata.m_Entity.GetComponent <VCEComponentTool>().m_DrawPivot.position.y; wheel_cnt++; } } pivot.y = sum_y / (float)wheel_cnt - 0.1f; m_Root.transform.localRotation = Quaternion.identity; m_Root.transform.localPosition = -pivot; } else if (m_Attribute.m_Type == ECreation.Aircraft) { Vector3 pivot = m_Attribute.m_CenterOfMass; pivot.y = 0; m_Root.transform.localRotation = Quaternion.identity; m_Root.transform.localPosition = -pivot; } else if (m_Attribute.m_Type == ECreation.Boat) { Vector3 pivot = m_Attribute.m_CenterOfMass; pivot.y = 0; m_Root.transform.localRotation = Quaternion.identity; m_Root.transform.localPosition = -pivot; } else if (m_Attribute.m_Type == ECreation.SimpleObject) { VCComponentData pivotCmpt = null; foreach (VCComponentData cdata in m_IsoData.m_Components) { if (cdata.m_Type == EVCComponent.cpPivot) { pivotCmpt = cdata; break; } } Vector3 pivot; if (pivotCmpt != null) { pivot = pivotCmpt.m_Position; } else { pivot = m_Attribute.m_CenterOfMass; } pivot.y = 0; m_Root.transform.localRotation = Quaternion.identity; m_Root.transform.localPosition = -pivot; } else if (m_Attribute.m_Type == ECreation.Robot) { Vector3 pivot = m_Attribute.m_CenterOfMass; pivot.y = 0; m_Root.transform.localRotation = Quaternion.identity; m_Root.transform.localPosition = -pivot; } else if (m_Attribute.m_Type == ECreation.AITurret) { Vector3 pivot = m_Attribute.m_CenterOfMass; pivot.y = 0; m_Root.transform.localRotation = Quaternion.identity; m_Root.transform.localPosition = -pivot; } else if (m_Attribute.m_Type == ECreation.ArmorHead || m_Attribute.m_Type == ECreation.ArmorBody || m_Attribute.m_Type == ECreation.ArmorArmAndLeg || m_Attribute.m_Type == ECreation.ArmorHandAndFoot || m_Attribute.m_Type == ECreation.ArmorDecoration ) { Vector3 pivot = m_Attribute.m_CenterOfMass; pivot.y = 0; m_Root.transform.localRotation = Quaternion.identity; m_Root.transform.localPosition = -pivot; } #endregion #region Top Script // [VCCase] - Create top scripts creationController = m_Prefab.AddComponent <CreationController>(); creationController.enabled = false; creationController.Init( m_PartGroup.transform, m_MeshGroup.transform, m_DecalGroup.transform, m_EffectGroup.transform, this); switch (m_Attribute.m_Type) { case ECreation.Sword: { PeSword sword = m_Prefab.AddComponent <PeSword>(); VCPSwordHilt properties = FindComponent <VCPSwordHilt>(EVCComponent.cpSwordHilt); properties.CopyTo(sword, this); float weight = creationController.creationData.m_Attribute.m_Weight; sword.m_AnimSpeed = VCUtility.GetSwordAnimSpeed(weight); //set attacktrigger height if (properties.Attacktrigger != null) { for (int i = 0; i < properties.Attacktrigger.attackParts.Length; i++) { properties.Attacktrigger.attackParts[i].capsule.heigh = creationController.creationData.m_Attribute.m_AtkHeight.x; properties.Attacktrigger.attackParts[i].capsule.offset.y -= creationController.creationData.m_Attribute.m_AtkHeight.z; } } } break; case ECreation.SwordLarge: { PeSword sword = m_Prefab.AddComponent <PeSword>(); VCPSwordHilt properties = FindComponent <VCPSwordHilt>(EVCComponent.cpLgSwordHilt); properties.CopyTo(sword, this); float weight = creationController.creationData.m_Attribute.m_Weight; sword.m_AnimSpeed = VCUtility.GetSwordAnimSpeed(weight); //set attacktrigger height if (properties.Attacktrigger != null) { for (int i = 0; i < properties.Attacktrigger.attackParts.Length; i++) { properties.Attacktrigger.attackParts[i].capsule.heigh = creationController.creationData.m_Attribute.m_AtkHeight.x; properties.Attacktrigger.attackParts[i].capsule.offset.y -= creationController.creationData.m_Attribute.m_AtkHeight.z; } } } break; case ECreation.SwordDouble: { PETwoHandWeapon sword = m_Prefab.AddComponent <PETwoHandWeapon>(); VCPSwordHilt properties = FindComponent <VCPSwordHilt>(EVCComponent.cpDbSwordHilt); properties.CopyTo(sword, this); sword.m_LHandWeapon = m_RootL; float weight = creationController.creationData.m_Attribute.m_Weight; sword.m_AnimSpeed = VCUtility.GetSwordAnimSpeed(weight); //set attacktrigger height int cnt = 0; foreach (VCComponentData cdata in m_IsoData.m_Components) { if (cdata.m_Type == EVCComponent.cpDbSwordHilt && (cdata as VCFixedHandPartData).m_LeftHand && properties.Attacktrigger != null) { cnt++; VCPSwordHilt hiltL = cdata.m_Entity.GetComponent <VCPSwordHilt>(); if (hiltL == null) { continue; } for (int i = 0; i < properties.Attacktrigger.attackParts.Length; i++) { hiltL.Attacktrigger.attackParts[i].capsule.heigh = creationController.creationData.m_Attribute.m_AtkHeight.x; hiltL.Attacktrigger.attackParts[i].capsule.offset.y -= creationController.creationData.m_Attribute.m_AtkHeight.z; } } if (cdata.m_Type == EVCComponent.cpDbSwordHilt && !(cdata as VCFixedHandPartData).m_LeftHand && properties.Attacktrigger != null) { cnt++; VCPSwordHilt hiltR = cdata.m_Entity.GetComponent <VCPSwordHilt>(); if (hiltR == null) { continue; } for (int i = 0; i < properties.Attacktrigger.attackParts.Length; i++) { hiltR.Attacktrigger.attackParts[i].capsule.heigh = creationController.creationData.m_Attribute.m_AtkHeight.y; hiltR.Attacktrigger.attackParts[i].capsule.offset.y -= creationController.creationData.m_Attribute.m_AtkHeight.w; } } if (cnt == 2) { break; } } } break; case ECreation.Bow: { PEBow bow = m_Prefab.AddComponent <PEBow>(); VCPBowGrip bowProperties = FindComponent <VCPBowGrip>(EVCComponent.cpBowGrip); bowProperties.CopyTo(bow, this); } break; case ECreation.Axe: { PEAxe axe = m_Prefab.AddComponent <PEAxe>(); VCPAxeHilt axeProperties = FindComponent <VCPAxeHilt>(EVCComponent.cpAxeHilt); axeProperties.CopyTo(axe, this); float weight = creationController.creationData.m_Attribute.m_Weight; axe.m_AnimSpeed = VCUtility.GetAxeAnimSpeed(weight); } break; case ECreation.Shield: { PESheild sheild = m_Prefab.AddComponent <PESheild>(); sheild.showOnVehicle = false; } break; case ECreation.Rifle: case ECreation.HandGun: { PEGun gun = m_Prefab.AddComponent <PEGun>(); VCPGunHandle handleProperties = FindComponent <VCPGunHandle>(EVCComponent.cpGunHandle); VCPGunMuzzle muzzleProperties = FindComponent <VCPGunMuzzle>(EVCComponent.cpGunMuzzle); handleProperties.CopyTo(gun); muzzleProperties.CopyTo(gun); } break; case ECreation.Vehicle: { VCParticlePlayer pp = m_Prefab.AddComponent <VCParticlePlayer>(); pp.FunctionTag = VCParticlePlayer.ftExplode; pp.LocalPosition = creationController.bounds.center; break; } case ECreation.Aircraft: { VCParticlePlayer pp = m_Prefab.AddComponent <VCParticlePlayer>(); pp.FunctionTag = VCParticlePlayer.ftExplode; pp.LocalPosition = creationController.bounds.center; break; } case ECreation.Boat: { VCParticlePlayer pp = m_Prefab.AddComponent <VCParticlePlayer>(); pp.FunctionTag = VCParticlePlayer.ftExplode; pp.LocalPosition = creationController.bounds.center; break; } case ECreation.Robot: { VCParticlePlayer pp = m_Prefab.AddComponent <VCParticlePlayer>(); pp.FunctionTag = VCParticlePlayer.ftExplode; pp.LocalPosition = creationController.bounds.center; break; } case ECreation.AITurret: { VCParticlePlayer pp = m_Prefab.AddComponent <VCParticlePlayer>(); pp.FunctionTag = VCParticlePlayer.ftExplode; pp.LocalPosition = creationController.bounds.center; break; } case ECreation.SimpleObject: break; case ECreation.ArmorHead: case ECreation.ArmorBody: case ECreation.ArmorArmAndLeg: case ECreation.ArmorHandAndFoot: case ECreation.ArmorDecoration: break; default: break; } #endregion }