void HandleText(string text)
    {
        string[] statements = text.Split('.');

        if (statements.Length == 2)
        {
            string otherName = statements[0];
            string command   = statements[1];

            // Find object
            HackableObject objectInQuestion = null;

            foreach (HackableObject thing in GameObject.FindObjectsOfType(typeof(HackableObject)))
            {
                if (thing.hackName.Equals(otherName))
                {
                    objectInQuestion = thing;
                    break;
                }
            }

            // Set object's state
            if (objectInQuestion != null)
            {
                objectInQuestion.state = command;
            }
        }
    }
    public override void Action(string[] args)
    {
        List <HackableObject> connections = new List <HackableObject>();

        foreach (Router r in Router.unlockedRouters)
        {
            connections.AddRange(r.connections);
        }

        // invalid arguments
        if (args.Length != 1)
        {
            comRef.PrintToTerminal("Please input device name after \"hack\" command.");
        }
        // everything good!
        else
        {
            HackableObject toHack = FindHackableObjectByUID(connections, args[0]);
            if (toHack != null)
            {
                // SUCCESS PATH
                if (toHack.online && !toHack.active)   // hackable object found and not

                {
                    comRef.PrintToTerminal("<color=\"green\">" + toHack.ToString() + " successfully hacked.</color>");
                    AudioHelper.PlaySound("hack", false);

                    // already active
                    // for loop through all hackable objects and turn them off
                    /// TODO: Make sure to check if object should be made inactive
                    /// or not (i.e. camera, etc. should not be when others are hacked)
                    foreach (Router r in Router.unlockedRouters)
                    {
                        r.ClosePanel(toHack.panelNo);
                    }
                    toHack.SetEnabled(true);

                    // FAILURE PATH
                }
                else if (toHack.online)     // hackable object active
                {
                    comRef.PrintToTerminal("Already connected to " + toHack.ToString());
                }
                else     // hackable object offline
                {
                    comRef.PrintToTerminal("<color=\"red\">ERROR: " + toHack.ToString() + " is offline.</color>");
                    AudioHelper.PlaySound("error", false);
                }
            }
            else     // hackable object not found
            {
                comRef.PrintToTerminal("<color=\"red\">ERROR: Connection doesn't exist.</color>");
                AudioHelper.PlaySound("error", false);
            }
        }
    }
Example #3
0
    string PrintConnection(string text, HackableObject obj)
    {
        string color = "red";

        if (obj.online)
        {
            color = "green";
        }
        text += "<color=\"" + color + "\"> " + obj.ToString() + "</color>\n";
        return(text);
    }
Example #4
0
 public void HackTo(Vector3 startPos, HackableObject target, Transform transform)
 {
     Moving     = true;
     Hacking    = true;
     Velocity   = HackSpeed;
     HackTarget = target;
     TargetObj  = transform;
     this.transform.position = startPos;
     cameraFollow.target     = this.transform;
     particle.Play(false);
     particleSwirl2.Stop(true, ParticleSystemStopBehavior.StopEmittingAndClear);
 }
Example #5
0
        // Start is called before the first frame update
        void Start()
        {
            HackableObject obj = GetComponent <HackableObject>();

            if (obj != null)
            {
                obj.HackIn(PlayerNum);
            }
            NetworkNode node = GetComponent <NetworkNode>();

            if (node != null)
            {
                node.MoveIn(PlayerNum);
            }
        }
Example #6
0
 public void AddConnection(HackableObject obj)
 {
     connections.Add(obj);
     txt.text = PrintConnection(txt.text, obj);
     txt.rectTransform.sizeDelta += new Vector2(0, 30f);
 }
Example #7
0
    /// <summary>
    /// Sets us the data for the hack gui for the hack objext supplied.
    /// </summary>
    /// <param name="hackObject">Hack object.</param>
    public static void displayGUI(HackableObject hackObject)
    {
        //New positions are taken
        float newHackGUIx = Input.mousePosition.x;
        float newHackGUIy = Screen.height - Input.mousePosition.y;

        //On Click command should be ignored if done inside the currently displayed area
        //Function just returns leaving the gui to not be updated
        if (LevelGUI.displayHackGUI)
        {
            if (((newHackGUIx >= hackGUIx) && (newHackGUIx <= (hackGUIx + hackGUIWidth))) &&
                ((newHackGUIy >= hackGUIy) && (newHackGUIy <= (hackGUIy + hackGUIHeight))))
            {
                return;
            }
        }

        //GUI is disabled for a bit
        displayHackGUI = false;

        //Data is transfered across into the object attributes
        LevelGUI.hackObject = hackObject;
        hackGUIx            = newHackGUIx;
        hackGUIy            = newHackGUIy;

        //Properties are stored
        originalProperties = hackObject.getPropeties();
        //Copy properties array is created
        properties = new HackableProperty[originalProperties.Length];

        //Creates a property copy for each type of hackable property
        int index = 0;

        foreach (HackableProperty property in originalProperties)
        {
            if (property is HackableBool)
            {
                HackableBool copyProperty = new HackableBool();
                copyProperty.copy((HackableBool)property);
                properties[index] = copyProperty;
            }
            else if (property is HackableString)
            {
                HackableString copyProperty = new HackableString();
                copyProperty.copy((HackableString)property);
                properties[index] = copyProperty;
            }
            else if (property is HackableNumber)
            {
                HackableNumber copyProperty = new HackableNumber();
                copyProperty.copy((HackableNumber)property);
                properties[index] = copyProperty;
            }
            else if (property is HackableEnum)
            {
                HackableEnum copyProperty = new HackableEnum();
                copyProperty.copy((HackableEnum)property);
                properties[index] = copyProperty;
            }
            index++;
        }

        //Height is caluclated and stored
        hackGUIHeight = 10 + indvidualHeight + ((properties.Length + 1) * indvidualHeight);

        //Coordinates are moved if the menu appears off the screen

        if ((hackGUIx + hackGUIWidth) >= Screen.width)
        {
            hackGUIx = Screen.width - hackGUIWidth;
        }
        if ((hackGUIy + hackGUIHeight) >= Screen.height)
        {
            hackGUIy = Screen.height - hackGUIHeight;
        }

        //precalcuated values are stored
        nameX  = hackGUIx + 10;
        valueX = hackGUIx + 100;

        //GUI is now set to be displayed
        displayHackGUI = true;
    }
 // Start is called before the first frame update
 void Start()
 {
     base.Start();
     hackName = "door" + HackableObject.GetNum();
 }
Example #9
0
 public void HackTo(Vector3 startPos, HackableObject target, Transform transform, float velocity)
 {
     HackTo(startPos, target, transform);
     Velocity = velocity;
 }