IEnumerator SpawnBlades() { while (currentSpawnCount < MaxDuration) { var instance = Instantiate(ProjectilePrefab); ProjectileControl p = instance.GetComponent <ProjectileControl>(); p.setUnitType(UnitType.Ally); bool bleed = Random.Range(0, 100) < UpgradedSkill.Upgrades[SkillUpgrade.RoBBleed] * SkillUpgrade.RoBBleed.SpecialAmount;//whether his blade will cause bleed bool piercing = false; int dmgMulti = 1; //fourth big blade counter if (UpgradedSkill.Upgrades[SkillUpgrade.RoBFourth] > 0) { piercing = true; bigBladeCounter++; if (bigBladeCounter == 4) { bigBladeCounter = 0; p.transform.localScale *= 1.5f; dmgMulti = 1 + (int)(UpgradedSkill.Upgrades[SkillUpgrade.RoBFourth] * SkillUpgrade.RoBFourth.SpecialAmount); } } int xDir = Random.Range(-(int)(UpgradedSkill.ProjectileSpeed * 0.6f), (int)(UpgradedSkill.ProjectileSpeed * 0.6f)); p.SetUp(UpgradedSkill.Amount * dmgMulti, new Vector2(xDir, -UpgradedSkill.ProjectileSpeed), piercing, bleed ? 1 : 0, 0); p.transform.position = transform.position; if (UpgradedSkill.Upgrades[SkillUpgrade.RoBSlow] > 0) { p.AddSlow(UpgradedSkill.Upgrades[SkillUpgrade.RoBSlow] * (int)SkillUpgrade.RoBSlow.SpecialAmount); } currentSpawnCount += SpawnInterval; //movement if (movementSpeed > 0 && ClosestEnemy != null) { if (ClosestEnemy.transform.position.x > transform.position.x + 0.5f) { GetComponent <Rigidbody2D>().velocity = new Vector2(movementSpeed, 0); } else if (ClosestEnemy.transform.position.x < transform.position.x - 0.5f) { GetComponent <Rigidbody2D>().velocity = new Vector2(-movementSpeed, 0); } else { GetComponent <Rigidbody2D>().velocity = new Vector2(0, 0); } } else { GetComponent <Rigidbody2D>().velocity = new Vector2(0, 0); } yield return(new WaitForSeconds(SpawnInterval)); } Destroy(gameObject); }
void Detonate() { GetComponent <Animator>().Play("Spring"); canDetect = false; if (spikes > 0) { for (int i = 0; i < spikes; i++) { var instance = Instantiate(spikePrefab); ProjectileControl p = instance.GetComponent <ProjectileControl>(); p.setUnitType(UnitType.Ally); float xDir = Random.Range(-20, 20); float yDir = 20 - Mathf.Abs(xDir); p.SetUp(5, new Vector2(xDir, yDir), true, 0, 0); p.DontCollideWithWalls(1); p.transform.position = transform.position; } } }