示例#1
0
文件: DamagerHUD.cs 项目: 2tmb2/TD
    public void UpdateLives(float lives)
    {
        int livesInt = Mathf.FloorToInt(lives);

        List <RectTransform> lifeIcons = new List <RectTransform> ();

        livesContainer.GetComponentsInChildren <RectTransform>(lifeIcons);

        if (livesContainer.GetComponent <RectTransform> () != null)
        {
            lifeIcons.Remove(livesContainer.GetComponent <RectTransform>());
        }

        int lifeIconsCount = lifeIcons.Count;

        while (lifeIconsCount > livesInt)
        {
            Destroy(lifeIcons[lifeIconsCount - 1].gameObject);

            lifeIconsCount--;
        }

        while (lifeIconsCount < livesInt)
        {
            GameObject newHeart = Instantiate(lifeHeartPrefab) as GameObject;
            newHeart.transform.SetParent(livesContainer.transform, false);
            lifeIconsCount++;
        }
    }
示例#2
0
                /// <summary>
                /// Removes choices from a given choices panel
                /// </summary>
                protected void RemoveChoices(LayoutGroup choicesPanel)
                {
                    var choiceButtons = choicesPanel.GetComponentsInChildren <Button>();

                    foreach (var choiceButton in choiceButtons)
                    {
                        Destroy(choiceButton.gameObject);
                    }
                }
示例#3
0
    private void Refresh(bool ignored)
    {
        circuits = CircuitsPanel.GetComponentsInChildren <TrainingEntityListItem>().Where(x => x.selected).Select(x => x.item).ToList();
        cars     = CarsPanel.GetComponentsInChildren <TrainingEntityListItem>().Where(x => x.selected).Select(x => x.item).ToList();
        agents   = GetComponentsInChildren <AgentToggle>().Where(a => a.Checked).Select(a => a.agent).ToList();
        var instances = circuits.Count * cars.Count;

        SummaryText.text = string.Format("Selected {0}", instances);
    }
示例#4
0
        protected override void OnInit()
        {
            mBtnNums = new Dictionary <Button, int>();
            Button[] buttons = m_Group.GetComponentsInChildren <Button>();
            for (int i = 0; i < buttons.Length; i++)
            {
                Button btn    = buttons[i];
                char   suffix = btn.name[btn.name.Length - 1];
                if (suffix.Equals('.'))
                {
                    mBtnPoint = btn;
                }
                else if (suffix.Equals('-'))
                {
                    mBtnNeg = btn;
                }
                else
                {
                    mBtnNums[btn] = int.Parse(suffix.ToString());
                }

                btn.onClick.AddListener(() => OnClickPad(btn));
            }

            if (mFieldNumber.IntOnly)
            {
                mBtnPoint.gameObject.SetActive(false);
            }

            ClearNum();
            m_BtnClear.onClick.AddListener(ClearNum);

            AddCloseEvent(() =>
            {
                if (!string.IsNullOrEmpty(m_LabelNum.text))
                {
                    mField.SetValue(m_LabelNum.text);
                }
            });
        }