protected override void Activate(params object[] args) { ProjectileCollider = new HitColliderBehaviour(abilityData.GetCustomStatValue("Damage"), abilityData.GetCustomStatValue("KnockBackScale"), abilityData.GetCustomStatValue("HitAngle"), despawnAfterTimeLimit, abilityData.GetCustomStatValue("Lifetime"), owner, DestroyOnHit, IsMultiHit, true, abilityData.GetCustomStatValue("HitStun")); //Log if a projectile couldn't be found if (!Projectile) { Debug.LogError("Projectile for " + abilityData.abilityName + " could not be found."); return; } //Create object to spawn projectile from GameObject spawnerObject = new GameObject(); spawnerObject.transform.parent = SpawnTransform; spawnerObject.transform.localPosition = Vector3.zero; spawnerObject.transform.position = new Vector3(spawnerObject.transform.position.x, spawnerObject.transform.position.y, owner.transform.position.z); spawnerObject.transform.forward = owner.transform.forward; //Initialize and attach spawn script ProjectileSpawnerBehaviour spawnScript = spawnerObject.AddComponent <ProjectileSpawnerBehaviour>(); spawnScript.projectile = Projectile; //Fire projectile ActiveProjectiles.Add(spawnScript.FireProjectile(spawnerObject.transform.forward * abilityData.GetCustomStatValue("Speed"), ProjectileCollider)); MonoBehaviour.Destroy(spawnerObject); }
//Called when ability is used protected override void Activate(params object[] args) { _projectileCollider = new HitColliderBehaviour(abilityData.GetCustomStatValue("Damage"), abilityData.GetCustomStatValue("KnockBackScale"), abilityData.GetCustomStatValue("HitAngle"), true, abilityData.GetCustomStatValue("Lifetime"), owner, true, false, true, abilityData.GetCustomStatValue("HitStun")); _projectileCollider.IgnoreColliders = abilityData.IgnoreColliders; _projectileCollider.Priority = abilityData.ColliderPriority; //If no spawn transform has been set, use the default owner transform if (!ownerMoveset.ProjectileSpawnTransform) { spawnTransform = owner.transform; } else { spawnTransform = ownerMoveset.ProjectileSpawnTransform; } //Log if a projectile couldn't be found if (!_projectile) { Debug.LogError("Projectile for " + abilityData.abilityName + " could not be found."); return; } CleanProjectileList(); if (_activeProjectiles.Count >= abilityData.GetCustomStatValue("MaxInstances") && abilityData.GetCustomStatValue("MaxInstances") >= 0) { return; } //Create object to spawn laser from GameObject spawnerObject = new GameObject(); spawnerObject.transform.parent = spawnTransform; spawnerObject.transform.localPosition = Vector3.zero; spawnerObject.transform.position = new Vector3(spawnerObject.transform.position.x, spawnerObject.transform.position.y, owner.transform.position.z); spawnerObject.transform.forward = owner.transform.forward; //Initialize and attach spawn script ProjectileSpawnerBehaviour spawnScript = spawnerObject.AddComponent <ProjectileSpawnerBehaviour>(); spawnScript.projectile = _projectile; Vector2 offSet = new Vector2(1, 0) * -owner.transform.forward; offSet.x = Mathf.RoundToInt(offSet.x); offSet.y = Mathf.RoundToInt(offSet.y); _ownerMoveScript.MoveToPanel(_ownerMoveScript.Position + offSet); //Fire laser spawnScript.FireProjectile(CalculateProjectileForce(), _projectileCollider); MonoBehaviour.Destroy(spawnerObject); }
//Called when ability is used protected override void Activate(params object[] args) { float powerScale = (float)args[0]; //If no spawn transform has been set, use the default owner transform if (!ownerMoveset.ProjectileSpawnTransform) { spawnTransform = owner.transform; } else { spawnTransform = ownerMoveset.ProjectileSpawnTransform; } //Log if a projectile couldn't be found if (!_projectile) { Debug.LogError("Projectile for " + abilityData.abilityName + " could not be found."); return; } //Initialize collider stats shotDamage = abilityData.GetCustomStatValue("Damage") * powerScale; knockBackScale = abilityData.GetCustomStatValue("KnockBackScale") * powerScale; _projectileCollider = new HitColliderBehaviour(shotDamage, knockBackScale, abilityData.GetCustomStatValue("HitAngle"), true, abilityData.GetCustomStatValue("Lifetime"), owner, true, false, true, abilityData.GetCustomStatValue("HitStun")); _projectileCollider.IgnoreColliders = abilityData.IgnoreColliders; _projectileCollider.Priority = abilityData.ColliderPriority; //Create object to spawn laser from GameObject spawnerObject = new GameObject(); spawnerObject.transform.parent = spawnTransform; spawnerObject.transform.localPosition = Vector3.zero; spawnerObject.transform.position = new Vector3(spawnerObject.transform.position.x, spawnerObject.transform.position.y, owner.transform.position.z); spawnerObject.transform.forward = owner.transform.forward; //Initialize and attach spawn script ProjectileSpawnerBehaviour spawnScript = spawnerObject.AddComponent <ProjectileSpawnerBehaviour>(); spawnScript.projectile = _projectile; //Fire laser spawnScript.FireProjectile(spawnerObject.transform.forward * abilityData.GetCustomStatValue("Speed"), _projectileCollider); }
/// <summary> /// Spawns the smaller, weaker lobshot /// </summary> /// <param name="axis"></param> private void SpawnWeakShot(Vector3 axis) { //Create object to spawn laser from GameObject spawnerObject = new GameObject(); spawnerObject.transform.parent = _weakSpawnTransform; spawnerObject.transform.localPosition = Vector3.up / 2; spawnerObject.transform.forward = owner.transform.forward; //Initialize and attach spawn script ProjectileSpawnerBehaviour spawnScript = spawnerObject.AddComponent <ProjectileSpawnerBehaviour>(); spawnScript.projectile = _weakProjectile; //Fire laser spawnScript.FireProjectile(CalculateProjectileForce(axis, _weakShotDistance), _weakProjectileCollider); MonoBehaviour.Destroy(spawnerObject); }
private void SpawnProjectile() { //If no spawn transform has been set, use the default owner transform if (!ownerMoveset.ProjectileSpawnTransform) { SpawnTransform = owner.transform; } else { SpawnTransform = ownerMoveset.ProjectileSpawnTransform; } //Log if a projectile couldn't be found if (!_projectile) { Debug.LogError("Projectile for " + abilityData.abilityName + " could not be found."); return; } //Create object to spawn laser from GameObject spawnerObject = new GameObject(); spawnerObject.transform.parent = SpawnTransform; spawnerObject.transform.localPosition = Vector3.zero; spawnerObject.transform.position = new Vector3(spawnerObject.transform.position.x + owner.transform.forward.x, spawnerObject.transform.position.y, owner.transform.position.z); spawnerObject.transform.forward = owner.transform.forward; //Initialize and attach spawn script ProjectileSpawnerBehaviour spawnScript = spawnerObject.AddComponent <ProjectileSpawnerBehaviour>(); spawnScript.projectile = _projectile; //Fire laser GameObject newProjectile = spawnScript.FireProjectile(spawnerObject.transform.forward * abilityData.GetCustomStatValue("Speed"), _projectileCollider); ActiveProjectiles.Add(newProjectile); MonoBehaviour.Destroy(spawnerObject); }
//Called when ability is used protected override void Activate(params object[] args) { //If no spawn transform has been set, use the default owner transform if (!ownerMoveset.ProjectileSpawnTransform) { spawnTransform = owner.transform; } else { spawnTransform = ownerMoveset.ProjectileSpawnTransform; } //Log if a projectile couldn't be found if (!_strongProjectile) { Debug.LogError("Projectile for " + abilityData.abilityName + " could not be found."); return; } //Initialize stats of strong and weak colliders float powerScale = (float)args[0]; _weakShotDamage = abilityData.GetCustomStatValue("WeakShotDamage") * powerScale; _strongShotDamage = abilityData.GetCustomStatValue("StrongShotDamage") * powerScale; _strongShotKnockBackScale = abilityData.GetCustomStatValue("StrongShotKnockBackScale") * powerScale; _strongShotDistance = (powerScale - 1) / abilityData.GetCustomStatValue("StrongShotForceIncreaseRate"); _weakProjectileCollider = new HitColliderBehaviour(_weakShotDamage, abilityData.GetCustomStatValue("WeakShotKnockBackScale"), abilityData.GetCustomStatValue("WeakShotHitAngle"), true, abilityData.GetCustomStatValue("WeakShotLifeTime"), owner, true, false, true, abilityData.GetCustomStatValue("WeakHitStun")); _weakProjectileCollider.IgnoreColliders = abilityData.IgnoreColliders; _weakProjectileCollider.Priority = abilityData.GetCustomStatValue("WeakColliderPriority"); _strongProjectileCollider = new HitColliderBehaviour(_strongShotDamage, _strongShotKnockBackScale, abilityData.GetCustomStatValue("StrongShotHitAngle"), true, abilityData.GetCustomStatValue("StrongShotLifeTime"), owner, true, false, true, abilityData.GetCustomStatValue("StrongHitStun")); _strongProjectileCollider.Priority = abilityData.ColliderPriority; _strongProjectileCollider.IgnoreColliders = abilityData.IgnoreColliders; CleanProjectileList(); //If the maximum amount of lobshot instances has been reached for this owner, don't spawn a new one if (_activeProjectiles.Count >= abilityData.GetCustomStatValue("MaxInstances") && abilityData.GetCustomStatValue("MaxInstances") >= 0) { return; } //Create object to spawn laser from GameObject spawnerObject = new GameObject(); spawnerObject.transform.parent = spawnTransform; spawnerObject.transform.localPosition = Vector3.zero; spawnerObject.transform.position = new Vector3(spawnerObject.transform.position.x, spawnerObject.transform.position.y, owner.transform.position.z); spawnerObject.transform.forward = owner.transform.forward; //Initialize and attach spawn script ProjectileSpawnerBehaviour spawnScript = spawnerObject.AddComponent <ProjectileSpawnerBehaviour>(); spawnScript.projectile = _strongProjectile; Vector2 offSet = new Vector2(1, 0) * -owner.transform.forward; offSet.x = Mathf.RoundToInt(offSet.x); offSet.y = Mathf.RoundToInt(offSet.y); _ownerMoveScript.MoveToPanel(_ownerMoveScript.Position + offSet); _strongProjectileCollider.onHit += SpawnWeakShots; //Fire laser _weakSpawnTransform = spawnScript.FireProjectile(CalculateProjectileForce(owner.transform.forward, _strongShotDistance), _strongProjectileCollider).transform; _activeProjectiles.Add(_weakSpawnTransform.gameObject); MonoBehaviour.Destroy(spawnerObject); _weakShotDamage /= powerScale; _strongShotDamage /= powerScale; _strongShotKnockBackScale /= powerScale; _strongShotDistance -= (powerScale - 1) / _strongForceIncreaseRate; }