public void HandleCollision(GameObject obj, Collider2D c) { if (collided) { // already collided, don't do anything return; } // stop the projectile collided = true; Stop(); // destroy particle systems after a slight delay if (ProjectileDestroyParticleSystemsOnCollision != null) { foreach (ParticleSystem p in ProjectileDestroyParticleSystemsOnCollision) { GameObject.Destroy(p, 0.1f); } } // play collision sound if (ProjectileCollisionSound != null) { ProjectileCollisionSound.Play(); } // Play the collision particle system ProjectileExplosionParticleSystem.transform.position = ProjectileColliderObject.transform.position; ProjectileExplosionParticleSystem.Play(); FireBaseScript.CreateExplosion(ProjectileColliderObject.transform.position, ProjectileExplosionRadius, ProjectileExplosionForce); c.gameObject.GetComponent <Health> ().TakeDamage(10); }
public void HandleCollision(GameObject obj, Collision c) { if (collided) { // already collided, don't do anything return; } // stop the projectile collided = true; Stop(); // destroy particle systems after a slight delay if (ProjectileDestroyParticleSystemsOnCollision != null) { foreach (ParticleSystem p in ProjectileDestroyParticleSystemsOnCollision) { GameObject.Destroy(p, 0.1f); } } // play collision sound if (ProjectileCollisionSound != null) { ProjectileCollisionSound.Play(); } // if we have contacts, play the collision particle system and call the delegate if (c.contacts.Length != 0) { ProjectileExplosionParticleSystem.transform.position = c.contacts[0].point; ProjectileExplosionParticleSystem.Play(); FireBaseScript.CreateExplosion(c.contacts[0].point, ProjectileExplosionRadius, ProjectileExplosionForce); if (CollisionDelegate != null) { CollisionDelegate(this, c.contacts[0].point); } } EnemyHealth enemyHealth = c.gameObject.GetComponent <EnemyHealth> (); if (enemyHealth != null) { enemyHealth.TakeDamage(100, c.transform.position); } PlayerHealth playerHealth = c.gameObject.GetComponent <PlayerHealth> (); if (playerHealth != null && playerHealth.currentHealth > 0) { GameObject player = playerHealth.gameObject; if (player.GetComponent <PlayerID>().playerUniqueName != this.ownerName) { CmdTellServerWhoGotShot(player.GetComponent <PlayerID>().playerUniqueName, 20); if (playerHealth.currentHealth <= 0) { IncreaseNumberOfKills(this.ownerName); } } } }
public void CreateExplosion(Vector3 pos) { prefabObject = GameObject.Instantiate(Prefabs[0]); prefabScript = prefabObject.GetComponent<FireBaseScript>(); prefabObject.transform.position = pos; prefabObject.transform.rotation = Quaternion.identity; }
private void StopCurrent() { // if we are running a constant effect like wall of fire, stop it now if (currentPrefabScript != null && currentPrefabScript.Duration > 10000) { currentPrefabScript.Stop(); } currentPrefabObject = null; currentPrefabScript = null; }
public void HandleCollision(GameObject obj, Collision c) { if (collided) { // already collided, don't do anything return; } // stop the projectile collided = true; Stop(); // destroy particle systems after a slight delay if (ProjectileDestroyParticleSystemsOnCollision != null) { foreach (ParticleSystem p in ProjectileDestroyParticleSystemsOnCollision) { GameObject.Destroy(p, 0.1f); } } // play collision sound if (ProjectileCollisionSound != null) { ProjectileCollisionSound.Play(); } if (c.gameObject.tag == "Enemy") { //Debug.Log("ENEMY"); float dmg = 0; if (ProjectileColliderObject.name == "FireballCollider") { dmg = GM.mgr_spells.calculateDamage("FF"); } c.gameObject.GetComponent <MonsterAI>().health -= dmg; } // if we have contacts, play the collision particle system and call the delegate if (c.contacts.Length != 0) { ProjectileExplosionParticleSystem.transform.position = c.contacts[0].point; ProjectileExplosionParticleSystem.Play(); FireBaseScript.CreateExplosion(c.contacts[0].point, ProjectileExplosionRadius, ProjectileExplosionForce); if (CollisionDelegate != null) { CollisionDelegate(this, c.contacts[0].point); } } }
public void HandleCollision(GameObject obj, Collision c) { if (collided) { // already collided, don't do anything return; } // stop the projectile collided = true; Stop(); // destroy particle systems after a slight delay if (ProjectileDestroyParticleSystemsOnCollision != null) { foreach (ParticleSystem p in ProjectileDestroyParticleSystemsOnCollision) { GameObject.Destroy(p, 0.1f); } } // play collision sound if (ProjectileCollisionSound != null) { ProjectileCollisionSound.Play(); } // if we have contacts, play the collision particle system and call the delegate if (c.contacts.Length != 0) { /* * Collider[] colliders = Physics.OverlapSphere(transform.position, ProjectileExplosionRadius, ProjectileCollisionLayers); * for (int i = 0; i < colliders.Length; i++) * { * Rigidbody targetRigidbody = colliders[i].GetComponent<Rigidbody>(); * * if (!targetRigidbody) * { * continue; * } * targetRigidbody.AddExplosionForce(ProjectileExplosionForce, transform.position, ProjectileExplosionRadius); * * } */ ProjectileExplosionParticleSystem.transform.position = c.contacts[0].point; ProjectileExplosionParticleSystem.Play(); FireBaseScript.CreateExplosion(c.contacts[0].point, ProjectileExplosionRadius, ProjectileExplosionForce); if (CollisionDelegate != null) { CollisionDelegate(this, c.contacts[0].point); } } }
public void HandleCollision(GameObject obj, Collision c) { if (collided) { // already collided, don't do anything return; } // stop the projectile collided = true; Stop(); // destroy particle systems after a slight delay if (ProjectileDestroyParticleSystemsOnCollision != null) { foreach (ParticleSystem p in ProjectileDestroyParticleSystemsOnCollision) { GameObject.Destroy(p); } } // play collision sound if (ProjectileCollisionSound != null) { ProjectileCollisionSound.Play(); } if (c.collider.tag.Equals("Monster")) { Monster monster = c.collider.gameObject.GetComponent <Monster>(); monster.takeDamage(bulletDamage, firstElementType, secondElementType); // increament the level of all elements fireLevelController.IncrementElement(1); waterLevelController.IncrementElement(1); earthLevelController.IncrementElement(1); windLevelController.IncrementElement(1); } // if we have contacts, play the collision particle system and call the delegate if (c.contacts.Length != 0) { ProjectileExplosionParticleSystem.transform.position = c.contacts[0].point; ProjectileExplosionParticleSystem.Play(); FireBaseScript.CreateExplosion(c.contacts[0].point, ProjectileExplosionRadius, ProjectileExplosionForce); if (CollisionDelegate != null) { CollisionDelegate(this, c.contacts[0].point); } } }
private void Awake() { // find a point light firePointLight = gameObject.GetComponentInChildren<Light>(); if (firePointLight != null) { // we have a point light, set the intensity to 0 so it can fade in nicely lightIntensity = firePointLight.intensity; firePointLight.intensity = 0.0f; baseY = firePointLight.gameObject.transform.position.y; } seed = UnityEngine.Random.value * Seed; fireBaseScript = gameObject.GetComponent<FireBaseScript>(); }
private void Awake() { // find a point light firePointLight = gameObject.GetComponentInChildren <Light>(); if (firePointLight != null) { // we have a point light, set the intensity to 0 so it can fade in nicely lightIntensity = firePointLight.intensity; firePointLight.intensity = 0.0f; baseY = firePointLight.gameObject.transform.position.y; } seed = UnityEngine.Random.value * Seed; fireBaseScript = gameObject.GetComponent <FireBaseScript>(); }
private void BeginEffect(int i) { Vector3 pos; float yRot = transform.rotation.eulerAngles.y; Vector3 forwardY = Quaternion.Euler(0.0f, yRot, 0.0f) * Vector3.forward; Vector3 forward = transform.forward; Vector3 right = transform.right; Vector3 up = transform.up; Quaternion rotation = Quaternion.identity; currentPrefabObject = GameObject.Instantiate(Prefabs[i]); currentPrefabScript = currentPrefabObject.GetComponent <DigitalRuby.PyroParticles.FireConstantBaseScript>(); if (currentPrefabScript == null) { // temporary effect, like a fireball currentPrefabScript = currentPrefabObject.GetComponent <DigitalRuby.PyroParticles.FireBaseScript>(); if (currentPrefabScript.IsProjectile) { // set the start point near the player rotation = transform.rotation; pos = transform.position + forward; // pos = transform.position + forward + right + up; } else { // set the start point in front of the player a ways pos = transform.position + (forwardY * 10.0f); } } else { // set the start point in front of the player a ways, rotated the same way as the player pos = transform.position + (forwardY * 5.0f); rotation = transform.rotation; pos.y = 0.0f; } DigitalRuby.PyroParticles.FireProjectileScript projectileScript = currentPrefabObject.GetComponentInChildren <DigitalRuby.PyroParticles.FireProjectileScript>(); if (projectileScript != null) { // make sure we don't collide with other friendly layers projectileScript.ProjectileCollisionLayers &= (~UnityEngine.LayerMask.NameToLayer("FriendlyLayer")); } currentPrefabObject.transform.position = pos; currentPrefabObject.transform.rotation = rotation; }
// Use this for initialization void Start() { Vector3 pos; float yRot = transform.rotation.eulerAngles.y; Vector3 forwardY = Quaternion.Euler(0.0f, yRot, 0.0f) * Vector3.forward; Vector3 forward = transform.forward; Vector3 right = transform.right; Vector3 up = transform.up; Quaternion rotation = Quaternion.identity; currentPrefabObject = GameObject.Instantiate(GetComponent<baseSkillScript> ().effect); currentPrefabScript = currentPrefabObject.GetComponent<DigitalRuby.PyroParticles.FireConstantBaseScript>(); if (currentPrefabScript == null) { // temporary effect, like a fireball currentPrefabScript = currentPrefabObject.GetComponent<DigitalRuby.PyroParticles.FireBaseScript>(); if (currentPrefabScript.IsProjectile) { // set the start point near the player rotation = transform.rotation; pos = transform.position + forward + right + up; } else { // set the start point in front of the player a ways pos = transform.position + (forwardY * 10.0f); } } else { // set the start point in front of the player a ways, rotated the same way as the player pos = transform.position + (forwardY * 5.0f); rotation = transform.rotation; pos.y = 0.0f; } DigitalRuby.PyroParticles.FireProjectileScript projectileScript = currentPrefabObject.GetComponentInChildren<DigitalRuby.PyroParticles.FireProjectileScript>(); if (projectileScript != null) { // make sure we don't collide with other friendly layers // projectileScript.ProjectileCollisionLayers &= (~UnityEngine.LayerMask.NameToLayer("Ignore Raycast")); } currentPrefabObject.transform.position = pos; currentPrefabObject.transform.rotation = rotation; GetComponent<baseSkillScript> ().SetActive (false); StartCoroutine (GetComponent<baseSkillScript> ().TriggerDestroy ()); }
public void HandleCollision(GameObject obj, Collision c) { if (collided) { // already collided, don't do anything return; } // stop the projectile collided = true; Stop(); // destroy particle systems after a slight delay if (ProjectileDestroyParticleSystemsOnCollision != null) { foreach (ParticleSystem p in ProjectileDestroyParticleSystemsOnCollision) { GameObject.Destroy(p, 0.1f); } GameObject.Destroy(shadowRenderer.gameObject); } // play collision sound if (ProjectileCollisionSound != null) { ProjectileCollisionSound.Play(); } // if we have contacts, play the collision particle system and call the delegate if (c.contacts.Length != 0) { ProjectileExplosionParticleSystem.transform.position = c.contacts[0].point; ProjectileExplosionParticleSystem.Play(); FireBaseScript.CreateExplosion(c.contacts[0].point, ProjectileExplosionRadius, ProjectileExplosionForce); if (CollisionDelegate != null) { CollisionDelegate(this, c.contacts[0].point); } } //if collide with the player, inflicts damage if (c.collider.CompareTag("Player")) { c.collider.gameObject.SendMessage("ApplyDamage", boss.getFireballStrength(), SendMessageOptions.DontRequireReceiver); } }
public void HandleCollision(GameObject obj, Collision c) { if (collided) { // already collided, don't do anything return; } print(obj.tag); if (c.gameObject.CompareTag("Player")) { FindObjectOfType <LevelManager>().LevelLost(); } // stop the projectile collided = true; Stop(); // destroy particle systems after a slight delay if (ProjectileDestroyParticleSystemsOnCollision != null) { foreach (ParticleSystem p in ProjectileDestroyParticleSystemsOnCollision) { GameObject.Destroy(p, 0.1f); } } // play collision sound if (ProjectileCollisionSound != null) { ProjectileCollisionSound.Play(); } // if we have contacts, play the collision particle system and call the delegate if (c.contacts.Length != 0) { ProjectileExplosionParticleSystem.transform.position = c.contacts[0].point; ProjectileExplosionParticleSystem.Play(); FireBaseScript.CreateExplosion(c.contacts[0].point, ProjectileExplosionRadius, ProjectileExplosionForce); if (CollisionDelegate != null) { CollisionDelegate(this, c.contacts[0].point); } } }
public void HandleCollision(GameObject obj, Collision c) { //if (collided) //{ // float damage = 10; // //SendMessageUpwards("TakeDamage", damage); // // already collided, don't do anything // return; //} // stop the projectile collided = true; Stop(); // destroy particle systems after a slight delay if (ProjectileDestroyParticleSystemsOnCollision != null) { foreach (ParticleSystem p in ProjectileDestroyParticleSystemsOnCollision) { GameObject.Destroy(p, 0.1f); } } // play collision sound if (ProjectileCollisionSound != null) { ProjectileCollisionSound.Play(); } // if we have contacts, play the collision particle system and call the delegate if (c.contacts.Length != 0) { ProjectileExplosionParticleSystem.transform.position = c.contacts[0].point; ProjectileExplosionParticleSystem.Play(); FireBaseScript.CreateExplosion(c.contacts[0].point, ProjectileExplosionRadius, ProjectileExplosionForce); if (CollisionDelegate != null) { CollisionDelegate(this, c.contacts[0].point); } } }
private void BeginEffect() { Vector3 pos; float yRot = transform.rotation.eulerAngles.y; Vector3 forwardY = Quaternion.Euler(0.0f, yRot, 0.0f) * Vector3.forward; Vector3 forward = transform.forward; Vector3 right = transform.right; Vector3 up = transform.up; Quaternion rotation = Quaternion.identity; currentPrefabObject = GameObject.Instantiate(Prefabs[currentPrefabIndex]); currentPrefabScript = currentPrefabObject.GetComponent<FireConstantBaseScript>(); if (currentPrefabScript == null) { // temporary effect, like a fireball currentPrefabScript = currentPrefabObject.GetComponent<FireBaseScript>(); if (currentPrefabScript.IsProjectile) { // set the start point near the player rotation = transform.rotation; pos = transform.position + forward + right + up; } else { // set the start point in front of the player a ways pos = transform.position + (forwardY * 10.0f); } } else { // set the start point in front of the player a ways, rotated the same way as the player pos = transform.position + (forwardY * 5.0f); rotation = transform.rotation; pos.y = 0.0f; } FireProjectileScript projectileScript = currentPrefabObject.GetComponentInChildren<FireProjectileScript>(); if (projectileScript != null) { // make sure we don't collide with other friendly layers projectileScript.ProjectileCollisionLayers &= (~UnityEngine.LayerMask.NameToLayer("FriendlyLayer")); } currentPrefabObject.transform.position = pos; currentPrefabObject.transform.rotation = rotation; }
public void HandleCollision(GameObject obj, Collision c) { //return; if (collided) { // already collided, don't do anything return; } if (name.Equals("Firebolt(Clone)")) { if (c.collider.name.Equals("Player")) { Player t = c.collider.gameObject.GetComponent <Player>(); t.hit(); } else if (c.collider.name.Equals("Shield")) { } else { return; } } else if (name.Equals("Fireball(Clone)")) { Debug.Log("HELLO"); if (c.collider.name.Equals("Enemy(Clone)")) { c.collider.gameObject.GetComponent <Enemy>().hit(1); } else { return; } } else { Debug.Log(name); } // stop the projectile collided = true; Stop(); // destroy particle systems after a slight delay if (ProjectileDestroyParticleSystemsOnCollision != null) { foreach (ParticleSystem p in ProjectileDestroyParticleSystemsOnCollision) { GameObject.Destroy(p, 0.005f); } } // play collision sound if (ProjectileCollisionSound != null) { ProjectileCollisionSound.Play(); } // if we have contacts, play the collision particle system and call the delegate if (c.contacts.Length != 0) { ProjectileExplosionParticleSystem.transform.position = c.contacts[0].point; ProjectileExplosionParticleSystem.Play(); FireBaseScript.CreateExplosion(c.contacts[0].point, ProjectileExplosionRadius, ProjectileExplosionForce); if (CollisionDelegate != null) { CollisionDelegate(this, c.contacts[0].point); } } }