public void AddUnit(WaveUnit Unit) { Units.Add(Unit); Unit.Cloaked = FactionCard.CloakMode; Unit.Summoner = FactionCard.SummonMode; Unit.Huge = FactionCard.HugeMode; string b = Unit.Cloaked ? "Cloaked " : Unit.Summoner ? "Summoner " : Unit.Huge ? "Huge " : ""; if (Unit.Card != null) { if (Unit.StartingUnitCount > 1) { TextItems.AddLast(new WaveCardText(Unit.StartingUnitCount.ToString() + " " + b + Unit.Card.Name + (Unit.StartingUnitCount > 1 ? "s." : "."))); } else { TextItems.AddLast(new WaveCardText(b + Unit.Card.Name + (Unit.StartingUnitCount > 1 ? "s." : "."))); } } }
public virtual void Update(GameTime gameTime) { if (!CanSpawnUnits) { return; } UnitTimer += gameTime.ElapsedGameTime.Milliseconds; while (UnitTimer > MaxUnitTimer) { int reps = 100; UnitTimer -= MaxUnitTimer; WaveUnit waveUnit = null; do { reps--; CurrentUnit++; if (CurrentUnit >= Units.Count) { CurrentUnit = 0; } waveUnit = Units[CurrentUnit]; }while ((waveUnit.Card.GetType().IsSubclassOf(typeof(PlayerCard)) || waveUnit.Card.GetType().IsSubclassOf(typeof(StrikeCard)) || waveUnit.UnitCount < 1) && reps > 0); waveUnit.UnitCount--; CanSpawnUnits = false; foreach (WaveUnit w in Units) { if (w.UnitCount > 0 && !w.Card.GetType().IsSubclassOf(typeof(PlayerCard)) && !w.Card.GetType().IsSubclassOf(typeof(StrikeCard))) { CanSpawnUnits = true; } } LevelMult = 2; for (int i = 0; i < waveUnit.Card.GetUnitBuildNumber(); i++) { UnitBasic u = waveUnit.Card.GetUnit(NeutralManager.NeutralFaction); if (u == null) { //throw new Exception("Null unit error"); return; } WaveManager.self.ParentLevel.AddObject(u); u.SetLevel(waveUnit.Level * LevelMult, 1); NeutralManager.SpawnUnit(u); if (u.GetType().IsSubclassOf(typeof(UnitShip))) { UnitShip u2 = (UnitShip)u; u2.CanCloak = waveUnit.Cloaked; u2.CanSummon = waveUnit.Summoner; u2.IsHuge = waveUnit.Huge; u2.SummonCard = (UnitCard)waveUnit.Card; } } } }