void Start() { GameObject startTObj = new GameObject(); startT = startTObj.transform; startT.position = transform.position; startT.rotation = transform.rotation; startT.localScale = Vector3.one * 100; instance = this; trans = transform; trans.parent = startT; isNewBeta = false; if (ShooterDriver.parkingMode == 2 && ShooterDriver.useParking) { ptype = ProjectileType.E; isNewBeta = true; } currentMedium = new List <MediumInfo>(); MacroModeGUI.NewLine(transform.position, null, 0); graphic = (Instantiate(((SelectZoomLevelGUI.selectedButton == 0 || ShooterDriver.useParking) ? particlePrefabsSmall[(int)ptype] : particlePrefabs[(int)ptype]), transform.position, transform.rotation) as GameObject).transform; graphic.parent = transform; theSpeed = speeds[(int)ptype]; curEnergy = energies[(int)ptype]; if (ptype == ProjectileType.G) { curEnergy *= 1f + (Random.value - 0.5f) * 0.7f; } energyLossPerDensityPerUnit = energyLosses[(int)ptype]; originalEnergy = curEnergy; //cameraInstance = Instantiate(cameraPrefab1, transform.position, Quaternion.identity) as GameObject; }
private Transform SpawnProjectile(Vector2 velocity) { Vector3 spawnLocation = transform.position + transform.rotation * (Vector3)spawnOffset; float rotationFromProjectileVelocity = fixRotation ? 0 : velocity.y; Transform projectile = Instantiate(projectilePrefab, spawnLocation, Quaternion.Euler(0, 0, rotationFromProjectileVelocity - angleWhenUpright)); projectilesFired.Add(projectile); Rigidbody2D rb = projectile.GetComponent <Rigidbody2D>(); ProjectileDriver pd = projectile.GetComponent <ProjectileDriver>(); if (rb != null) { rb.velocity = transform.rotation * (Vector3)Mathv.Pol2Car(velocity); } if (pd != null) { pd.sourceObject = transform; if (input != null) { pd.playerId = input.playerId; } } return(projectile); }
public void OnTriggerEnter2D(Collider2D c) { ProjectileDriver pd = c.GetComponent <ProjectileDriver>(); if (pd != null && hp != null && pd.playerId != playerId) { // Play some sounds if (pd.damage < 50) { GameManager.GetInstance().soundManager.PlaySound("hit_rocket", 1f, false); } else { GameManager.GetInstance().soundManager.PlaySound("hit_melee", 1f, false); } GameManager.GetInstance().soundController.PlayHitChatter(); // Register damage hp.currentValue -= pd.damage; particleGenerator.SpawnParticles(); if (hp.currentValue > 0) { pingSpawner.Reveal(PingSpawner.Hurt); screenShake.Shake(ScreenShake.HitShake); } Destroy(pd.gameObject); } }