protected override LoopListViewItem2 OnGetItemByIndex(LoopListView2 listView, int index)
    {
        if (index < 0 || index >= DataManger.TotalItemCount)
        {
            return(null);
        }
        GridItemData itemData = DataManger.GetItemDataByIndex(index);

        if (itemData == null)
        {
            return(null);
        }
        LoopListViewItem2 item = listView.NewListViewItem(ItemName);

        EquipItem itemScript = item.GetComponent <EquipItem>();

        itemScript.Init();
        itemScript.SetData(index, UnityEngine.Random.Range(1, 6), SpriteArray[UnityEngine.Random.Range(0, SpriteArray.Length)].name, UnityEngine.Random.Range(0, 2) == 1,
                           UnityEngine.Random.Range(1, 1000), UnityEngine.Random.Range(1, 6));
        itemScript.GetComponent <Button>().onClick.RemoveAllListeners();
        itemScript.GetComponent <Button>().onClick.AddListener(delegate
        {
            Debug.Log(itemScript.Index);
        });

        return(item);
    }
示例#2
0
    void Awake()
    {
        mAvatarImg      = transform.Find("avatar").GetComponent <RawImage>();
        mAvatarSpawnPos = GameObject.FindGameObjectWithTag(Tags.AvatarCamTag).transform.Find("SpawnPos");
        mWeaponTogGroup = transform.Find("weapon").GetComponent <ToggleGroup>();
        mWeaponGrid     = transform.Find("weapon/scroll/gridlayout").GetComponent <GridLayoutGroup>();
        mEnterBtn       = transform.Find("enter").GetComponent <Button>();
        mReturnBtn      = transform.Find("return").GetComponent <Button>();
        UIEventListener.Get(mAvatarImg.gameObject).onDrag  += OnDragAvatarImage;
        UIEventListener.Get(mEnterBtn.gameObject).onClick  += OnEnterBtnClick;
        UIEventListener.Get(mReturnBtn.gameObject).onClick += OnReturnBtnClick;

        ToggleGroup group = transform.Find("herolist").GetComponent <ToggleGroup>();

        Toggle[] toglist = group.GetComponentsInChildren <Toggle>();
        for (int i = 0; i < toglist.Length; i++)
        {
            AvatarItem item = new AvatarItem();
            item.Init(toglist[i], i);
            item.mAvatarItemClick += OnRoleToggleClick;
            mAvatarList.Add(item);
        }

        group   = transform.Find("equipment").GetComponent <ToggleGroup>();
        toglist = group.GetComponentsInChildren <Toggle>();
        for (int i = 0; i < toglist.Length; i++)
        {
            EquipItem item = new EquipItem();
            item.Init(toglist[i], i);
            item.mEquipItemClick += OnEquipToggleClick;
            mEquipList.Add(item);
        }

        if (mAvatarList.Count > 0)
        {
            mAvatarList[0].Selected();
        }
    }
示例#3
0
    public override void OnFirstOpen()
    {
        base.OnFirstOpen();

        wndPrepare = ViewManager.Get <WndPrepare>("WndPrepare");

        bagContainer     = GetGameObject("bagContainer");
        bagContainerRect = bagContainer.GetComponent <RectTransform>();

        bagMoveHeight = bagContainerRect.rect.height +
                        GetRectTransform("bagContainer/closeBtn").rect.height + 10;

        bagContainerRect.anchoredPosition = new Vector2(0, -bagMoveHeight);

        sellEquipGo = GetGameObject("bagContainer/sell");
        equipPrice  = GetText("bagContainer/sell/text");

        GameObject bagGrid = GetGameObject("bagContainer/bagList/grid");

        bagListRect = GetRectTransform("bagContainer/bagList");

        AddUIButton("bagContainer/closeBtn", (go) => { SetVisible(false); });

        //18个装备格子
        for (int i = 0; i < 18; i++)
        {
            var        equipItem = new EquipItem();
            GameObject go        = GameObject.Instantiate(bagGrid, bagListRect);

            equipItem.Init(go, i);
            equipItem.SetInfo(equipModel.GetEquip(i));
            equipItems[i] = equipItem;
        }
        bagGrid.SetActive(false);

        TimeManager.Regist((id) => { GameObject.Destroy(GetComponent <GridLayoutGroup>("bagContainer/bagList")); }
                           , 0.5f, 0, 1);
    }
示例#4
0
    protected override LoopListViewItem2 OnGetItemByIndex(LoopListView2 listView, int index)
    {
        if (index < 0 || index >= DataManger.TotalItemCount)
        {
            return(null);
        }
        GridItemData itemData = DataManger.GetItemDataByIndex(index);

        if (itemData == null)
        {
            return(null);
        }
        LoopListViewItem2 item = listView.NewListViewItem(ItemName);

        for (int i = 0; i < row; i++)
        {
            int       itemIndex  = index * row + i;
            EquipItem itemScript = item.transform.GetChild(i).GetComponent <EquipItem>();
            if (itemIndex >= DataManger.TotalDataCount)
            {
                itemScript.gameObject.SetActive(false);
                continue;
            }
            else
            {
                itemScript.gameObject.SetActive(true);
            }
            itemScript.Init();
            itemScript.SetData(itemIndex, UnityEngine.Random.Range(1, 6), SpriteArray[UnityEngine.Random.Range(0, SpriteArray.Length)].name, UnityEngine.Random.Range(0, 2) == 1,
                               UnityEngine.Random.Range(1, 1000), UnityEngine.Random.Range(1, 6));
            itemScript.GetComponent <Button>().onClick.RemoveAllListeners();
            itemScript.GetComponent <Button>().onClick.AddListener(delegate
            {
                Debug.Log(itemScript.Index);
            });
        }
        return(item);
    }
