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);
    }
Esempio n. 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;
 }
    private IEnumerator MoneyLoss(StaticDb.ThreatType type, float moneyLoss)
    {
        yield return(new WaitForSeconds(messageDelay));

        manager.GetGameData().lastTypeLoss   = type;
        manager.GetGameData().lastAmountLoss = moneyLoss;

        Canvas dialog = ClassDb.dialogBoxManager.OpenDialog();

        DialogBoxMessage message;


        switch (type)
        {
        case StaticDb.ThreatType.local:
            message = MessageFromJson(Resources.Load <TextAsset>(StaticDb.localMoneyLoss));
            break;

        case StaticDb.ThreatType.remote:
            message = MessageFromJson(Resources.Load <TextAsset>(StaticDb.remoteMoneyLoss));
            break;

        case StaticDb.ThreatType.fakeLocal:
            message = MessageFromJson(Resources.Load <TextAsset>(StaticDb.fakeLocalMoneyLoss));
            break;

        case StaticDb.ThreatType.timeEvent:
            ClassDb.dialogBoxManager.CloseDialog(dialog);
            yield break;

        default:
            throw new ArgumentOutOfRangeException();
        }

        dialog.GetComponent <DialogBoxManager>().SetDialog(
            message.head,
            string.Format(message.body, Math.Round(moneyLoss, 0).ToString(CultureInfo.CurrentCulture)),
            message.backBtn,
            message.nextBtn,
            dialog
            );

        dialog.GetComponent <DialogBoxManager>().dialogBoxBtnNext.onClick.RemoveAllListeners();
        dialog.GetComponent <DialogBoxManager>().dialogBoxBtnNext.gameObject.SetActive(true);
        dialog.GetComponent <DialogBoxManager>().dialogBoxBtnNext.onClick.AddListener(delegate
        {
            ClassDb.dialogBoxManager.CloseDialog(dialog);
        });

        dialog.GetComponent <DialogBoxManager>().dialogBoxBtnBack.onClick.RemoveAllListeners();
        dialog.GetComponent <DialogBoxManager>().dialogBoxBtnBack.gameObject.SetActive(false);
    }
    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 void StartMoneyLoss(StaticDb.ThreatType type, float moneyLoss)
 {
     moneyLossRoutine = MoneyLoss(type, moneyLoss);
     StartCoroutine(moneyLossRoutine);
 }
    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);
    }