public Modification GetModification(ModType type) { // Define return value // ------------------- Modification mod; switch (type) { case ModType.HommingMotion: mod = new HommingMotionModifier(); (mod as HommingMotionModifier).SetDriftAngle(180); break; case ModType.Piercing: mod = new PiercingModifier(); break; case ModType.Speed: mod = new SpeedModifier(); break; case ModType.Gatling: mod = new GatlingModifier(); break; case ModType.ZickZack: mod = new ZickZackMotionModifier(); (mod as ZickZackMotionModifier).SetJitterStrength(10); break; case ModType.Shield: mod = new ShieldModifier(); break; case ModType.ChainHit: mod = new ChainHitModifier(); break; default: Debug.LogError("No modifier for " + type + " found!"); return(null); } // Return mod // ---------- return(mod); }
private void Shoot() { // Create projectile // ----------------- Projectile prjt = Instantiate(projectilePrefab, transform.position, transform.rotation).GetComponent <Projectile>(); // Flag projectile as player projectile // ------------------------------------ prjt.SetPlayerProjectile(true); // Add modifiers to projectile // --------------------------- foreach (Modification mod in m_modificationManager.GetModifications()) { // Skip (Player mod) // ----------------- if (mod.IsPlayerMod()) { continue; } // Write modifier to projectile // ---------------------------- prjt.GetModificationManager().AddModification(mod); if (mod is ChainHitModifier) { ChainHitModifier chm = new ChainHitModifier(); chm.SetModificationTarget(prjt); prjt.GetModificationManager().AddModification(chm); } if (mod is PiercingModifier) { PiercingModifier pm = new PiercingModifier(); pm.SetModificationTarget(this); prjt.GetModificationManager().AddModification(pm); } } // Disable player collision // ------------------------ Physics.IgnoreCollision(prjt.GetComponent <Collider>(), coll); }