Exemple #1
0
 protected void setColourProperty()
 {
     //Colour property is set up
     colourProperty = new HackableEnum();
     colourProperty.addString("Red");
     colourProperty.addString("Blue");
     colourProperty.addString("Green");
     colourProperty.addString("Yellow");
     colourProperty.addString("Purple");
     colourProperty.addString("Pink");
     colourProperty.addString("Orange");
     colourProperty.setIndex(colourIndex);
     colourProperty.name = "Colour";
 }
Exemple #2
0
 //Copies the contents of the property into a new property
 public void copy(HackableEnum property)
 {
     valueList  = property.valueList;
     valueIndex = property.valueIndex;
     superCopy(property);
 }
Exemple #3
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;
    }