private static void AddLightningWave(GameObject wavePrefab) { ManipulatorProjectileWaveImpact lightningWaveChild = wavePrefab.GetComponentInChildren <ManipulatorProjectileWaveImpact>(); lightningWaveChild.childrenProjectilePrefab = CreateLightningWaveExplosion(StatValues.lightningBlastRadius, StatValues.lightningBlastLifetime); lightningWaveChild.fireChildren = true; lightningWaveChild.childrenCount = 1; lightningWaveChild.impactEffect = Resources.Load <GameObject>("Prefabs/Effects/ImpactEffects/OmniExplosionVFXQuick"); lightningWaveChild.childrenDamageCoefficient = 1f; }
private static GameObject CreateNewWave(string waveName, DamageType damageType, string ghostPrefabName, Vector3 waveCoreSize, Vector3 waveOuterSize, Vector3 rotation, bool useIceDebuff) { //clone fire projectile, fix size (original size is 0.05, 0.05, 1) GameObject newWavePrefab = CloneProjectilePrefab("Fireball", waveName); newWavePrefab.transform.localScale = new Vector3(1f, 1f, 1f); newWavePrefab.transform.localRotation = Quaternion.Euler(StatValues.waveRotation1); //create 'container' to enable local rotation of the wave GameObject transformBox = new GameObject("TransformBox"); transformBox.transform.parent = newWavePrefab.transform; transformBox.layer = 14; //set ghost, damage and owner ProjectileController newWaveController = newWavePrefab.GetComponent <ProjectileController>(); newWaveController.ghostPrefab = CreateGhostPrefab(ghostPrefabName); newWaveController.GetComponent <ProjectileDamage>().damageType = damageType; newWaveController.owner = Survivors.Manipulator.characterPrefab; newWaveController.procCoefficient = StatValues.waveProcCoefficient; TeamFilter newWaveTeam = newWavePrefab.GetComponent <TeamFilter>(); newWaveTeam.defaultTeam = TeamIndex.Player; //replace single target impact with custom impact script UnityEngine.Object.Destroy(newWavePrefab.GetComponent <ProjectileSingleTargetImpact>()); ManipulatorProjectileWaveImpact newWaveImpact = newWavePrefab.AddComponent <ManipulatorProjectileWaveImpact>(); newWaveImpact.destroyOnWorld = true; newWaveImpact.destroyWhenNotAlive = true; newWaveImpact.useIceDebuff = useIceDebuff; ProjectileSimple newWaveSimple = newWavePrefab.GetComponent <ProjectileSimple>(); newWaveSimple.lifetime = StatValues.waveLifetime; //newWaveSimple.velocity = waveVelocity; newWaveSimple.desiredForwardSpeed = StatValues.waveSpeed; //replace sphere with core box (smaller middle, collides with both terrain and enemies) //UnityEngine.Object.Destroy(newWavePrefab.GetComponent<SphereCollider>()); BoxCollider newWaveBox = newWavePrefab.AddComponent <BoxCollider>(); newWaveBox.transform.parent = transformBox.transform; newWaveBox.size = waveCoreSize; //add outer box collider (collides with enemies only) GameObject childObject = new GameObject("OuterBox"); childObject.layer = 14; childObject.transform.parent = transformBox.transform; ManipulatorProjectileChildCollisionDetection childScript = childObject.AddComponent <ManipulatorProjectileChildCollisionDetection>(); childScript.AddBoxCollider(waveOuterSize, childObject); //set local rotation Quaternion quaternion = Quaternion.Euler(rotation); transformBox.transform.localRotation = quaternion; //return result return(newWavePrefab); }