void addRule() { int inputOrOutput = getInputOrOutput(); int acceptOrDrop = getAcceptOrDrop(); string factionIP = getFactionIP(); DataTypes.ProtoPort protoPort = getPort(); DataTypes.FirewallRule firewallRule = new DataTypes.FirewallRule(inputOrOutput, acceptOrDrop, factionIP, protoPort); rulesList.Add(firewallRule); rulesTextBox.text += firewallRule.ToString() + "\n"; }
void addRule() { if (rulesIndex == 4) { Debug.Log("This is the max amount of rules needed for this level. HINT: You only need to add one rule."); return; } rulesIndex++; int inputOrOutput = getInputOrOutput(); int acceptOrDrop = getAcceptOrDrop(); DataTypes.ProtoPort protoPort = getPort(); DataTypes.FirewallRule firewallRule = new DataTypes.FirewallRule(DataTypes.INPUT, acceptOrDrop, "Amazon (72.21.215.90)", protoPort); rulesList.Add(firewallRule); RectTransform parent = rulesListView.GetComponent <RectTransform>(); GameObject g = new GameObject(firewallRule.getFactionIP() + " | " + (int)firewallRule.getProtoPort() + " | " + firewallRule.getADAsString()); TextMeshProUGUI t = g.AddComponent <TextMeshProUGUI>(); t.transform.SetParent(parent); t.font = textMeshFont; RectTransform rect = t.GetComponent <RectTransform>(); Debug.Log(rect.sizeDelta); t.fontSize = 35; rect.sizeDelta = new Vector2(30, 25); t.alignment = TMPro.TextAlignmentOptions.Midline; t.color = new Color(163.0f / 255.0f, 15.0f / 255.0f, 45.0f / 255.0f); g.AddComponent <RulesMouseEnter>(); Debug.Log(rulesIndex); t.text = rulesIndex + ""; }
void Update() { //Handdles if caravan should go through, or go to next gate if (caravanMovement.getCollision()) { Debug.Log(caravanMovement.recentCollision.gameObject.name); if (caravanMovement.recentCollision.gameObject.name == "dragon") { losingText.text = "The dragon swallowed your entire caravan whole! Wrong Rule! \n \n Please try again."; caravanPrefab.transform.position = packetPosition; caravanMovement.collided = false; caravanMovement.currentGateIndex = 0; losingPanel.SetActive(true); caravanPrefab.GetComponent <SpriteRenderer>().sprite = caravanMovingLeftSprite; rulesList = new List <DataTypes.FirewallRule>(); caravanMovement.ready = false; AudioSource dragon_roar = caravanMovement.recentCollision.gameObject.GetComponent <AudioSource>(); dragon_roar.Play(); foreach (UnityEngine.UI.Button infoButton in infoButtons) { infoButton.gameObject.SetActive(true); } } else if (caravanMovement.recentCollision.gameObject.name == "cat") { losingText.text = "THE CARAVAN CRUSHED A KITTEN. \n YOU KILLED A KITTEN. \n Please try again."; caravanPrefab.transform.position = packetPosition; caravanMovement.collided = false; caravanMovement.currentGateIndex = 0; losingPanel.SetActive(true); caravanPrefab.GetComponent <SpriteRenderer>().sprite = caravanMovingLeftSprite; rulesList = new List <DataTypes.FirewallRule>(); caravanMovement.ready = false; AudioSource cat_meow = caravanMovement.recentCollision.gameObject.GetComponent <AudioSource>(); cat_meow.Play(); foreach (UnityEngine.UI.Button infoButton in infoButtons) { infoButton.gameObject.SetActive(true); } } else if (caravanMovement.recentCollision.gameObject.name == "Lava") { losingText.text = "The caravan melted into the lava. \n Its dead. \n Please try again."; caravanPrefab.transform.position = packetPosition; caravanMovement.collided = false; caravanMovement.currentGateIndex = 0; losingPanel.SetActive(true); caravanPrefab.GetComponent <SpriteRenderer>().sprite = caravanMovingLeftSprite; rulesList = new List <DataTypes.FirewallRule>(); caravanMovement.ready = false; AudioSource lava_melting_sound = caravanMovement.recentCollision.gameObject.GetComponent <AudioSource>(); lava_melting_sound.Play(); foreach (UnityEngine.UI.Button infoButton in infoButtons) { infoButton.gameObject.SetActive(true); } } else if (caravanMovement.recentCollision.gameObject.name == "80_gate") { losingText.text = "The gates are closed, so the caravan is not allowed to pass. \n Please try again."; caravanPrefab.transform.position = packetPosition; caravanMovement.collided = false; losingPanel.SetActive(true); caravanMovement.currentGateIndex = 0; caravanPrefab.GetComponent <SpriteRenderer>().sprite = caravanMovingLeftSprite; rulesList = new List <DataTypes.FirewallRule>(); caravanMovement.ready = false; foreach (UnityEngine.UI.Button infoButton in infoButtons) { infoButton.gameObject.SetActive(true); } } else if (caravanMovement.recentCollision.gameObject.name == "market") { // winningPanel.text = "The gates are closed, so the caravan is not allowed to pass. \n Please try again."; // caravanPrefab.transform.position = packetPosition; // caravanMovement.collided = false; winningPanel.SetActive(true); //caravanPrefab.GetComponent<SpriteRenderer>().sprite = caravanMovingLeftSprite; rulesList = new List <DataTypes.FirewallRule>(); // caravanMovement.ready = false; /*foreach (UnityEngine.UI.Button infoButton in infoButtons) * { * infoButton.gameObject.SetActive(true); * }*/ } else { Collision2D theCollision = caravanMovement.recentCollision; Gate collisionGate = theCollision.gameObject.GetComponent <Gate>(); DataTypes.ProtoPort gatePort = collisionGate.protoPort; int inputOrOutput, acceptOrDrop; string IPAddress; DataTypes.ProtoPort protoPort; foreach (DataTypes.FirewallRule firewallRule in rulesList) { inputOrOutput = firewallRule.getInputOrOutput(); acceptOrDrop = firewallRule.getAcceptOrDrop(); IPAddress = firewallRule.getFactionIP(); protoPort = firewallRule.getProtoPort(); if ((inputOrOutput == DataTypes.INPUT) && (acceptOrDrop == DataTypes.ACCEPT) && ((caravan.factionName + " (" + caravan.IPAddress + ")") == IPAddress) && (protoPort == gatePort)) { //Let it through levelComplete = true; caravanMovement.collided = false; rulesList = new List <DataTypes.FirewallRule>(); //winningPanel.SetActive(true); break; } } if (!levelComplete) { if (caravanMovement.currentGateIndex == 4) //If this was the last gate { Debug.Log("You lost due to either no rules, or just no rule to match this caravan, and it dropped the packet by default"); caravanPrefab.transform.position = packetPosition; caravanMovement.collided = false; losingPanel.SetActive(true); caravanPrefab.GetComponent <SpriteRenderer>().sprite = caravanMovingLeftSprite; rulesList = new List <DataTypes.FirewallRule>(); caravanMovement.ready = false; foreach (UnityEngine.UI.Button infoButton in infoButtons) { infoButton.gameObject.SetActive(true); } } else //If this wasn't the last gate, we keep moving towards the left, but first we move down till the road { caravanMovement.ready = false; //Stop packetmovement update method caravanPrefab.GetComponent <SpriteRenderer>().sprite = caravanMovingDownSprite; if (caravan.transform.position.y != packetPosition.y) { //caravan.transform.position -= velocity * Time.fixedDeltaTime; caravan.transform.position = Vector3.MoveTowards(caravan.transform.position, new Vector3(caravan.transform.position.x, packetPosition.y, caravan.transform.position.z), 3 * Time.deltaTime); } else { //Now we're back on the road, so we change sprite back to left one caravanPrefab.GetComponent <SpriteRenderer>().sprite = caravanMovingLeftSprite; caravanMovement.currentGateIndex++; //Update the current index to show its going to the next gate caravanMovement.ready = true; //Start packetmovement updatee method so it moves left caravanMovement.collided = false; } } } } } }
public Gate(DataTypes.ProtoPort protoPort) { this.protoPort = protoPort; }