public void PlayHitSound(int layer, Vector3 pos, E_ProjectileType inProjType) { AudioClip clip = null; if (inProjType == E_ProjectileType.Plasma) { clip = PlasmaSounds.HitDefault; } /* else if(inProjType == E_ProjectileType.Grenade) * { * switch (layer) * { * case 27: clip = GrenadeSounds.HitWater; break; * case 28: clip = GrenadeSounds.HitDefault; break; * case 29: clip = GrenadeSounds.HitMetal; break; * case 31: clip = GrenadeSounds.HitBlood; break; * default: clip = GrenadeSounds.HitDefault; break; * } * } * else*/ { switch (layer) { case 27: clip = ProjectileSounds.HitWater; break; case 28: clip = ProjectileSounds.HitDefault; break; case 29: clip = ProjectileSounds.HitMetal; break; case 31: clip = ProjectileSounds.HitBlood; break; default: clip = ProjectileSounds.HitDefault; break; } } //assert(clip); if (clip != null) { PlaySound(clip, pos); } }
public void SpawnProjectile(E_ProjectileType inProjeType, Vector3 inPos, Vector3 inDir, Projectile.InitSettings inSettings) { //Debug.Log("New SpawnProjectile " + inProjeType); // test if we have configured cache for this type of resource... if (CacheOfProjectiles.ContainsKey(inProjeType) == false) { Debug.LogError("ProjectileFactory: unknown type " + inProjeType); return; } // if we known this type but we don't have resource cache than go out, // this is corect situation... else if (CacheOfProjectiles[inProjeType] == null) { Debug.LogError("ProjectileFactory: For this type " + inProjeType + " we don't have resource"); return; } //check the projectile against the camera frustum - when it doesn't intersect it, do not bother spawning it on client if (uLink.Network.isServer == false && inSettings.Agent && inSettings.Agent.IsProxy) { Frustum.SetupCamera(GameCamera.Instance, 100); // variant A: faster but not accurate Frustum.E_Location loc = Frustum.LineInFrustumFast(inPos, inPos + inDir * GameCamera.Instance.MainCamera.farClipPlane); // variant B: accurate but slower // Frustum.E_Location loc = Frustum.LineInFrustum(GameCamera.Instance.MainCamera,inPos, inPos + inDir * GameCamera.Instance.MainCamera.far); if (loc == Frustum.E_Location.Outside) //do not spawn the projectile if it's not visible at all { // Debug.Log ("Projectile NOT SPAWNED, pos=" + inPos.ToString("F3") + ", dir=" + inDir.ToString("F3")); return; } // else // { // Debug.Log ("Projectile SPAWNED, pos=" + inPos.ToString("F3") + ", dir=" + inDir.ToString("F3")); // } } // Projectile proj = CacheOfProjectiles[inProjeType].Get(); if (proj == null) { Debug.LogError("ProjectileFactory: Can't create projectile for type " + inProjeType); return; } proj.ProjectileInit(inPos, inDir.normalized, inSettings); ActiveProjectiles.Add(proj); }
public void PlayHitEffect(GameObject parent, int layer, Vector3 pos, Vector3 dir, E_ProjectileType inProjectileType, bool localPlayer) { if (uLink.Network.isServer) { return; } if (localPlayer == false) { Frustum.SetupCamera(GameCamera.Instance, 30); Frustum.E_Location loc = Frustum.PointInFrustum(pos); if (loc == Frustum.E_Location.Outside) //do not spawn the projectile if it's not visible at all { return; } } if (inProjectileType == E_ProjectileType.Plasma) { if (PlasmaGunHit.Prefab != null) { //shift it a little to avoid static object penetration PlasmaGunHit.Play(pos + dir * 0.4f, dir); return; } } if (inProjectileType == E_ProjectileType.Rail) { if (PlasmaGunHit.Prefab != null) { PlasmaGunHit.Play(pos, dir); return; } } // default, old, behavior... if (HitEffects.ContainsKey(layer) == true) { HitEffects[layer].Play(pos, dir); } else { HitEffects[0].Play(pos, dir); } }
public void PlayHitEffect(GameObject parent, Vector3 pos, Vector3 dir, E_ProjectileType inProjectileType, bool localPlayer) { PlayHitEffect(parent, parent.layer, pos, dir, inProjectileType, localPlayer); }
public ProjectileCacheEx(String inName, E_ProjectileType inProjectileType, int inInitialCacheSize) : base(inName, inInitialCacheSize) { m_ProjectileType = inProjectileType; }
void RegisterProjectile(string inPrefabPath, E_ProjectileType inType, int inInitCount) { CacheOfProjectiles[inType] = new ProjectileCacheEx(inPrefabPath, inType, inInitCount); }