public Threat NewRemoteThreat()
    {
        int id = ++manager.GetGameData().lastThreatId;

        StaticDb.ThreatType threatType = StaticDb.ThreatType.remote;

        float deployTime = Random.Range(2f, 6f);

        StaticDb.ThreatAttacker threatAttacker = (StaticDb.ThreatAttacker)Random.Range(0, 2);

        StaticDb.ThreatAttack threatAttack;

        do
        {
            threatAttack = (StaticDb.ThreatAttack)manager.GetGameData().threatRandomizer.GetNext();
        } while ((int)threatAttack > 5);

        StaticDb.ThreatDanger threatDanger = (StaticDb.ThreatDanger)Random.Range(0, 3);

        float moneyLossPerMinute;

        switch (threatDanger)
        {
        case StaticDb.ThreatDanger.low:
            moneyLossPerMinute = Random.Range(1f, 1.5f);
            break;

        case StaticDb.ThreatDanger.medium:
            moneyLossPerMinute = Random.Range(2f, 2.5f);
            break;

        case StaticDb.ThreatDanger.high:
            moneyLossPerMinute = Random.Range(3f, 3.5f);
            break;

        case StaticDb.ThreatDanger.fakeLocal:
            moneyLossPerMinute = Random.Range(3f, 3.5f);
            break;

        case StaticDb.ThreatDanger.timeEvent:
            moneyLossPerMinute = 0;
            break;

        default:
            moneyLossPerMinute = 0;
            break;
        }

        Threat threat = new Threat(id, threatType, deployTime, threatAttacker, threatDanger, threatAttack, moneyLossPerMinute, false);

        //Debug.Log(threat);

        return(threat);
    }
示例#2
0
 public Threat(int id, StaticDb.ThreatType threatType, float deployTime, StaticDb.ThreatAttacker threatAttacker, StaticDb.ThreatDanger threatDanger, StaticDb.ThreatAttack threatAttack, float moneyLossPerMinute, bool fromCreateRemote)
 {
     this.id                 = id;
     this.threatType         = threatType;
     this.deployTime         = deployTime;
     this.threatAttacker     = threatAttacker;
     this.threatDanger       = threatDanger;
     this.threatAttack       = threatAttack;
     this.moneyLossPerMinute = moneyLossPerMinute;
     this.fromCreateRemote   = fromCreateRemote;
 }
    public Threat NewFakeLocalThreat()
    {
        int id = ++manager.GetGameData().lastThreatId;

        StaticDb.ThreatType threatType = StaticDb.ThreatType.fakeLocal;

        float deployTime = Random.Range(2f, 6f);

        StaticDb.ThreatAttacker threatAttacker = StaticDb.ThreatAttacker.intern;

        StaticDb.ThreatAttack threatAttack = StaticDb.ThreatAttack.fakeLocal;

        StaticDb.ThreatDanger threatDanger = StaticDb.ThreatDanger.fakeLocal;

        float moneyLossPerMinute = Random.Range(3f, 3.5f);

        Threat threat = new Threat(id, threatType, deployTime, threatAttacker, threatDanger, threatAttack, moneyLossPerMinute, false);

        //Debug.Log(threat);

        return(threat);
    }
    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);
    }