Exemplo n.º 1
0
    public override bool Init(int index, SkyScrollPanel mySkyScrollPanel)
    {
        base.Init(index, mySkyScrollPanel);
        ElementButtonConfig config = ((ElementButtonConfig)(MySkyScrollPanel.Config));

        gameObject.name = "ElementButton" + index;
        b         = gameObject.transform.parent.Find(gameObject.name).GetComponent <Button> ();
        mytext    = gameObject.transform.Find("Text").GetComponent <Text> ();
        isSpecial = config.ConfigInfs [index].IsSpecial;
        if (((ElementButtonConfig)(MySkyScrollPanel.Config)).ConfigInfs [index].sprite == null)
        {
            mytext.text = config.ConfigInfs [index].desc;
        }
        else
        {
            b.image.sprite = config.ConfigInfs [index].sprite;
        }
        b.onClick.AddListener(() => ElementButtonConfig.ChoiseEvent(config.ConfigInfs [index].buttonConfigType));

        if (isSpecial)
        {
            timeRecord = new TimeRecord("test", SkyTime.MINUTE * 10, false);
        }
        return(true);
    }
Exemplo n.º 2
0
    public override bool Init(int index, SGScrollPanel mySkyScrollPanel)
    {
        base.Init(index, mySkyScrollPanel);
        ElementButtonConfig config = ((ElementButtonConfig)(MySkyScrollPanel.Config));

        gameObject.name = "ElementButton" + index;
        b      = gameObject.transform.parent.Find(gameObject.name).GetComponent <Button> ();
        mytext = gameObject.transform.Find("Text").GetComponent <Text> ();
        if (((ElementButtonConfig)(MySkyScrollPanel.Config)).ConfigInfs [index].sprite == null)
        {
            mytext.text = config.ConfigInfs [index].desc;
        }
        else
        {
            b.image.sprite = config.ConfigInfs [index].sprite;
        }

        b.onClick.AddListener(() => {
            GameController.GetInstance().GetPlayGameInstance().OnRoleSeleted(index % 2);
            GameController.GetInstance().GetMainPanel().Play();
        });

        return(true);
    }