/// <summary>
    /// パーティリストの作成
    /// </summary>
    void CreatePartyList()
    {
        PacketStructUnit[][] partys = UserDataAdmin.Instance.m_StructPartyAssign;
        m_PartySelectGroup.ClearPartyGroups();

        var       partyModels         = new List <PartySelectGroupUnitListItemModel>();
        const int AnimationFirstIndex = 0;
        const int AnimationLastIndex  = 4;

        for (int i = 0; i < partys.Length; ++i)
        {
            PacketStructUnit[] party = partys[i];
            int index = i;
            var model = new PartySelectGroupUnitListItemModel((uint)index);

            PartySelectGroupUnitContext partyGroup = new PartySelectGroupUnitContext(model);
            partyGroup.Index    = index;                                                           // 番号の設定
            partyGroup.NameText = string.Format(GameTextUtil.GetText("questlast_tub"), index + 1); // パーティ名
            Array.Copy(party, partyGroup.PartyData, partyGroup.PartyData.Length);                  // ユニット情報をコピー
            for (int pt_cout = 0; pt_cout < partyGroup.PartyData.Length; ++pt_cout)
            {
                // リンクユニット情報を設定
                if (partyGroup.PartyData[pt_cout] == null)
                {
                    continue;
                }
                partyGroup.PartyLinkData[pt_cout] = CharaLinkUtil.GetLinkUnit(partyGroup.PartyData[pt_cout].link_unique_id);
            }

            PacketStructUnit leaderUnit = partyGroup.PartyData[(int)GlobalDefine.PartyCharaIndex.LEADER];
            if (leaderUnit != null)
            {
                // リーダーユニット画像
                UnitIconImageProvider.Instance.Get(
                    leaderUnit.id,
                    sprite =>
                {
                    partyGroup.UnitImage = sprite;
                });
                //partyGroup.IsActiveLinkIcon = (leaderUnit.link_info != (uint)ServerDataDefine.CHARALINK_TYPE.CHARALINK_TYPE_NONE); // リンクアイコン
                MasterDataParamChara _master = MasterFinder <MasterDataParamChara> .Instance.Find((int)leaderUnit.id);

                partyGroup.IconSelect = MainMenuUtil.GetElementCircleSprite(_master.element);
            }
            partyGroup.IsSelect = (index == m_UnitPartyCurrent);
            m_PartySelectGroup.AddData(partyGroup);
            model.OnClicked += () =>
            {
                OnSelectPartyGroup(partyGroup);
            };

            model.OnShowedNextIcon += () =>
            {
                if (index <= AnimationFirstIndex ||
                    index > AnimationLastIndex)
                {
                    return;
                }

                partyModels[index - 1].ShowIcon();
            };
            model.OnShowedNextName += () =>
            {
                if (index >= AnimationLastIndex)
                {
                    return;
                }

                partyModels[index + 1].ShowName();
            };

            model.OnViewStarted += () =>
            {
                bool showName = index == AnimationFirstIndex ||
                                index > AnimationLastIndex;
                bool showIcon = index == AnimationLastIndex ||
                                index > AnimationLastIndex;

                if (showName)
                {
                    model.ShowName();
                }
                if (showIcon)
                {
                    model.ShowIcon();
                }
            };

            partyModels.Add(model);
        }
    }
Exemple #2
0
 public PartySelectGroupUnitContext(PartySelectGroupUnitListItemModel listItemModel)
 {
     m_model = listItemModel;
 }
    public override void OnInitialized()
    {
        base.OnInitialized();

        m_PartyMemberStatusPanel = GetComponentInChildren <PartyMemberStatusPanel>();

        // マスターデータ
        List <MasterDataParamChara> charaMasterDatas = MasterFinder <MasterDataParamChara> .Instance.FindAll();


        // パーティ
        for (int i = 0; i < m_PartyCount; ++i)
        {
            var model = new PartySelectGroupUnitListItemModel((uint)i);

            PartySelectGroupUnitContext party = new PartySelectGroupUnitContext(model);
            UnitIconImageProvider.Instance.Get(
                charaMasterDatas[Random.Range(0, 1800)].fix_id,
                sprite => { party.UnitImage = sprite; });
            party.NameText = string.Format(GameTextUtil.GetText("questlast_tub"), i + 1);
            m_PartySelectGroup.AddData(party);
            model.OnClicked += () => {
                m_PartySelectGroup.ChangePartyItemSelect(party.Index); // パーティ選択状態を変更
            };
        }

        // パーティメンバー
        for (int i = 0; i < 4; ++i)
        {
            var unitDataModel = new PartyMemberUnitListItemModel((uint)i);

            PartyMemberUnitContext unit = new PartyMemberUnitContext(unitDataModel);
            UnitIconImageProvider.Instance.Get(
                charaMasterDatas[Random.Range(0, 1800)].fix_id,
                sprite => { unit.UnitImage = sprite; });
            m_PartyMemberUnitGroup.Units.Add(unit);
            unitDataModel.OnClicked += () => {
                unit.DidSelectItem(unit); // TODO : DidSelectItem()の内容と差し替え
            };
            unitDataModel.OnLongPressed += () => {
                unit.DidLongPressItem(unit); // TODO : DidLongPressItem()の内容と差し替え
            };
        }

        // クエストパーティメンバー
        for (int i = 0; i < 5; ++i)
        {
            var unitDataModel = new PartyMemberUnitListItemModel((uint)i);

            PartyMemberUnitContext unit = new PartyMemberUnitContext(unitDataModel);
            UnitIconImageProvider.Instance.Get(
                charaMasterDatas[Random.Range(0, 1800)].fix_id,
                sprite => { unit.UnitImage = sprite; });
            //m_PartyParamQuestPartyPanel.Units.Add(unit);
            unitDataModel.OnClicked += () => {
                unit.DidSelectItem(unit); // TODO : DidSelectItem()の内容と差し替え
            };
            unitDataModel.OnLongPressed += () => {
                unit.DidLongPressItem(unit); // TODO : DidLongPressItem()の内容と差し替え
            };
        }

        for (int i = 0; i < 4; ++i)
        {
            PartyMemberStatusListItemContext status = new PartyMemberStatusListItemContext();
            m_PartyMemberStatusPanel.UnitStatusParams.Add(status);
        }
    }
    void Start()
    {
        m_model = Context.model;

        SetModel(m_model);

        m_model.OnShowedIcon += () =>
        {
            m_icon.Show(
                // onNext
                () =>
            {
                m_model.ShowNextIcon();
            },
                // onFinish
                () =>
            {
                m_iconShowFinish = true;
            });
        };

        m_model.OnShowedName += () =>
        {
            m_name.Show(() =>
            {
                m_model.ShowNextName();
            });
        };

        m_model.OnUpdated += () =>
        {
            if (!m_icon.isShowed)
            {
                return;
            }

            if (m_model.isSelected)
            {
                m_icon.ShowArrow();
            }
            else
            {
                m_icon.HideArrow();
            }


            if (m_model.isSelected)
            {
                m_name.Select();
            }
        };

        // TODO : 演出あるならしかるべき場所に移動
        m_listItemModel.Appear();
        m_listItemModel.SkipAppearing();

        m_model.ViewStarted();

        if (m_button != null)
        {
            // ボタンの選択画像を設定
            if (Context.IsLowerScreen)
            {
                m_button.targetGraphic = m_nameBG;
            }
            else
            {
                m_button.targetGraphic = m_unitIcon;
            }
        }
    }