public SmartBulletHoleGroup() { Tag = "Everything"; Material = null; PhysicMaterial = null; BulletHole = null; }
public SmartBulletHoleGroup(string t, Material m, PhysicMaterial pm, BulletHolePool bh) { Tag = t; Material = m; PhysicMaterial = pm; BulletHole = bh; }
// Use this for initialization void Start() { //计算开火的频率 if (RateOfFire != 0) { ActualROF = 1.0f / RateOfFire; } else { ActualROF = 0.01f; } //初始化当前准星大小 CurrentCrosshairSize = StartingCrosshairSize; //重置计时器 FireTimer = 0.0f; //设置换弹状态 m_IsReloading = false; //初始化当前总弹药量 m_CurrentTotalAmmo = TotalAmmo; ////开始时先执行一次换弹 //Reload(); //初始化武器的当前弹药量 m_CurrentAmmo = AmmoCapacity; //确保设置了射线起点 if (RaycastStartSpot == null) { if (Type == WeaponType.Raycast) { Debug.LogWarning("Please set the RaycastStartSpot..."); } RaycastStartSpot = gameObject.transform; } //设置武器的射击起点 m_CurrentShootPoint = RaycastStartSpot; //如果使用瞄准镜,设置瞄准镜的状态 if (UseMirror) { //如果没有设置开静后的射击位置,默认为不开镜的射击位置 if (MirrorRaycastingPoint == null) { Debug.LogWarning("Please set the MirrorRaycastingPoint..."); MirrorRaycastingPoint = RaycastStartSpot; } //如果使用了瞄准镜,就设置瞄准镜的状态 if (UseMirrorCamera) { if (MirrorCamera == null) { Debug.LogWarning("Please set the MirrorCamera..."); } else { //设置瞄准镜状态 MirrorCamera.SetActive(false); } } //初始化开镜状态 m_IsUsingMirror = false; } //初始化武器的初始位置 m_OriginalPosition = this.transform.localPosition; m_OriginalRotation = this.transform.localRotation; //确保设置了枪口火光的产生位置 if (MuzzleEffectsPosition == null) { Debug.LogWarning("Please set the MuzzleEffectsPosition..."); MuzzleEffectsPosition = gameObject.transform; } //确保设置了抛射物抛射的起始位置 if (ProjectileSpawnSpot == null) { Debug.LogWarning("Please set the ProjectileSpawnSpot..."); ProjectileSpawnSpot = gameObject.transform; } //确保设置了武器Model if (WeaponModel == null) { Debug.LogWarning("Please set the WeaponModel..."); WeaponModel = gameObject; } //确保设置了绘制准星的贴图 if (CrosshairTexture == null) { Debug.LogWarning("Please set the CrosshairTexture..."); CrosshairTexture = new Texture2D(0, 0); } //初始化弹孔池list for (int i = 0; i < BulletHolePoolNames.Count; i++) { GameObject g = GameObject.Find(BulletHolePoolNames[i]); if (g != null && g.GetComponent <BulletHolePool>() != null) { BulletHoleGroups[i].BulletHole = g.GetComponent <BulletHolePool>(); } else { Debug.LogWarning("Bullet Hole Pool does not exist or does not have a BulletHolePool component. Please assign GameObjects in the inspector that have the BulletHolePool component."); } } //初始化默认弹孔池list for (int i = 0; i < DefaultBulletHolePoolNames.Count; i++) { GameObject g = GameObject.Find(DefaultBulletHolePoolNames[i]); BulletHolePool bulletHolePool = g.GetComponent <BulletHolePool>(); if (bulletHolePool != null) { DefaultBulletHoles[i] = g.GetComponent <BulletHolePool>(); } else { Debug.LogWarning("Default Bullet Hole Pool does not have a BulletHolePool component. Please assign GameObjects in the inspector that have the BulletHolePool component."); } } //初始化后坐力参数 m_RecoilParam = new Hashtable { { "shootInterval", ActualROF }, { "maxAngle", RecoilMaxAngle } }; }