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;
        }
    }
Пример #2
0
    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;
        }
    }