protected IEnumerator CreateProjectileBurst() { WaitForSeconds delay = new WaitForSeconds(projectileInfo.burstDelay); int count = projectileInfo.projectileCount; for (int i = 0; i < count; i++) { Projectile shot = ProjectileFactory.CreateProjectile(projectileInfo, effectOrigin, ParentAbility.Source, i); shot.Initialize(this); if (projectileInfo.addInitialForce == true) { Vector2 force = projectileInfo.initialForce.CalcDirectionAndForce(shot.gameObject, Source); shot.GetComponent <Rigidbody2D>().AddForce(force); } if (projectileInfo.burstDelay > 0) { yield return(delay); } else { yield return(null); } } }
protected override void Shoot() { PlayerProjectile projectile = ProjectileFactory.CreateProjectile(ProjectileType.PLAYER) as PlayerProjectile; projectile.transform.position = shootPosition.position; projectile.Launch(shootPosition.forward, ShoudProjectileRecochet(), GameField); }
public void StartShootingAtMonster(MonsterView[] monsters) { List <MonsterController> controllers = new List <MonsterController>(); foreach (MonsterView view in monsters) { if (!(view.Controller.Model).WillDie) { controllers.Add(view.Controller); } } if (controllers.Count == 0) { return; } int randomIndex = random.Next(controllers.Count); MonsterController monsterController = controllers[randomIndex]; Projectile projectileModel = Model.Shoot(monsterController.Model); fireCooldownCounter = new Cooldown(Model.AttackSpeed); if (projectileModel != null) { ProjectileController projectileController = ProjectileFactory.CreateProjectile(this, projectileModel, projectileModel.Type); View.Shoot(monsterController.View, projectileController); fireCooldownCounter.Reset(); } }
protected override void Shoot() { EnemyProjectile projectile = ProjectileFactory.CreateProjectile(ProjectileType.ENEMY) as EnemyProjectile; projectile.transform.position = shootPosition.position; Transform playerTransform = FindObjectOfType <PlayerView>().transform; projectile.Launch(playerTransform, this); }
protected void DeliverProjectiles() { if (projectileInfo.projectileCount == 1) { Projectile shot = ProjectileFactory.CreateProjectile(projectileInfo, effectOrigin, ParentAbility.Source); shot.Initialize(this); } else { ParentAbility.Source.GetMonoBehaviour().StartCoroutine(CreateProjectileBurst()); } }
void CreateAndPush(ShootingTemplate shootingTemplate) { if (!_canShootAgain) { //spawn projectile on each end of the shooting template for (int i = 0; i < shootingTemplate.ProjectileSpawnPoint.Length; i++) { Projectile projectile = _projectileFactory.CreateProjectile(shootingTemplate.ProjectileSpawnPoint[i].transform); } _canShootAgain = true; StartCoroutine(waitToShootAgain()); } }
private static Attack CreateAttack(Dictionary <string, object> attackProperties) { Attack attack = null; string attackName = (string)attackProperties["attackName"]; Projectile projectile = ProjectileFactory.CreateProjectile((Dictionary <string, object>)attackProperties["projectile"]); MovementPattern movement = MovementPatternFactory.CreateMovementPattern((Dictionary <string, object>)attackProperties["movementPattern"]); Timer cooldownToAttack = EntityGroupBuilder.CreateTimer((float)attackProperties["cooldownToAttack"]); cooldownToAttack.Stop(); cooldownToAttack.AutoReset = true; Timer cooldownToCreateProjectile = EntityGroupBuilder.CreateTimer((float)attackProperties["cooldownToCreateProjectile"]); cooldownToCreateProjectile.Stop(); cooldownToCreateProjectile.AutoReset = true; switch (attackName) { case "basicLinear": attack = new BasicLinear(projectile, movement, cooldownToAttack, cooldownToCreateProjectile); break; case "circularHoming": attack = new CircularHoming(projectile, (Circular)movement, cooldownToAttack, cooldownToCreateProjectile); break; case "circularTriHoming": attack = new CircularTriHoming(projectile, (Circular)movement, cooldownToAttack, cooldownToCreateProjectile); break; case "circle": int numberOfProjectiles = Convert.ToInt32((float)attackProperties["numberOfProjectiles"]); float degreesToStart = (float)attackProperties["degreesToStart"]; float degreesToEnd = (float)attackProperties["degreesToEnd"]; attack = new Circle(projectile, movement, cooldownToAttack, cooldownToCreateProjectile, numberOfProjectiles, degreesToStart, degreesToEnd); break; case "arrow": int widthOfArrow = Convert.ToInt32((float)attackProperties["widthOfArrow"]); attack = new Arrow(projectile, movement, cooldownToAttack, cooldownToCreateProjectile, widthOfArrow); break; default: throw new Exception("Invalid Entity"); } return(attack); }
protected void DeliverProjectiles() { //Debug.Log("Delivering projectiles"); if (projectileInfo.projectileCount == 1) { Projectile shot = ProjectileFactory.CreateProjectile(projectileInfo, effectOrigin, ParentAbility.Source); shot.Initialize(this); if (projectileInfo.addInitialForce == true) { Vector2 force = projectileInfo.initialForce.CalcDirectionAndForce(shot.gameObject, Source); shot.GetComponent <Rigidbody2D>().AddForce(force); } } else { ParentAbility.Source.GetMonoBehaviour().StartCoroutine(CreateProjectileBurst()); } }
protected IEnumerator CreateProjectileBurst() { WaitForSeconds delay = new WaitForSeconds(projectileInfo.burstDelay); int count = projectileInfo.projectileCount; for (int i = 0; i < count; i++) { Projectile shot = ProjectileFactory.CreateProjectile(projectileInfo, effectOrigin, ParentAbility.Source, i); shot.Initialize(this); if (projectileInfo.burstDelay > 0) { yield return(delay); } else { yield return(null); } } }
protected bool Attack(IAttackableEntity target) { if (target == null) { return(false); } StartedAttack?.Invoke(target); ProjectileFactory.CreateProjectile(Configuration.Projectile, target); remainingAttacks--; if (remainingAttacks == 0) { Reload(); } else { nextAttackDelay += Configuration.AttackSpeed; } return(true); }
public override void OnCastSpell() { ProjectileFactory.CreateProjectile(Projectiles.Roots, this.Side, this.Position); }