示例#1
0
 void SetValToStatsBlock(StatsBlock sb, string name, string desc, string val)
 {
     sb.DisplayName = dislayName;
     sb?.SetName(name);
     sb?.SetDesc(desc);
     sb?.SetValue(val);
 }
示例#2
0
        /*
         * On Click of an MCUID, simplify the total list of MCUs being displayed to just itself.
         * Sets page title and key/type for breaking out of the page.
         * */
        protected void mcuidClick(object sender, EventArgs e)
        {
            Button btn = (Button)sender;

            foreach (GridViewRow rw in resultsGrid.Rows)
            {
                if (((Button)rw.FindControl("MCUID")).Text == btn.Text)
                {
                    //Keep or mark matching items as visible
                    rw.Visible = true;
                }
                else
                {
                    //Hide unrelated objects
                    rw.Visible = false;
                }
            }
            Page.Title    = "MCU: " + btn.Text;
            keyBreak      = btn.Text;
            typeBreak     = "MCUID";
            humidity      = ((Label)StatsBlock.FindControl("Humidity"));
            humidity.Text = "Test??";
        }
示例#3
0
    void SetDescription(Description desc)
    {
        for (int i = 0; i < constraintsPanel.childCount; i++)
        {
            Destroy(constraintsPanel.GetChild(i).gameObject);
        }
        for (int i = 0; i < statsPanel.childCount; i++)
        {
            Destroy(statsPanel.GetChild(i).gameObject);
        }
        for (int i = 0; i < secondStatsPanel.childCount; i++)
        {
            Destroy(secondStatsPanel.GetChild(i).gameObject);
        }

        if (desc.Icon != null)
        {
            itemIcon.sprite = desc.Icon;
            itemIcon.gameObject.SetActive(true);
        }
        else
        {
            itemIcon.gameObject.SetActive(false);
        }

        if (desc.Name != null)
        {
            name.text = desc.Name;
        }
        else
        {
            name.text = string.Empty;
        }

        if (desc.Desc != null)
        {
            description.text = desc.Desc;
        }
        else
        {
            description.text = string.Empty;
        }

        if (desc.Constraints != null && desc.Constraints.Length > 0)
        {
            foreach (var d in desc.Constraints)
            {
                GameObject go = Instantiate(statsBlockOriginal, constraintsPanel);
                StatsBlock sb = go.GetComponent <StatsBlock>();
                sb.SetName(d.Name);
                sb.SetValue(d.Description, d.ItPositiveDesc);
            }
            constraintsPanel.gameObject.SetActive(true);
        }
        else
        {
            constraintsPanel.gameObject.SetActive(false);
        }

        if (!string.IsNullOrEmpty(desc.StatsName))
        {
            statsName.gameObject.SetActive(true);
            statsName.text = desc.StatsName;
        }
        else
        {
            statsName.gameObject.SetActive(false);
        }

        if (desc.Stats != null && desc.Stats.Length > 0)
        {
            foreach (var d in desc.Stats)
            {
                GameObject go = Instantiate(statsBlockOriginal, statsPanel);
                StatsBlock sb = go.GetComponent <StatsBlock>();
                sb.SetName(d.Name);
                sb.SetValue(d.Description, d.ItPositiveDesc);
            }
            statsPanel.gameObject.SetActive(true);
        }
        else
        {
            statsPanel.gameObject.SetActive(false);
        }

        if (!string.IsNullOrEmpty(desc.SecondStatsName))
        {
            secondStatsName.gameObject.SetActive(true);
            secondStatsName.text = desc.SecondStatsName;
        }
        else
        {
            secondStatsName.gameObject.SetActive(false);
        }

        if (desc.SecondStats != null && desc.SecondStats.Length > 0)
        {
            foreach (var d in desc.SecondStats)
            {
                GameObject go = Instantiate(statsBlockOriginal, secondStatsPanel);
                StatsBlock sb = go.GetComponent <StatsBlock>();
                sb.SetName(d.Name);
                sb.SetValue(d.Description, d.ItPositiveDesc);
            }
            secondStatsPanel.gameObject.SetActive(true);
        }
        else
        {
            secondStatsPanel.gameObject.SetActive(false);
        }

        if (desc.Cost.HasValue)
        {
            costPanel.alpha = 1;
            if (desc.Cost.Value.CostPerOne.HasValue)
            {
                costPerOneText.gameObject.SetActive(true);
                costPerOneText.text = desc.Cost.Value.CostPerOne.Value.ToString(StringFormats.intSeparatorNumber, StringFormats.nfi);
            }
            else
            {
                costPerOneText.gameObject.SetActive(false);
            }

            if (desc.Cost.Value.CostAll.HasValue)
            {
                costAllText.gameObject.SetActive(true);
                costAllText.text = desc.Cost.Value.CostAll.Value.ToString(StringFormats.intSeparatorNumber, StringFormats.nfi);
            }
            else
            {
                costAllText.gameObject.SetActive(false);
            }

            if (desc.Cost.Value.CostCurrency.HasValue)
            {
                currencyIcon.sprite = currency[(int)desc.Cost.Value.CostCurrency];
            }
            else
            {
                currencyIcon.sprite = currency[(int)DSPlayerScore.Currency.SILVER];
            }
        }
        else
        {
            costPanel.alpha = 0;
        }

        if (desc.Condition.HasValue)
        {
            conditionText.text  = desc.Condition.Value.Name;
            conditionText.color = desc.Condition.Value.Value.GetColor();
            conditionText.gameObject.SetActive(true);
            name.alignment = TextAlignmentOptions.BottomLeft;
        }
        else
        {
            conditionText.gameObject.SetActive(false);
            name.alignment = TextAlignmentOptions.MidlineLeft;
        }

        if (!string.IsNullOrEmpty(desc.UseType))
        {
            howToUsePanel.SetName(LocalizedStrings.how_to_use);
            howToUsePanel.SetValue(desc.UseType);
        }
        howToUsePanel.gameObject.SetActive(!string.IsNullOrEmpty(desc.UseType));
    }