Example #1
0
    //This method needs to be called in the Awake() or Start() method of every concrete subclass
    protected void InitialiseScenario()
    {
        //Initialise the list of queued flag changes
        this.queuedFlagChanges = new Queue <KeyValuePair <int, FlagValue> >();

        //Initialise the list of flags
        this.flags = new Dictionary <int, FlagValue>();
        int[] flagKeys = EnumUtil.ArrayFromEnum(this.GetEnumType());
        foreach (int key in flagKeys)
        {
            this.flags[key] = new FlagValue(0, false);
        }

        //Initialise the list of flag triggers
        this.flagTriggers = new List <FlagTriggerDetails>();

        //When the scenario first becomes active, set it as the current scenario
        ScenarioManager.SetCurrentScenario(this);

        //If there is a flags debug instance present, set our enum type for it
        FlagsDebugDisplay flagDebug = this.gameObject.GetComponent <FlagsDebugDisplay>();

        if (flagDebug != null)
        {
            flagDebug.enumType = this.GetEnumType();
        }
    }
Example #2
0
    void OnGUI()
    {
        //Don't draw anything if the enum type has not been specified
        if (this.enumType == null)
        {
            return;
        }

        //Retrieve the list of enum values as ints
        int[] enumValues = EnumUtil.ArrayFromEnum(this.enumType);

        //Build the output text
        string debugText = "";

        foreach (int val in enumValues)
        {
            //Retrieve the enum value's name
            string valName = System.Enum.Parse(this.enumType, val.ToString()).ToString();

            //Determine whether or not the flag is set
            bool flagSet = ScenarioManager.GetCurrentScenario().GetFlag(val).value;

            //Append the line to the output
            debugText += valName + ": " + (flagSet ? "Set" : "Unset") + "\n";
        }

        GUI.color           = Color.black;
        GUI.backgroundColor = new Color(0, 0, 0, 0);
        GUI.Label(new Rect(0, 0, 999999, 999999), debugText);
    }