コード例 #1
0
    public void NewSpell(string spell)
    {
        GameObject spellToBeAdded;

        if (newSpellBtns.TryGetValue(spell, out spellToBeAdded))
        {
            Debug.Log("Spell already exists");
        }
        else
        {
            GameObject  splBtnGo = GameObjectUtility.CustomInstantiate(spellButton.gameObject, transform);
            SpellButton splBtn   = splBtnGo.GetComponent <SpellButton>();
            splBtn.Initialize(spell, this);
            newSpellBtns.Add(spell, splBtnGo);
        }
    }
コード例 #2
0
    public void Initialize(List <string> spells, Hero user)
    {
        this.user    = user;
        newSpellBtns = new Dictionary <string, GameObject>();
        foreach (string spell in spells)
        {
            GameObject  splBtnGo = GameObjectUtility.CustomInstantiate(spellButton.gameObject, transform);
            SpellButton splBtn   = splBtnGo.GetComponent <SpellButton>();
            splBtn.Initialize(spell, this);
        }

        displayPanelGameObject = GameObject.Find("DisplayPanel");
        displayPanel           = displayPanelGameObject.GetComponent <DisplayPanel>();

        GameObject BackBtnGO = GameObjectUtility.CustomInstantiate(BackSpaceBtn.gameObject, transform);

        BackBtnGO.GetComponent <Button>().onClick.RemoveAllListeners();
        BackBtnGO.GetComponent <Button>().onClick.AddListener(() => { BackSpace(); });
        GameObject ClearBtnGO = GameObjectUtility.CustomInstantiate(ClearAllBtn.gameObject, transform);

        ClearBtnGO.GetComponent <Button>().onClick.RemoveAllListeners();
        ClearBtnGO.GetComponent <Button>().onClick.AddListener(() => { ClearAll(); });
    }