示例#1
0
    private void InitMountItems()
    {
        Dictionary <int, DActor> mounts = new Dictionary <int, DActor>();

        foreach (var current in ReadCfgActor.Dict)
        {
            if (current.Value.Type != EActorType.MOUNT)
            {
                continue;
            }
            mounts.Add(current.Key, current.Value);
        }
        int group = GTWindowManager.Instance.GetToggleGroupId();

        foreach (KeyValuePair <int, DActor> pair in mounts)
        {
            GameObject item = NGUITools.AddChild(grid.gameObject, template);
            item.SetActive(true);
            UIToggle toggle = item.GetComponent <UIToggle>();
            toggle.group = group;

            ItemMount tab = new ItemMount();
            tab.id      = pair.Value.Id;
            tab.toggle  = toggle;
            tab.btn     = item;
            tab.quality = item.transform.GetComponent <UISprite>();
            tab.icon    = item.transform.Find("Icon").GetComponent <UISprite>();
            tab.dress   = item.transform.Find("Dress").gameObject;
            int index = mMountItems.Count;

            UIEventListener.Get(tab.btn).onClick = (GameObject go) =>
            {
                GTAudioManager.Instance.PlayEffectAudio(GTAudioKey.SOUND_UI_CLICK);
                if (mSelectIndex == index)
                {
                    return;
                }
                mSelectIndex = index;
                UIMount.SetSelectMountID(tab.id);
                ShowView();
            };

            mMountItems.Add(tab);
        }
        mMountItems[0].toggle.value = true;
        UIMount.SetSelectMountID(mMountItems[0].id);
    }
示例#2
0
 private void OnFightClick(GameObject go)
 {
     GTAudioManager.Instance.PlayEffectAudio(GTAudioKey.SOUND_UI_CLICK);
     MountService.Instance.TryChangeMount(UIMount.GetSelectMountID());
 }