public void OnPointerClick(PointerEventData eventData) { ToggleMenu(); manager.GetGameData().pressedSprite = gameObject.name; }
public void SetListeners() { List <Button> buttons; if (manager.GetGameData().pointOutPurchased) { if (manager.GetGameData().hasThreatDeployed) { buttons = interactiveSprite.actionButtonManager.GetActiveCanvasGroup(7); //buttons[0].GetComponentInChildren<TextMeshProUGUI>().text = "Apri monitor SCADA"; //buttons[0].onClick.RemoveAllListeners(); //buttons[0].onClick.AddListener(delegate //{ // ToggleScadaScreen(); // interactiveSprite.ToggleMenu(); //}); buttons[0].GetComponentInChildren <TextMeshProUGUI>().text = "Vai al Negozio"; buttons[0].onClick.RemoveAllListeners(); buttons[0].onClick.AddListener(delegate { ToggleStoreScreen(); interactiveSprite.ToggleMenu(); }); if (manager.GetGameData().isFirewallActive) { buttons[1].GetComponentInChildren <TextMeshProUGUI>().text = "Disattiva Firewall"; buttons[1].onClick.RemoveAllListeners(); buttons[1].onClick.AddListener(delegate { manager.SetFirewallActive(false); interactiveSprite.ToggleMenu(); interactiveSprite.ToggleMenu(); }); } else { buttons[1].GetComponentInChildren <TextMeshProUGUI>().text = "Attiva Firewall"; buttons[1].onClick.RemoveAllListeners(); buttons[1].onClick.AddListener(delegate { manager.SetFirewallActive(true); interactiveSprite.ToggleMenu(); interactiveSprite.ToggleMenu(); }); } if (manager.GetGameData().isRemoteIdsActive) { buttons[2].GetComponentInChildren <TextMeshProUGUI>().text = "Disattiva IDS"; buttons[2].onClick.RemoveAllListeners(); buttons[2].onClick.AddListener(delegate { manager.SetRemoteIdsActive(false); interactiveSprite.ToggleMenu(); interactiveSprite.ToggleMenu(); }); } else { buttons[2].GetComponentInChildren <TextMeshProUGUI>().text = "Attiva IDS"; buttons[2].onClick.RemoveAllListeners(); buttons[2].onClick.AddListener(delegate { manager.SetRemoteIdsActive(true); interactiveSprite.ToggleMenu(); interactiveSprite.ToggleMenu(); }); } if (manager.GetGameData().isLocalIdsActive) { buttons[3].GetComponentInChildren <TextMeshProUGUI>().text = "Disattiva Controlli Locali"; buttons[3].onClick.RemoveAllListeners(); buttons[3].onClick.AddListener(delegate { manager.SetLocalIdsActive(false); interactiveSprite.ToggleMenu(); interactiveSprite.ToggleMenu(); }); } else { buttons[3].GetComponentInChildren <TextMeshProUGUI>().text = "Attiva Controlli Locali"; buttons[3].onClick.RemoveAllListeners(); buttons[3].onClick.AddListener(delegate { manager.SetLocalIdsActive(true); interactiveSprite.ToggleMenu(); interactiveSprite.ToggleMenu(); }); } buttons[4].GetComponentInChildren <TextMeshProUGUI>().text = "Check configurazione di rete"; buttons[4].onClick.RemoveAllListeners(); buttons[4].onClick.AddListener(delegate { StartCheckNetworkCfg(); interactiveSprite.ToggleMenu(); }); buttons[5].GetComponentInChildren <TextMeshProUGUI>().text = "Esegui scansione malware"; buttons[5].onClick.RemoveAllListeners(); buttons[5].onClick.AddListener(delegate { StartAntiMalwareScan(); interactiveSprite.ToggleMenu(); }); buttons[6].GetComponentInChildren <TextMeshProUGUI>().text = "Individua minacce"; buttons[6].onClick.RemoveAllListeners(); buttons[6].onClick.AddListener(delegate { StartPointOutLocalThreat(); interactiveSprite.ToggleMenu(); }); } else { buttons = interactiveSprite.actionButtonManager.GetActiveCanvasGroup(4); //buttons[0].GetComponentInChildren<TextMeshProUGUI>().text = "Apri monitor SCADA"; //buttons[0].onClick.RemoveAllListeners(); //buttons[0].onClick.AddListener(delegate //{ // ToggleScadaScreen(); // interactiveSprite.ToggleMenu(); //}); buttons[0].GetComponentInChildren <TextMeshProUGUI>().text = "Vai al Negozio"; buttons[0].onClick.RemoveAllListeners(); buttons[0].onClick.AddListener(delegate { ToggleStoreScreen(); interactiveSprite.ToggleMenu(); }); if (manager.GetGameData().isFirewallActive) { buttons[1].GetComponentInChildren <TextMeshProUGUI>().text = "Disattiva Firewall"; buttons[1].onClick.RemoveAllListeners(); buttons[1].onClick.AddListener(delegate { manager.SetFirewallActive(false); interactiveSprite.ToggleMenu(); }); } else { buttons[1].GetComponentInChildren <TextMeshProUGUI>().text = "Attiva Firewall"; buttons[1].onClick.RemoveAllListeners(); buttons[1].onClick.AddListener(delegate { manager.SetFirewallActive(true); interactiveSprite.ToggleMenu(); }); } if (manager.GetGameData().isRemoteIdsActive) { buttons[2].GetComponentInChildren <TextMeshProUGUI>().text = "Disattiva IDS"; buttons[2].onClick.RemoveAllListeners(); buttons[2].onClick.AddListener(delegate { manager.SetRemoteIdsActive(false); interactiveSprite.ToggleMenu(); }); } else { buttons[2].GetComponentInChildren <TextMeshProUGUI>().text = "Attiva IDS"; buttons[2].onClick.RemoveAllListeners(); buttons[2].onClick.AddListener(delegate { manager.SetRemoteIdsActive(true); interactiveSprite.ToggleMenu(); }); } if (manager.GetGameData().isLocalIdsActive) { buttons[3].GetComponentInChildren <TextMeshProUGUI>().text = "Disattiva Controlli Locali"; buttons[3].onClick.RemoveAllListeners(); buttons[3].onClick.AddListener(delegate { manager.SetLocalIdsActive(false); interactiveSprite.ToggleMenu(); }); } else { buttons[3].GetComponentInChildren <TextMeshProUGUI>().text = "Attiva Controlli Locali"; buttons[3].onClick.RemoveAllListeners(); buttons[3].onClick.AddListener(delegate { manager.SetLocalIdsActive(true); interactiveSprite.ToggleMenu(); }); } buttons[4].GetComponentInChildren <TextMeshProUGUI>().text = "Individua minacce"; buttons[4].onClick.RemoveAllListeners(); buttons[4].onClick.AddListener(delegate { StartPointOutLocalThreat(); interactiveSprite.ToggleMenu(); }); } } else { if (manager.GetGameData().hasThreatDeployed) { buttons = interactiveSprite.actionButtonManager.GetActiveCanvasGroup(6); //buttons[0].GetComponentInChildren<TextMeshProUGUI>().text = "Apri monitor SCADA"; //buttons[0].onClick.RemoveAllListeners(); //buttons[0].onClick.AddListener(delegate //{ // ToggleScadaScreen(); // interactiveSprite.ToggleMenu(); //}); buttons[0].GetComponentInChildren <TextMeshProUGUI>().text = "Vai al Negozio"; buttons[0].onClick.RemoveAllListeners(); buttons[0].onClick.AddListener(delegate { ToggleStoreScreen(); interactiveSprite.ToggleMenu(); }); if (manager.GetGameData().isFirewallActive) { buttons[1].GetComponentInChildren <TextMeshProUGUI>().text = "Disattiva Firewall"; buttons[1].onClick.RemoveAllListeners(); buttons[1].onClick.AddListener(delegate { manager.SetFirewallActive(false); interactiveSprite.ToggleMenu(); }); } else { buttons[1].GetComponentInChildren <TextMeshProUGUI>().text = "Attiva Firewall"; buttons[1].onClick.RemoveAllListeners(); buttons[1].onClick.AddListener(delegate { manager.SetFirewallActive(true); interactiveSprite.ToggleMenu(); }); } if (manager.GetGameData().isRemoteIdsActive) { buttons[2].GetComponentInChildren <TextMeshProUGUI>().text = "Disattiva IDS"; buttons[2].onClick.RemoveAllListeners(); buttons[2].onClick.AddListener(delegate { manager.SetRemoteIdsActive(false); interactiveSprite.ToggleMenu(); }); } else { buttons[2].GetComponentInChildren <TextMeshProUGUI>().text = "Attiva IDS"; buttons[2].onClick.RemoveAllListeners(); buttons[2].onClick.AddListener(delegate { manager.SetRemoteIdsActive(true); interactiveSprite.ToggleMenu(); }); } if (manager.GetGameData().isLocalIdsActive) { buttons[3].GetComponentInChildren <TextMeshProUGUI>().text = "Disattiva Controlli Locali"; buttons[3].onClick.RemoveAllListeners(); buttons[3].onClick.AddListener(delegate { manager.SetLocalIdsActive(false); interactiveSprite.ToggleMenu(); }); } else { buttons[3].GetComponentInChildren <TextMeshProUGUI>().text = "Attiva Controlli Locali"; buttons[3].onClick.RemoveAllListeners(); buttons[3].onClick.AddListener(delegate { manager.SetLocalIdsActive(true); interactiveSprite.ToggleMenu(); }); } buttons[4].GetComponentInChildren <TextMeshProUGUI>().text = "Check configurazione di rete"; buttons[4].onClick.RemoveAllListeners(); buttons[4].onClick.AddListener(delegate { StartCheckNetworkCfg(); interactiveSprite.ToggleMenu(); }); buttons[5].GetComponentInChildren <TextMeshProUGUI>().text = "Esegui scansione malware"; buttons[5].onClick.RemoveAllListeners(); buttons[5].onClick.AddListener(delegate { StartAntiMalwareScan(); interactiveSprite.ToggleMenu(); }); } else { buttons = interactiveSprite.actionButtonManager.GetActiveCanvasGroup(4); //buttons[0].GetComponentInChildren<TextMeshProUGUI>().text = "Apri monitor SCADA"; //buttons[0].onClick.RemoveAllListeners(); //buttons[0].onClick.AddListener(delegate //{ // ToggleScadaScreen(); // interactiveSprite.ToggleMenu(); //}); buttons[0].GetComponentInChildren <TextMeshProUGUI>().text = "Vai al Negozio"; buttons[0].onClick.RemoveAllListeners(); buttons[0].onClick.AddListener(delegate { ToggleStoreScreen(); interactiveSprite.ToggleMenu(); }); if (manager.GetGameData().isFirewallActive) { buttons[1].GetComponentInChildren <TextMeshProUGUI>().text = "Disattiva Firewall"; buttons[1].onClick.RemoveAllListeners(); buttons[1].onClick.AddListener(delegate { manager.SetFirewallActive(false); interactiveSprite.ToggleMenu(); }); } else { buttons[1].GetComponentInChildren <TextMeshProUGUI>().text = "Attiva Firewall"; buttons[1].onClick.RemoveAllListeners(); buttons[1].onClick.AddListener(delegate { manager.SetFirewallActive(true); interactiveSprite.ToggleMenu(); }); } if (manager.GetGameData().isRemoteIdsActive) { buttons[2].GetComponentInChildren <TextMeshProUGUI>().text = "Disattiva IDS"; buttons[2].onClick.RemoveAllListeners(); buttons[2].onClick.AddListener(delegate { manager.SetRemoteIdsActive(false); interactiveSprite.ToggleMenu(); }); } else { buttons[2].GetComponentInChildren <TextMeshProUGUI>().text = "Attiva IDS"; buttons[2].onClick.RemoveAllListeners(); buttons[2].onClick.AddListener(delegate { manager.SetRemoteIdsActive(true); interactiveSprite.ToggleMenu(); }); } if (manager.GetGameData().isLocalIdsActive) { buttons[3].GetComponentInChildren <TextMeshProUGUI>().text = "Disattiva Controlli Locali"; buttons[3].onClick.RemoveAllListeners(); buttons[3].onClick.AddListener(delegate { manager.SetLocalIdsActive(false); interactiveSprite.ToggleMenu(); }); } else { buttons[3].GetComponentInChildren <TextMeshProUGUI>().text = "Attiva Controlli Locali"; buttons[3].onClick.RemoveAllListeners(); buttons[3].onClick.AddListener(delegate { manager.SetLocalIdsActive(true); interactiveSprite.ToggleMenu(); }); } } } foreach (Button button in buttons) { button.interactable = true; } }
private IEnumerator ThreatStopped(Threat threat) { yield return(new WaitForSeconds(messageDelay)); manager.GetGameData().lastThreatStopped = threat; Canvas dialog = ClassDb.dialogBoxManager.OpenDialog(); DialogBoxMessage message; switch (threat.threatType) { case StaticDb.ThreatType.local: message = MessageFromJson(Resources.Load <TextAsset>(StaticDb.localStopped)); break; case StaticDb.ThreatType.remote: message = MessageFromJson(Resources.Load <TextAsset>(StaticDb.remoteStopped)); break; case StaticDb.ThreatType.fakeLocal: message = MessageFromJson(Resources.Load <TextAsset>(StaticDb.fakeLocalStopped)); break; case StaticDb.ThreatType.timeEvent: ClassDb.dialogBoxManager.CloseDialog(dialog); yield break; default: throw new ArgumentOutOfRangeException(); } DialogBoxMessage messageIntern; if (threat.threatType != StaticDb.ThreatType.fakeLocal) { messageIntern = threat.threatAttacker == StaticDb.ThreatAttacker.intern ? MessageFromJson(Resources.Load <TextAsset>(StaticDb.internalMessage)) : StaticDb.emptyMessage; } else { messageIntern = StaticDb.emptyMessage; } dialog.GetComponent <DialogBoxManager>().SetDialog( message.head, message.body + "\n" + messageIntern.body, 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 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); }
public void SetListeners() { List <Button> buttons; if (manager.GetGameData().hasThreatDeployed || isThreatDetected) { buttons = interactiveSprite.actionButtonManager.GetActiveCanvasGroup(7); if (manager.GetGameData().isFirewallActive) { buttons[0].GetComponentInChildren <TextMeshProUGUI>().text = "Disattiva Firewall"; buttons[0].onClick.RemoveAllListeners(); buttons[0].onClick.AddListener(delegate { manager.SetFirewallActive(false); interactiveSprite.ToggleMenu(); interactiveSprite.ToggleMenu(); }); } else { buttons[0].GetComponentInChildren <TextMeshProUGUI>().text = "Attiva Firewall"; buttons[0].onClick.RemoveAllListeners(); buttons[0].onClick.AddListener(delegate { manager.SetFirewallActive(true); interactiveSprite.ToggleMenu(); interactiveSprite.ToggleMenu(); }); } if (manager.GetGameData().isRemoteIdsActive) { buttons[1].GetComponentInChildren <TextMeshProUGUI>().text = "Disattiva IDS"; buttons[1].onClick.RemoveAllListeners(); buttons[1].onClick.AddListener(delegate { manager.SetRemoteIdsActive(false); interactiveSprite.ToggleMenu(); interactiveSprite.ToggleMenu(); }); } else { buttons[1].GetComponentInChildren <TextMeshProUGUI>().text = "Attiva IDS"; buttons[1].onClick.RemoveAllListeners(); buttons[1].onClick.AddListener(delegate { manager.SetRemoteIdsActive(true); interactiveSprite.ToggleMenu(); interactiveSprite.ToggleMenu(); }); } if (manager.GetGameData().isLocalIdsActive) { buttons[2].GetComponentInChildren <TextMeshProUGUI>().text = "Disattiva Controlli Locali"; buttons[2].onClick.RemoveAllListeners(); buttons[2].onClick.AddListener(delegate { manager.SetLocalIdsActive(false); interactiveSprite.ToggleMenu(); interactiveSprite.ToggleMenu(); }); } else { buttons[2].GetComponentInChildren <TextMeshProUGUI>().text = "Attiva Controlli Locali"; buttons[2].onClick.RemoveAllListeners(); buttons[2].onClick.AddListener(delegate { manager.SetLocalIdsActive(true); interactiveSprite.ToggleMenu(); interactiveSprite.ToggleMenu(); }); } buttons[3].GetComponentInChildren <TextMeshProUGUI>().text = "Controlla eventi IDS"; buttons[3].onClick.RemoveAllListeners(); buttons[3].onClick.AddListener(delegate { StartIdsClean(); interactiveSprite.ToggleMenu(); }); buttons[4].GetComponentInChildren <TextMeshProUGUI>().text = "Check configurazione di rete"; buttons[4].onClick.RemoveAllListeners(); buttons[4].onClick.AddListener(delegate { StartCheckNetworkCfg(interactiveSprite); interactiveSprite.ToggleMenu(); }); buttons[5].GetComponentInChildren <TextMeshProUGUI>().text = "Riavvia server"; buttons[5].onClick.RemoveAllListeners(); buttons[5].onClick.AddListener(delegate { StartRebootServer(); interactiveSprite.ToggleMenu(); }); buttons[6].GetComponentInChildren <TextMeshProUGUI>().text = "Esegui scansione malware"; buttons[6].onClick.RemoveAllListeners(); buttons[6].onClick.AddListener(delegate { StartAntiMalwareScan(interactiveSprite); interactiveSprite.ToggleMenu(); }); } else { buttons = interactiveSprite.actionButtonManager.GetActiveCanvasGroup(3); if (manager.GetGameData().isFirewallActive) { buttons[0].GetComponentInChildren <TextMeshProUGUI>().text = "Disattiva Firewall"; buttons[0].onClick.RemoveAllListeners(); buttons[0].onClick.AddListener(delegate { manager.SetFirewallActive(false); interactiveSprite.ToggleMenu(); }); } else { buttons[0].GetComponentInChildren <TextMeshProUGUI>().text = "Attiva Firewall"; buttons[0].onClick.RemoveAllListeners(); buttons[0].onClick.AddListener(delegate { manager.SetFirewallActive(true); interactiveSprite.ToggleMenu(); }); } if (manager.GetGameData().isRemoteIdsActive) { buttons[1].GetComponentInChildren <TextMeshProUGUI>().text = "Disattiva IDS"; buttons[1].onClick.RemoveAllListeners(); buttons[1].onClick.AddListener(delegate { manager.SetRemoteIdsActive(false); interactiveSprite.ToggleMenu(); }); } else { buttons[1].GetComponentInChildren <TextMeshProUGUI>().text = "Attiva IDS"; buttons[1].onClick.RemoveAllListeners(); buttons[1].onClick.AddListener(delegate { manager.SetRemoteIdsActive(true); interactiveSprite.ToggleMenu(); }); } if (manager.GetGameData().isLocalIdsActive) { buttons[2].GetComponentInChildren <TextMeshProUGUI>().text = "Disattiva Controlli Locali"; buttons[2].onClick.RemoveAllListeners(); buttons[2].onClick.AddListener(delegate { manager.SetLocalIdsActive(false); interactiveSprite.ToggleMenu(); }); } else { buttons[2].GetComponentInChildren <TextMeshProUGUI>().text = "Attiva Controlli Locali"; buttons[2].onClick.RemoveAllListeners(); buttons[2].onClick.AddListener(delegate { manager.SetLocalIdsActive(true); interactiveSprite.ToggleMenu(); }); } } foreach (Button button in buttons) { button.interactable = true; } }
private void OnEnable() { manager = SetLevelManager(); tutorialManager = FindObjectOfType <TutorialManager>(); if (tutorialManager != null && tutorialManager.notebookFirstTime) { //show info message for security check notebookMessageRoutine = NotebookMessageRoutine(); StartCoroutine(notebookMessageRoutine); } if (manager != null) { manager.GetGameData().noteBookEnabled = true; } else if (tutorialManager != null) { tutorialManager.tutorialGameData.noteBookEnabled = true; } colorIndex = 0; pageCount = 0; nextBtn.onClick.RemoveAllListeners(); nextBtn.onClick.AddListener(delegate { pageToDisplay++; ShowText(); }); previousBtn.onClick.RemoveAllListeners(); previousBtn.onClick.AddListener(delegate { pageToDisplay -= 3; ShowText(); }); backBtn.onClick.RemoveAllListeners(); backBtn.onClick.AddListener(delegate { if (manager != null) { ToggleNoteBook(); } else { ToggleNoteBook(true); } }); LoadLesson(); toggleGroup.SetAllTogglesOff(); ShowInitialPage(); if (isFirstLesson) { ShowThreatLesson(firstLessonThreat); } else if (isScadaLesson) { ShowScadaLesson(); } else { return; } }
public void OnPointerDown(PointerEventData eventData) { if (destroy) { return; } spriteToAnimate = prSpriteName; ToggleMenu(); manager.GetGameData().pressedSprite = gameObject.name; //WRITE LOG ClassDb.logManager.StartWritePlayerLogRoutine(StaticDb.player, StaticDb.logEvent.UserEvent, gameObject.name.ToUpper() + " CLICKED"); }
private void OnDisable() { manager.GetGameData().idCardEnabled = false; }