public Threat NewRandomLevel1Threat() { int id = ++manager.GetGameData().lastThreatId; StaticDb.ThreatType threatType = (StaticDb.ThreatType)Random.Range(0, 3); float deployTime = Random.Range(2f, 6f); StaticDb.ThreatAttacker threatAttacker; switch (threatType) { case StaticDb.ThreatType.local: threatAttacker = (StaticDb.ThreatAttacker)Random.Range(0, 2); break; case StaticDb.ThreatType.remote: threatAttacker = StaticDb.ThreatAttacker.external; break; case StaticDb.ThreatType.fakeLocal: threatAttacker = StaticDb.ThreatAttacker.intern; break; default: throw new ArgumentOutOfRangeException(); } StaticDb.ThreatAttack threatAttack; switch (threatType) { case StaticDb.ThreatType.local: do { threatAttack = (StaticDb.ThreatAttack)manager.GetGameData().threatRandomizer.GetNext(); } while ((int)threatAttack < 3 || threatAttack == StaticDb.ThreatAttack.stuxnet || threatAttack == StaticDb.ThreatAttack.dragonfly || threatAttack == StaticDb.ThreatAttack.createRemote); break; case StaticDb.ThreatType.remote: do { threatAttack = (StaticDb.ThreatAttack)manager.GetGameData().threatRandomizer.GetNext(); } while ((int)threatAttack > 5 || threatAttack == StaticDb.ThreatAttack.replay || threatAttack == StaticDb.ThreatAttack.stuxnet || threatAttack == StaticDb.ThreatAttack.dragonfly); break; case StaticDb.ThreatType.fakeLocal: threatAttack = StaticDb.ThreatAttack.fakeLocal; break; case StaticDb.ThreatType.timeEvent: threatAttack = StaticDb.ThreatAttack.timeEvent; break; default: throw new ArgumentOutOfRangeException(); } StaticDb.ThreatDanger threatDanger = threatType == StaticDb.ThreatType.fakeLocal ? StaticDb.ThreatDanger.fakeLocal : (StaticDb.ThreatDanger)Random.Range(0, 3); float moneyLossPerMinute; switch (threatDanger) { case StaticDb.ThreatDanger.low: moneyLossPerMinute = Random.Range(2f, 2.5f); break; case StaticDb.ThreatDanger.medium: moneyLossPerMinute = Random.Range(3f, 3.5f); break; case StaticDb.ThreatDanger.high: moneyLossPerMinute = Random.Range(4f, 4.5f); break; case StaticDb.ThreatDanger.fakeLocal: moneyLossPerMinute = Random.Range(4f, 4.5f); break; case StaticDb.ThreatDanger.timeEvent: moneyLossPerMinute = 0; break; default: moneyLossPerMinute = 0; break; } WeightedRandomizer <int> rand = new WeightedRandomizer <int>(); rand.AddOrUpdateWeight((int)StaticDb.ThreatAttack.dos, 0.1f); Threat threat = new Threat(id, threatType, deployTime, threatAttacker, threatDanger, threatAttack, moneyLossPerMinute, false); //Debug.Log(threat); return(threat); }