示例#1
0
    void GetCurCharInfo()
    {
        if (m_menu[(int)eLobbyMenuType.Character].m_type == eLobbyMenuType.Character)
        {
            LobbyMenu_Character menu = m_menu[(int)eLobbyMenuType.Character].gObj.GetComponent <LobbyMenu_Character>();
            var spr = menu.GetCharSprite();
            var pos = menu.GetCharSprPosition(PlayerDataManager.Instance.GetCurHero() - 1);

            //로비의 캐릭터 이미지를 현재 선택된 것으로 변경
            m_charSpr.sprite2D = spr;
            m_charSpr.MakePixelPerfect();
            m_charSpr.transform.localPosition = pos + Vector3.up * 80f;

            //캐릭터 아이콘도 변경
            m_charIconSpr.spriteName = string.Format("select_character_{0:00}", PlayerDataManager.Instance.GetCurHero());

            //각 캐릭터의 이미지마다 Tween 포지션이 다르므로 각자의 포지션으로 변경 후 시작시켜줌.
            m_charTween.from = m_charSpr.transform.localPosition;
            m_charTween.to   = m_charTween.from + Vector3.down * 20f;
            m_charTween.ResetToBeginning();
            m_charTween.PlayForward();
        }
    }
    void LoadInventoryInfo()
    {
        m_charMenu = m_charMenu.gObj.GetComponent <LobbyMenu_Character>();
        var spr = m_charMenu.GetCharSprite();
        var pos = m_charMenu.GetCharSprPosition(PlayerDataManager.Instance.GetCurHero() - 1);

        //로비의 캐릭터 이미지를 현재 선택된 것으로 변경
        m_charSpr.sprite2D = spr;
        m_charSpr.MakePixelPerfect();
        m_charSpr.transform.localPosition = pos + Vector3.up * 400f;

        m_charTween.from = m_charSpr.transform.localPosition;
        m_charTween.to   = m_charTween.from + Vector3.down * 20f;
        m_charTween.ResetToBeginning();
        m_charTween.PlayForward();


        for (int i = 0; i < PlayerDataManager.Instance.GetEquipmentsNums(); i++)
        {
            if (PlayerDataManager.Instance.IsOwnedItem(i))
            {
                string target = string.Format("Equipment/Equipment_{0:00}", i + 1);

                if (!m_itemDict.ContainsKey(target))
                {
                    GameObject equips = Resources.Load <GameObject>(target);

                    var  equip = Instantiate(equips) as GameObject;
                    Item item  = equip.GetComponent <Item>();

                    m_itemDict.Add(target, item);

                    equip.transform.SetParent(m_uiGrid.transform);
                    equip.transform.localPosition = Vector3.zero;
                    equip.transform.localScale    = Vector3.one;

                    //장착되어있던 장비들 처리.
                    if (PlayerDataManager.Instance.IsEquippedItem(item.m_class, (int)item.m_type))
                    {
                        switch (item.m_class)
                        {
                        case Item.eItemClass.Weapon:
                            m_equipItems[0].spriteName = item.m_icon.spriteName;
                            break;

                        case Item.eItemClass.Armor:
                            m_equipItems[1].spriteName = item.m_icon.spriteName;
                            break;

                        case Item.eItemClass.Acc:
                            m_equipItems[2].spriteName = item.m_icon.spriteName;
                            break;

                        default:
                            break;
                        }
                    }
                }
            }
        }

        m_uiGrid.Reposition(); //다시 자식들을 정렬하게함.
    }