Esempio n. 1
0
    IEnumerator FadeTimerPanel()
    {
        Debug.Log("FadeTimerPanel Coroutine started.");
        showing_timer = true;
        endGameTimerPanel.gameObject.SetActive(true);
        CanvasRenderer[] renderers = endGameTimerPanel.GetComponentsInChildren <CanvasRenderer>();

        int fade_frames = (int)(2f / Time.deltaTime);  // two sec

        for (int i = 0; i < fade_frames; ++i)
        {
            float a = Mathf.Lerp(0f, 1f, (float)i / fade_frames);
            for (int r = 0; r < renderers.Length; ++r)
            {
                renderers[r].SetAlpha(a);
            }
            UpdateTimerText();
            yield return(null);
        }
        for (int i = 0; i < fade_frames; ++i)
        {
            float a = Mathf.Lerp(1f, 0f, (float)i / fade_frames);
            for (int r = 0; r < renderers.Length; ++r)
            {
                renderers[r].SetAlpha(a);
            }
            UpdateTimerText();
            yield return(null);
        }
        endGameTimerPanel.gameObject.SetActive(false);
        showing_timer = false;
    }
Esempio n. 2
0
 public static void toAlphaWithChildren(RawImage img, float alpha)
 {
     RawImage[] imgs = img.GetComponentsInChildren <RawImage>();
     for (int i = 0; i < imgs.Length; i++)
     {
         toAlpha(imgs[i], alpha);
     }
 }
    public void setPassports(Canvas passportIn, Canvas humanPassportIn)
    {
        passport      = passportIn;
        humanPassport = humanPassportIn;

        RawImage scroll = passport.GetComponentInChildren <RawImage> (true);

        RawImage[] images = scroll.GetComponentsInChildren <RawImage> (true);

        stamps       = new List <RawImage> ();
        stampSquares = new List <RawImage> ();

        for (int i = 0; i < 5; i++)
        {
            stampSquares.Add(images [2 * i + 1]);
            stamps.Add(images [2 * i + 2]);
        }

        Button[] buttons = scroll.GetComponentsInChildren <Button> (true);
        approve = buttons [0];
        reject  = buttons [1];

        if (automatic)
        {
            approve.enabled = false;
            approve.GetComponent <Image> ().enabled = false;

            reject.enabled = false;
            reject.GetComponent <Image> ().enabled = false;
        }

        hidePassport();

        Text[] textDisplays = scroll.GetComponentsInChildren <Text> (true);
        teamNameDisplay      = textDisplays[1];
        puzzleRequestDisplay = textDisplays[2];
    }
Esempio n. 4
0
    public void OnPointerClickCallBack(BaseEventData data)
    {
        switch (_skinState)
        {
        case SkinState.SS_BUY:
        {
            if (PlayerPrefs.GetInt("Money") >= int.Parse(_text.text))
            {
                Debug.Log("Buy Skin");

                _buyConfirmMask.gameObject.SetActive(true);
                string tiptext = DataManager._languageIndex == 1 ? string.Format("确定消耗\n{0}金币\n购买皮肤?", _skinMoneyNum) : string.Format("Cost\n{0}coins\nto buy skin?", _skinMoneyNum);
                _buyTipInfo.text = tiptext;

                var buttons = _buyConfirmMask.GetComponentsInChildren <Button> ();
                buttons [0].onClick.RemoveAllListeners();
                buttons [0].onClick.AddListener(BuyConfirm);
                buttons [1].onClick.RemoveAllListeners();
                buttons [1].onClick.AddListener(BuyCancle);
            }
            else
            {
                Debug.Log("Not Enough Money");

                GameObject canvas = GameObject.Find("Canvas");
                GameObject tip    = GameObject.Instantiate(_tipPrefab, canvas.transform);
                var        rect   = tip.transform as RectTransform;
                rect.anchoredPosition = new Vector2(0, 0);
                rect.sizeDelta        = new Vector2(Screen.width, Screen.height);
                tip.GetComponentInChildren <Text> ().text = DataManager._languageIndex == 1 ? "金币不足!" : "Not Enough Money";
            }
        }
        break;

        case SkinState.SS_UNSELECTED:
        {
            _toggle.isOn = true;
            _skinState   = SkinState.SS_SELECTED;
            PlayerPrefs.SetInt("CurrentSkin", _skinNum);
            Messenger <int> .Broadcast(GameEvent.CHANGE_SKIN, _skinNum);
        }
        break;

        case SkinState.SS_SELECTED:
            break;
        }
    }
Esempio n. 5
0
    public void SortingHeight(int highestNote, float noteHeight)
    {
        Vector2 temp;

        recordBg.GetComponentsInChildren <Image>()
        .Where(x => x.tag == "Node")
        .ToList()
        .ForEach(note =>
        {
            temp   = note.rectTransform.sizeDelta;
            temp.y = noteHeight;
            note.rectTransform.sizeDelta = temp;

            temp   = note.rectTransform.anchoredPosition;
            temp.y = -(noteHeight * (highestNote - int.Parse(note.gameObject.name)));
            note.rectTransform.anchoredPosition = temp;
        });
    }