コード例 #1
0
 public void Assign(Recurso.OpcionContenido Option)
 {
     //We should be assigned to a toggle, so we can search it and init the values
     Toggle_True.isOn  = false;
     Toggle_False.isOn = false;
     Label.text        = Option.Data;
 }
コード例 #2
0
    public RenderOption[] BuildRenderOptions(Recurso.OpcionContenido[] Options)
    {
        List <RenderOption_Pairs> RenderOptions = new List <RenderOption_Pairs>();

        //First pass, create the RenderOptions and assign the first Port
        foreach (Recurso.OpcionContenido Opt in Options)
        {
            GameObject         instantiated = GameObject.Instantiate(Blueprint);
            RenderOption_Pairs pair         = instantiated.GetComponent <RenderOption_Pairs>();
            RenderOptions.Add(pair);

            pair.SetupPort(RenderOption_Pairs.PortLocation.Left, Opt);
        }

        //Second pass, rumble the options and assign the second port
        System.Random             rnd      = new System.Random();
        Recurso.OpcionContenido[] RandOpts = Options.OrderBy(x => rnd.Next()).ToArray();

        for (int i = 0; i < RandOpts.Length; i++)
        {
            Recurso.OpcionContenido opt  = RandOpts[i];
            RenderOption_Pairs      pair = RenderOptions[i];

            pair.SetupPort(RenderOption_Pairs.PortLocation.Right, opt);
        }

        return(RenderOptions.ToArray());
    }
コード例 #3
0
    public void Assign(Recurso.OpcionContenido Option, int index)
    {
        //We should be assigned to a toggle, so we can search it and init the values
        Toggle.isOn = false;
        Label.text  = Option.Data;
        int asciiValue = (int)'A' + index;

        IndexLabel.text = ((char)asciiValue).ToString();
    }
コード例 #4
0
    public RenderOption[] BuildRenderOptions(Recurso.OpcionContenido[] Options)
    {
        List <RenderOption> RenderOptions = new List <RenderOption>();

        for (int i = 0; i < Options.Length; i++)
        {
            Recurso.OpcionContenido Opt          = Options[i];
            GameObject instantiated              = GameObject.Instantiate(Blueprint);
            RenderOption_Alternative alternative = instantiated.GetComponent <RenderOption_Alternative>();

            alternative.Assign(Opt, i);
            RenderOptions.Add(alternative);
        }

        return(RenderOptions.ToArray());
    }
コード例 #5
0
    public void SetupPort(PortLocation Location, Recurso.OpcionContenido Opcion)
    {
        PortType type = GetPortTypeForLocation(Location, Opcion);

        UnityEngine.UI.Text Label = null;
        string data = "";

        //Obtain the correct label to use
        switch (Location)
        {
        case PortLocation.Left:
            Label = LabelLeft;
            data  = Opcion.Data;
            break;

        case PortLocation.Right:
            Label = LabelRight;
            data  = Opcion.DataSecundaria;
            break;
        }

        switch (type)
        {
        case PortType.Text:
            Label.text = data;
            break;

        case PortType.Image:
            Label.text = "Cargando";

            //Clear escaped strings
            data = data.Replace("\\", "");

            //Request a download
            BeginLoadPortImage(data, Location);

            break;

        default:
            break;
        }
    }
コード例 #6
0
    private PortType GetPortTypeForLocation(PortLocation location, Recurso.OpcionContenido opcion)
    {
        string[] types = opcion.Tipo.Split("|".ToCharArray());

        //Should have more than 1 index
        if (types.Length <= 1)
        {
            return(PortType.Unknown);
        }

        string[] portTypes = types[1].Split("-".ToCharArray());

        //Same here, for this specific type of render option, each port type is separated via "-" like this: pares|txt-img
        if (portTypes.Length <= 1)
        {
            return(PortType.Unknown);
        }

        int index = location == PortLocation.Left ? 0 : 1;

        return(portTypes[index].Equals("txt") ? PortType.Text : portTypes[index].Equals("img") ? PortType.Image : PortType.Unknown);
    }