public EWorm(Vector2 pos, Vector2 vel, Texture2D tex, int chainPos, int length, EWorm parent) : base(tex, pos, vel) { ChainPosition = chainPos; growChild = true; damageTaken = 10; if (ChainPosition == 0) { FirstInChain = true; damageTaken = 5; } else if (ChainPosition == wormLength) { growChild = false; } this.parent = parent; wormLength = length; angle = (float)Game1.rand.NextDouble() * MathHelper.TwoPi; if (chainPos == 0) { CurrentCount++; } CurrentBodyPieces++; pointValue = 1; origin = Vector2.Zero; }
//Called by UpdateChain texture, updates the texture of the child recursively private void UpdateChildTex(EWorm e, Texture2D tex) { e.Texture = tex; if (e.Child != null) { UpdateChildTex(e.Child, tex); } }
protected virtual void SpawnChild() { if (growChild && timer > GROWTH_TIME && Child == null && ChainPosition < wormLength) { Vector2 pos = SetChildPos(position); Child = new EWorm(pos, Vector2.Zero, tex, ChainPosition + 1, wormLength, this); EnemyManager.AddEnemy((Enemy)Child); } }
public void KillChain() { parent = null; Life = 0; IsDead = true; if (Child != null) { Child.KillChain(); } }
public override void Die() { CurrentBodyPieces--; if (ChainPosition == 0) { CurrentCount--; } if (FirstInChain) { if (Child != null) { Child.KillChain(); Child = null; } } base.Die(); }
public void SetFirstInChain() { CurrentCount++; FirstInChain = true; parent = null; ChainPosition = 0; damageTaken = 5; Life = 100; timer = 0; if (wormLength > 1) { growChild = true; } if (Child != null) { Child.UpdateChain(ChainPosition + 1); } }
protected override void Behave(bool trigger, float time) { if (trigger) { velocity = RandUnitVector2(); velocity *= stats.Speed; angle = (float)Math.Atan2(velocity.Y, velocity.X); rotationalVelocity = 0; if (LevelManager.Current.EnemyManage.WormsOn) { for (int i = 0; i < stats.BranchRate / 2 - 1; i++) { EWorm e = new EWorm(Position + RandUnitVector2() * 30, RandUnitVector2(), EnemyManager.WormTex, 0, (int)stats.BranchRate - 2, null); EnemyManager.AddEnemy((Enemy)e); } } else { for (int i = 0; i < stats.BranchRate; i++) { EChaser c = new EChaser(EnemyManager.chaseTex, position + RandUnitVector2() * 100, Vector2.Zero); EnemyManager.AddEnemy((Enemy)c); } } } else if (stats.Curve) { Curve(); } counter += time; if (counter > stats.SpawnRate) { counter = 0; for (int i = 0; i < stats.BranchRate; i++) { ESeed e = new ESeed(EnemyManager.seedTex, position, RandUnitVector2() * 3); EnemyManager.AddEnemy((Enemy)e); } } }
protected void HandleRelativeDeath() { if (Child != null && Child.IsDead) { Child = null; timer = 0; } if (!FirstInChain) { if (parent != null && parent.IsDead) { SetFirstInChain(); parent = null; } else if (parent == null) { SetFirstInChain(); } } }
public PlayerWorm(Texture2D tex, int chainPos, int length, EWorm e) : base(Player.Position, Vector2.Zero, tex, chainPos, length, e) { }
private void Spawn() { Vector2 pos = new Vector2(); Vector2 vel = new Vector2(); Vector2 centre = new Vector2(Game1.ScreenX / 2, Game1.ScreenY / 2); if (!bossMode) { if (currentTime / (SPAWN_A + stats.SpawnModifier) > counterA && stats.DividersOn) { counterA++; int numCreate = Game1.rand.Next(1, 2 + stats.SpawnAmountModifier); for (int i = 0; i < numCreate; i++) { SetSpawnParameters(ref pos, ref vel, centre); EDivider e = new EDivider(divideTex, pos, vel, 0); enemies.Add((Enemy)e); } } if (currentTime / (SPAWN_B + stats.SpawnModifier) > counterB && stats.ChasersOn) { counterB++; int numCreate = Game1.rand.Next(1, 6 + stats.SpawnAmountModifier); for (int i = 0; i < numCreate; i++) { SetSpawnParameters(ref pos, ref vel, centre); EChaser e = new EChaser(chaseTex, pos, vel); enemies.Add((Enemy)e); } } if (ESpinner.CurrentCount < MAX_SPINNERS && currentTime / (SPAWN_C + stats.SpawnModifier) > counterC && stats.SpinnersOn) { counterC++; int numCreate = Game1.rand.Next(1, 3); for (int i = 0; i < numCreate; i++) { SetSpawnParameters(ref pos, ref vel, centre); //vel *= ESpinner.SPEED; ESpinner e = new ESpinner(spinTex, pos, vel); enemies.Add((Enemy)e); } } if (EWorm.CurrentCount < stats.MaxWorms && currentTime / (SPAWN_D + stats.SpawnModifier) > counterD && stats.WormsOn) { counterD++; int loopControl; if (LevelManager.Mode == GameMode.Worms) { loopControl = stats.MaxWorms - EWorm.CurrentCount; } else { loopControl = stats.SpawnAmountModifier / 2; } for (int i = 0; i < loopControl; i++) { SetSpawnParameters(ref pos, ref vel, centre); EWorm w = new EWorm(pos, vel, WormTex, 0, stats.SpawnAmountModifier + 1, null); enemies.Add((Enemy)w); } } } else { if (LevelManager.Mode != GameMode.Worms) { if (boss == null && enemies.Count == 0) { SetSpawnParameters(ref pos, ref vel, centre); boss = new Boss(bossTex, pos, vel); } } else { if (wBoss == null && enemies.Count == 0) { SetSpawnParameters(ref pos, ref vel, centre); wBoss = new WormBoss(pos, vel, WBossTex, 0, (int)LevelManager.Current.BossStats.SpawnRate + 4, null); } } } }