Beispiel #1
0
    // Use this for initialization
    void Start()
    {
        //Just sets up the basic information
        isOpening = false;
        isOpen    = false;

        isLocked       = new HackableBool();
        isLocked.value = locked;
        isLocked.name  = "Locked";

        keyCode       = new HackableString();
        keyCode.value = key;
        keyCode.name  = "Key Name";

        setColourProperty();
        updateColour();

        //Squashes the cube to look like a door relative to it's orientation
        if (xOrientated)
        {
            transform.localScale = new Vector3(transform.localScale.x, transform.localScale.y - 0.1f, 0.3f);
        }
        else
        {
            transform.localScale = new Vector3(0.3f, transform.localScale.y - 0.1f, transform.localScale.z);
        }
    }
Beispiel #2
0
    //Pushes hack menu changes to the object
    public override void updateProperties(HackableProperty[] properties)
    {
        colourProperty = (HackableEnum)properties [0];
        isLocked       = (HackableBool)properties [1];
        keyCode        = (HackableString)properties [2];

        updateColour();
        locked = isLocked.value;
        key    = keyCode.value;
    }
Beispiel #3
0
 //Populates a given HackableBool with a copy of the data
 public void copy(HackableBool property)
 {
     value = property.value;
     superCopy(property);
 }
Beispiel #4
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;
    }