示例#5
0
    public void Reinit()
    {
        m_Title.text = m_CreatureEquip.Info.Name;
        if (EquipItem == null)
        {
            EquipItem = NGUITools.AddChild(m_Equip, EquipItemPrefab).GetComponent <EquipItem>();
        }
        EquipItem.Init(m_CreatureEquip);
        for (int i = 0; i < m_Stuffs.Length; ++i)
        {
            if (m_CreatureEquip.Stuffs.Count > i)
            {
                Stuffs[i].Init(m_CreatureEquip.Stuffs[i]);
            }
            else
            {
                Stuffs[i].gameObject.SetActive(false);
            }
        }
        m_GridStuff.Reposition();
        //m_ToggleUpgrade.value = m_CreatureEquip.EnchantLevel == 5;
        //m_LabelUpgradeCondition.text = Localization.Format("ConditionEquipUpgrade", m_CreatureEquip.Info.NextEquipLevel);

        if (m_CreatureEquip.EnchantLevel == 5)
        {
            m_Label.text = Localization.Get("Upgrade");
        }
        else
        {
            m_Label.text = Localization.Get("Enchant");
        }

        if (m_ParticleReady != null)
        {
            m_ParticleReady.gameObject.SetActive(m_CreatureEquip.IsNotify);
        }
    }
示例#6
0
    public void Init()
    {
        UpdateEventIcon();
        m_EnchantBtnLabel.text = (m_Creature.Grade >= 6 && m_Creature.Enchant >= 5) ? Localization.Get("OverEnchant") : Localization.Get("Enchant");
        //m_CreatureType.spriteName = string.Format("hero_info_type_{0}", m_Creature.Info.ShowAttackType);
        m_CreatureType.spriteName = string.Format("New_hero_info_type_{0}", m_Creature.Info.ShowAttackType);
        m_LabelName.text          = m_Creature.Info.Name;
        if (m_Creature.Enchant > 0)
        {
            m_LabelName.text += " " + m_Creature.GetEnchantText();
        }
        m_LeftLabelLevel.text = m_Creature.GetLevelText();
        m_LabelLevel.text     = Localization.Format("HeroLevelDesc", m_Creature.Level, m_Creature.LevelLimit);

        UpdateLock();

        m_CharacterContainer.Init(AssetManager.GetCharacterAsset(m_Creature.Info.ID, m_Creature.SkinName), UICharacterContainer.Mode.UI_Normal, "win");
        m_CharacterContainer.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
        m_CharacterContainer.SetPlay(UICharacterContainer.ePlayType.Social);

        if (m_Creature.Info.TeamSkill != null)
        {
            if (m_TeamSkill.atlas.Contains(m_Creature.TeamSkill.Info.ID) == true)
            {
                m_TeamSkill.spriteName = m_Creature.TeamSkill.Info.ID;
            }
            else
            {
                m_TeamSkill.spriteName = "skill_default";
            }
            m_TeamSkill.gameObject.transform.parent.parent.gameObject.SetActive(true);
        }
        else
        {
            m_TeamSkill.gameObject.transform.parent.parent.gameObject.SetActive(false);
        }

        for (int i = 0; i < m_Stars.Length; ++i)
        {
            m_Stars[i].SetSpriteActive(m_Creature.Grade > i);
            m_Stars[i].gameObject.SetActive(m_Creature.Grade > i);
        }
        m_GridStars.Reposition();

        // equips
        if (m_Weapon == null)
        {
            m_Weapon = NGUITools.AddChild(m_WeaponIndicator, EquipItemPrefab).GetComponent <EquipItem>();
        }
        if (m_Armor == null)
        {
            m_Armor = NGUITools.AddChild(m_ArmorIndicator, EquipItemPrefab).GetComponent <EquipItem>();
        }
        m_Weapon.Init(m_Creature.Weapon);
        //m_WeaponParts.Init(m_Creature.Weapon);

        m_Armor.Init(m_Creature.Armor);
        //m_ArmorParts.Init(m_Creature.Armor);


        // skills
        List <Skill> active_skills = m_Creature.GetSkillsByType(eSkillType.active);

        for (int i = 0; i < m_ActiveSkills.Length; ++i)
        {
            bool active = i < active_skills.Count;
            m_ActiveSkills[i].gameObject.SetActive(active);
            if (active)
            {
                m_ActiveSkills[i].Init(active_skills[i]);
            }
        }

        List <Skill> passive_skills = m_Creature.GetSkillsByType(eSkillType.passive);

        for (int i = 0; i < m_PassiveSkills.Length; ++i)
        {
            bool active = i < passive_skills.Count;
            m_PassiveSkills[i].gameObject.SetActive(active);
            if (active)
            {
                m_PassiveSkills[i].Init(passive_skills[i]);
            }
        }


        bool move = m_Creatures != null && m_Creatures.Count > 0;

        m_ButtonLeft.SetActive(move);
        m_ButtonRight.SetActive(move);
        if (move)
        {
            UpdateNextCreatureIcon();
        }

        for (int i = 0; i < 10; ++i)
        {
            if (m_RuneList.Count <= i)
            {
                RuneItem item = RuneItemPrefab.GetNewObject <RuneItem>(m_GridRune.transform, Vector3.zero);
                m_RuneList.Add(item);
            }

            if (m_Creature.Runes.Count <= i)
            {
                m_RuneList[i].Init(null, m_Creature.RuneSlotCount <= i, null, i);
            }
            else
            {
                m_RuneList[i].Init(m_Creature.Runes[i], false, null, i);
            }
        }
        m_GridRune.Reposition();

        InitHeroInfo();
        InitSkillInfo();
        InitRuneInfo();
        InitEvolveInfo();
    }