public override void OnTriggered(Vector3 position, Vector3 direction, BehaviourProjectile projectile, Collider2D col = null) { if (NextBehaviour != null) { NextBehaviour.Activate(position, Quaternion.Euler(direction)); } }
public override void OnTriggered(Vector3 position, Vector3 direction, BehaviourProjectile projectile, Collider2D col = null) { float rotationPerProjectile = 360 / (float)Settings.LerpWeightInt(); for (int i = 0; i < Settings.LerpWeightInt(); i++) { Vector3 newRotation = new Vector3(0, 0, rotationPerProjectile * i); if (NextBehaviour != null) { // Activate next behaviour for every "created projectile". NextBehaviour.Activate(position, Quaternion.Euler(newRotation), col); } else if (_spawnedProjectileType != null) { // Instantiate default projectile. GameObject newProjectile = Instantiate(_spawnedProjectileType, position, Quaternion.Euler(newRotation)); // Grab projectile script. BehaviourProjectile projectileScript = newProjectile.GetComponent <BehaviourProjectile>(); // Initialize projectile. projectileScript.Initialize(null, PlayerID, Settings, new WeaponStats(Stats._projectileSpeed, childProjectileDamage, Stats._projectileColor)); if (col != null) { Physics2D.IgnoreCollision(newProjectile.GetComponent <Collider2D>(), col.GetComponent <Collider2D>()); } } } }
public override void OnTriggered(Vector3 position, Vector3 direction, BehaviourProjectile projectile, Collider2D col = null) { if (NextBehaviour != null) { // Activate the next behaviour at the calculated position. // Do this in a loop if you want to spawn multiple projectiles of the next behaviour. NextBehaviour.Activate(position, Quaternion.Euler(direction), col); } }
public override void OnTriggered(Vector3 position, Vector3 direction, BehaviourProjectile projectile, Collider2D col = null) { // Grab bounce script. BounceCounter counter = projectile.GetComponent <BounceCounter>(); if (counter.numberOfBounces > 0) { if (PreviousBehaviour != null) { // Instantiate previous projectile. GameObject newProjectile = Instantiate(PreviousBehaviour.ProjectileType, position, Quaternion.Euler(direction)); // Grab projectile script. BehaviourProjectile projectileScript = newProjectile.GetComponent <BehaviourProjectile>(); // Assign bounce script. BounceCounter newCounter = newProjectile.AddComponent <BounceCounter>(); newCounter.numberOfBounces = counter.numberOfBounces - 1; // Initialize previous projectile. projectileScript.Initialize(OnTriggered, PlayerID, PreviousBehaviour.Settings, Stats); if (col != null) { Physics2D.IgnoreCollision(newProjectile.GetComponent <Collider2D>(), col.GetComponent <Collider2D>()); } } else { // Instantiate default projectile. GameObject newProjectile = Instantiate(ProjectileType, position, Quaternion.Euler(direction)); // Grab projectile script. BehaviourProjectile projectileScript = newProjectile.GetComponent <BehaviourProjectile>(); // Assign bounce script. BounceCounter newCounter = newProjectile.AddComponent <BounceCounter>(); newCounter.numberOfBounces = counter.numberOfBounces - 1; // Initialize default projectile. projectileScript.Initialize(OnTriggered, PlayerID, Settings, Stats); if (col != null) { Physics2D.IgnoreCollision(newProjectile.GetComponent <Collider2D>(), col.GetComponent <Collider2D>()); } } } else { if (NextBehaviour != null) { // Activate next behaviour, since bouncing is done. NextBehaviour.Activate(position, Quaternion.Euler(direction), col); } } }