/// <summary>
    /// パーティユニットをリジェクト
    /// </summary>
    /// <param name="selectUnit"></param>
    /// <param name="isChangeUnitGridMark">trueにするとアイコンの状態が更新されない</param>
    public void RejectPartyUnit(PartyMemberUnitContext selectUnit, bool isChangeUnitGridMark = true)
    {
        if (selectUnit == null)
        {
            return;
        }

        if (selectUnit.UnitData == null)
        {
            return;
        }


        UnitIconImageProvider.Instance.Reset(selectUnit.UnitData.id);

        selectUnit.UnitData       = null;
        selectUnit.UnitImage      = ResourceManager.Instance.Load("icon_empty2");
        selectUnit.LinkIcon       = null;
        selectUnit.IsEnalbeSelect = false;
        selectUnit.IsElement      = false;

        selectUnit.LinkOutSideCircleImage = ResourceManager.Instance.Load("icon_circle_deco", ResourceType.Common);
        selectUnit.LinkUnitImage          = ResourceManager.Instance.Load("icon_empty2", ResourceType.Menu);
        selectUnit.IsEmptyLinkUnit        = true;

        m_IsPartyMemberChange = true;

        SetupLinkChara(selectUnit);

        ChangeStatus(selectUnit.UnitData, selectUnit.PartyCharaIndex, GetPartyPacketStructUnits());
        if (isChangeUnitGridMark)
        {
            ChangeMemberUnitSelect(null);
        }
    }
    /// <summary>
    /// パーティの全解除
    /// </summary>
    void OnUnitRelease()
    {
        //
        if (TutorialManager.IsExists)
        {
            return;
        }

        SoundUtil.PlaySE(SEID.SE_MENU_RET);

        if (m_PartyMemberUnitGroup == null)
        {
            return;
        }
        for (int i = 0; i < m_PartyMemberUnitGroup.Units.Count; ++i)
        {
            PartyMemberUnitContext unit = m_PartyMemberUnitGroup.Units[i];
            if (unit.PartyCharaIndex == GlobalDefine.PartyCharaIndex.LEADER)
            {
                continue;
            }
            RejectPartyUnit(unit, false);
        }
        CheckUnitSpace();
    }
    /// <summary>
    /// パーティのユニットを長押ししたとき
    /// </summary>
    /// <param name="_unit"></param>
    void OnLongPressParamUnit(PartyMemberUnitContext _unit, MainMenuTutorialHeroSelect heroSelect)
    {
        if (heroSelect.isSelect)
        {
            return;
        }

        if (heroSelect.isDecision)
        {
            return;
        }

        if (heroSelect.isfinishDecision)
        {
            return;
        }

        if (_unit.UnitData != null &&
            _unit.UnitData.id > 0 &&
            MainMenuManager.HasInstance)
        {
            SoundUtil.PlaySE(SEID.SE_MENU_OK2);
            MainMenuManager.Instance.OpenUnitDetailInfoPlayerTutorial(_unit.UnitData, false);
        }
    }
    /// <summary>
    /// リンクキャラの作成
    /// </summary>
    /// <param name="unit"></param>
    void SetupLinkChara(PartyMemberUnitContext unit)
    {
        if (unit != null && unit.UnitData != null)
        {
            var linkData = CharaLinkUtil.GetLinkUnit(unit.UnitData.link_unique_id);
            List <MasterDataParamChara> charaMasterList = MasterFinder <MasterDataParamChara> .Instance.FindAll();

            if (linkData != null && linkData.id > 0)
            {
                unit.LinkCharaMaster = charaMasterList.Find((v) => v.fix_id == linkData.id);
                UnitIconImageProvider.Instance.Get(
                    linkData.id,
                    sprite =>
                {
                    unit.LinkUnitImage = sprite;
                });
                unit.IsEmptyLinkUnit = false;

                if (unit.LinkCharaMaster != null)
                {
                    unit.LinkOutSideCircleImage = MainMenuUtil.GetElementCircleSprite(unit.LinkCharaMaster.element);
                }
                return;
            }
        }
        unit.LinkOutSideCircleImage = ResourceManager.Instance.Load("icon_circle_deco", ResourceType.Common);
        unit.LinkUnitImage          = ResourceManager.Instance.Load("icon_empty2", ResourceType.Menu);
        unit.IsEmptyLinkUnit        = true;
    }
 /// <summary>
 /// ユニットの選択状態を変更
 /// </summary>
 /// <param name="unit"></param>
 public void ChangeUnitParam(PartyMemberUnitContext unit)
 {
     for (int i = 0; i < Units.Count; ++i)
     {
         if (unit != null)
         {
             Units[i].IsSelect = (ReferenceEquals(Units[i], unit));
         }
         else
         {
             Units[i].IsSelect = false;
         }
     }
     // Canvas移動はこのタイミング
     if (SceneObjReferMainMenu.Instance.m_MainMenuRoot)
     {
         var newParent = SceneObjReferMainMenu.Instance.m_MainMenuRoot.transform.Find("UIMainMenu/TopAnchor/MainMenuHeader(Clone)/PartyMemberUnitGroupRoot");
         if (newParent == null)
         {
             newParent = GameObject.Find("PartyMemberUnitGroupRoot").transform;
         }
         if (newParent != null)
         {
             transform.SetParent(newParent);
         }
     }
 }
 /// <summary>
 /// パーティのユニットを長押ししたとき
 /// </summary>
 /// <param name="_unit"></param>
 void OnLongPressParamUnit(PartyMemberUnitContext _unit)
 {
     if (_unit.UnitData != null && _unit.UnitData.id > 0 && MainMenuManager.HasInstance)
     {
         m_PartyParamPanel.m_CarouselRotator.SetIndex(m_PartyParamPanel.m_CurrentIndex, true);
         SoundUtil.PlaySE(SEID.SE_MENU_OK2);
         MainMenuManager.Instance.OpenUnitDetailInfoPlayer(_unit.UnitData);
     }
 }
 /// <summary>
 /// パーティのユニットを押したとき
 /// </summary>
 /// <param name="_unit"></param>
 void OnSelectParamUnit(PartyMemberUnitContext _unit)
 {
     SoundUtil.PlaySE(SEID.SE_MENU_OK);
     SendUnitPartyAssign(() =>
     {
         // パーティユニット選択画面に移る
         MainMenuParam.m_PartyAssignPrevPage = MAINMENU_SEQ.SEQ_UNIT_PARTY_SELECT;
         MainMenuManager.Instance.AddSwitchRequest(MAINMENU_SEQ.SEQ_UNIT_PARTY_FORM, false, false);
     });
     m_IsRequestedApi = true;
 }
    void SetUpCharaData(ref PartyMemberUnitContext item, PacketStructUnit _mainUnit, PacketStructUnit _subUnit, bool dispCharm)
    {
        CharaOnce baseChara = new CharaOnce();

        if (_mainUnit.link_info == (uint)ServerDataDefine.CHARALINK_TYPE.CHARALINK_TYPE_BASE &&
            _subUnit != null)
        {
            baseChara.CharaSetupFromID(
                _mainUnit.id,
                (int)_mainUnit.level,
                (int)_mainUnit.limitbreak_lv,
                (int)_mainUnit.limitover_lv,
                (int)_mainUnit.add_pow,
                (int)_mainUnit.add_hp,
                _subUnit.id,
                (int)_subUnit.level,
                (int)_subUnit.add_pow,
                (int)_subUnit.add_hp,
                (int)_mainUnit.link_point,
                (int)_subUnit.limitover_lv
                );
        }
        else
        {
            baseChara.CharaSetupFromID(
                _mainUnit.id,
                (int)_mainUnit.level,
                (int)_mainUnit.limitbreak_lv,
                (int)_mainUnit.limitover_lv,
                (int)_mainUnit.add_pow,
                (int)_mainUnit.add_hp,
                0,
                0,
                0,
                0,
                0,
                0
                );
        }

        item.HpText  = baseChara.m_CharaHP.ToString();
        item.AtkText = baseChara.m_CharaPow.ToString();
    }
    /// <summary>
    /// パーティのユニットを長押ししたとき
    /// </summary>
    /// <param name="_unit"></param>
    public void OnSelectUnitLongPress(PartyMemberUnitContext _unit)
    {
        //
        if (TutorialManager.IsExists)
        {
            return;
        }

        //ユニット詳細画面へ
        if (_unit.UnitData != null && _unit.UnitData.id > 0 && MainMenuManager.HasInstance)
        {
            SoundUtil.PlaySE(SEID.SE_MENU_OK2);

            UnitGridContext unitContext = m_UnitGrid.GridView.GetItem(_unit.UnitData.unique_id);
            if (unitContext != null)
            {
                openUnitDetailInfo(unitContext);
            }
        }
    }
    /// <summary>
    /// パーティメンバーを選択したとき
    /// </summary>
    /// <param name="unit"></param>
    void OnSelectPartyMemberUnit(PartyMemberUnitContext unit)
    {
        //
        if (TutorialManager.IsExists)
        {
            return;
        }

        if (unit.PartyCharaIndex != GlobalDefine.PartyCharaIndex.LEADER)
        {
            if (unit.UnitData != null)
            {
                SoundUtil.PlaySE(SEID.SE_MENU_RET);
            }
            RejectPartyUnit(unit);
            ChangeMemberUnitSelect(unit);
        }
        else
        {
            SoundUtil.PlaySE(SEID.SE_MENU_OK);
            ChangeMemberUnitSelect(unit);
        }
    }
    public void SetUnitData(ref PartyMemberUnitContext unit, PacketStructUnit unitData)
    {
        if (unit == null)
        {
            return;
        }
        if (unitData == null || unitData.id == 0)
        {
            return;
        }
        MasterDataParamChara charMaster = MasterFinder <MasterDataParamChara> .Instance.Find((int)unitData.id);

        if (charMaster == null)
        {
            return;
        }
        if (charMaster.skill_active0 > 0)
        {
            MasterDataSkillActive skill1 = MasterFinder <MasterDataSkillActive> .Instance.Find((int)charMaster.skill_active0);

            if (skill1 != null)
            {
                unit.IsActiveSkill1Empty = false;
                unit.Skill1Cost1         = MainMenuUtil.GetSkillElementIcon(skill1.cost1);
                unit.Skill1Cost2         = MainMenuUtil.GetSkillElementIcon(skill1.cost2);
                unit.Skill1Cost3         = MainMenuUtil.GetSkillElementIcon(skill1.cost3);
                unit.Skill1Cost4         = MainMenuUtil.GetSkillElementIcon(skill1.cost4);
                unit.Skill1Cost5         = MainMenuUtil.GetSkillElementIcon(skill1.cost5);
                unit.Skill1Color         = MainMenuUtil.GetSkillElementColor("S1", skill1.skill_element);
            }
        }

        if (charMaster.skill_active1 > 0)
        {
            MasterDataSkillActive skill2 = MasterFinder <MasterDataSkillActive> .Instance.Find((int)charMaster.skill_active1);

            if (skill2 != null)
            {
                unit.IsActiveSkill2Empty = false;
                unit.Skill2Cost1         = MainMenuUtil.GetSkillElementIcon(skill2.cost1);
                unit.Skill2Cost2         = MainMenuUtil.GetSkillElementIcon(skill2.cost2);
                unit.Skill2Cost3         = MainMenuUtil.GetSkillElementIcon(skill2.cost3);
                unit.Skill2Cost4         = MainMenuUtil.GetSkillElementIcon(skill2.cost4);
                unit.Skill2Cost5         = MainMenuUtil.GetSkillElementIcon(skill2.cost5);
                unit.Skill2Color         = MainMenuUtil.GetSkillElementColor("S2", skill2.skill_element);
            }
        }

        unit.ParamText = (unitData.level >= charMaster.level_max) ? GameTextUtil.GetText("uniticon_flag1")
                                    : string.Format(GameTextUtil.GetText("uniticon_flag2"), unitData.level); // レベル

        uint plusPoint = unitData.add_hp + unitData.add_pow;                                                 // プラス値の計算

        if (plusPoint != 0)
        {
            unit.ParamText += string.Format(GameTextUtil.GetText("uniticon_flag3"), plusPoint);
        }

        unit.LinkIcon           = MainMenuUtil.GetLinkMark(unitData, null); // リンクアイコン
        unit.OutSideCircleImage = MainMenuUtil.GetElementCircleSprite(charMaster.element);
        SetUpCharaData(ref unit, unitData, CharaLinkUtil.GetLinkUnit(unitData.link_unique_id), false);
    }
    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);
        }
    }
 /// <summary>
 /// ユニットの選択状態を変更する
 /// </summary>
 void ChangeMemberUnitSelect(PartyMemberUnitContext unit)
 {
     m_PartyMemberUnitGroup.ChangeUnitParam(unit);
     m_SelectPartyCharaIndex = (unit != null) ? unit.PartyCharaIndex : GlobalDefine.PartyCharaIndex.ERROR;
     ChangeUnitGridMark();
 }
    /// <summary>
    /// パーティメンバー一覧の作成
    /// </summary>
    void CreatePartyMemberUnitGroup()
    {
        PacketStructUnit[][] partys = UserDataAdmin.Instance.m_StructPartyAssign;
        PacketStructUnit[]   party  = new PacketStructUnit[(int)GlobalDefine.PartyCharaIndex.MAX - 1];
        Array.Copy(partys[m_CurrentSelectPartyIndex], party, party.Length); // ユニット情報をコピー

        List <PartyMemberUnitContext> unitList = new List <PartyMemberUnitContext>();

        foreach (PacketStructUnit unitData in party)
        {
            int index = unitList.Count;
            var model = new PartyMemberUnitListItemModel((uint)index);

            PartyMemberUnitContext unit = new PartyMemberUnitContext(model);
            unit.UnitData = unitData;
            if (unitData != null)
            {
                // ユニット画像
                UnitIconImageProvider.Instance.Get(
                    unitData.id,
                    sprite =>
                {
                    unit.UnitImage = sprite;
                },
                    true);
                unit.LinkIcon       = MainMenuUtil.GetLinkMark(unitData);
                unit.IsEnalbeSelect = true;
                MasterDataParamChara _master = MasterFinder <MasterDataParamChara> .Instance.Find((int)unitData.id);

                unit.IconSelect = MainMenuUtil.GetElementCircleSprite(_master.element);
                unit.IsElement  = true;
            }
            else
            {
                unit.UnitImage      = ResourceManager.Instance.Load("icon_empty2");
                unit.IsEnalbeSelect = false;
                unit.IsElement      = false;
            }

            SetupLinkChara(unit);

            unit.DidSelectItem    = OnSelectPartyMemberUnit;
            unit.DidLongPressItem = OnSelectUnitLongPress;
            unitList.Add(unit);
        }

        unitList[0].PartyCharaIndex = GlobalDefine.PartyCharaIndex.LEADER;
        unitList[1].PartyCharaIndex = GlobalDefine.PartyCharaIndex.MOB_1;
        unitList[2].PartyCharaIndex = GlobalDefine.PartyCharaIndex.MOB_2;
        unitList[3].PartyCharaIndex = GlobalDefine.PartyCharaIndex.MOB_3;

        m_PartyMemberUnitGroup.Units = unitList;
        m_PartyMemberUnitGroup.OnClickReleaseAction = OnUnitRelease;
        m_PartyMemberUnitGroup.OnClickDetailAction  = OnDetailWindow;
        m_PartyMemberUnitGroup.OnClickLinkAction    = OnSelectLink;

        CharaUtil.setupCharaParty(ref m_PartyMemberUnitGroup.PartyInfo, party); // パーティ情報の設定

        //DG0-4124 対応
        if (TutorialManager.HasInstance)
        {
            UnitIconImageProvider.Instance.Tick();
        }
    }
    /// <summary>
    /// パーティ詳細情報の変更
    /// </summary>
    void CreatePartyParam()
    {
        PacketStructUnit[][] partys = UserDataAdmin.Instance.m_StructPartyAssign;
        m_PartyParamPanel.m_CurrentIndex = m_UnitPartyCurrent;
        m_PartyParamPanel.PartyParams.Clear();
        m_PartyParamPanel.OnChangedPartyParamAction = OnChangedPartyParam;
        List <MasterDataParamChara> charaMasterList = MasterFinder <MasterDataParamChara> .Instance.FindAll();

        m_partyPanels.Clear();

        for (int i = 0; i < partys.Length; ++i)
        {
            int index           = i;
            var partyPanelModel = new PartyParamListItemModel((uint)index);

            PartyParamListItemContext   paertParam = new PartyParamListItemContext(partyPanelModel);
            PartySelectGroupUnitContext party      = m_PartySelectGroup.GetParty(i);


            m_partyPanels.Add(partyPanelModel);

            //--------------------------------------------
            // パーティ情報
            //--------------------------------------------
            if (m_PartyParamPanel != null)
            {
                CharaUtil.setupCharaParty(ref paertParam.PartyInfo, party.PartyData); // パーティ情報の設定
                paertParam.NameText = string.Format(GameTextUtil.GetText("questlast_text7"), party.Index + 1);
                paertParam.CostText = string.Format(GameTextUtil.GetText("questlast_text5"), paertParam.PartyInfo.m_PartyTotalCost
                                                    , UserDataAdmin.Instance.m_StructPlayer.total_party);                              // Cost
                paertParam.CharmText = string.Format(GameTextUtil.GetText("questlast_text6"), paertParam.PartyInfo.m_PartyTotalCharm); // CHARM
            }

            //-------------------------
            // ユニット設定
            //-------------------------
            List <PartyMemberUnitContext> unitList = new List <PartyMemberUnitContext>();
            int unitDataIndex = 0;
            for (int pt_count = 0; pt_count < party.PartyData.Length; ++pt_count)
            {
                PacketStructUnit unitData = party.PartyData[pt_count];
                PacketStructUnit linkData = party.PartyLinkData[pt_count];

                var unitDataModel           = new PartyMemberUnitListItemModel((uint)unitDataIndex++);
                PartyMemberUnitContext unit = new PartyMemberUnitContext(unitDataModel);
                unit.IsActiveStatus    = true;
                unit.IsActiveParamText = true;
                if (unitData != null)
                {
                    unit.CharaMaster = charaMasterList.Find((v) => v.fix_id == unitData.id);
                    UnitIconImageProvider.Instance.Get(
                        unitData.id,
                        sprite =>
                    {
                        unit.UnitImage = sprite;
                    });
                    unit.UnitData = unitData;
                    unitDataModel.OnLongPressed += () =>
                    {
                        OnLongPressParamUnit(unit);
                    };
                }
                else
                {
                    unit.OutSideCircleImage = ResourceManager.Instance.Load("icon_circle_deco", ResourceType.Common);
                    unit.UnitImage          = ResourceManager.Instance.Load("icon_empty2", ResourceType.Menu);
                    unit.IsEnalbeSelect     = true;
                }

                if (linkData != null && linkData.id > 0)
                {
                    unit.LinkCharaMaster = charaMasterList.Find((v) => v.fix_id == linkData.id);
                    UnitIconImageProvider.Instance.Get(
                        linkData.id,
                        sprite =>
                    {
                        unit.LinkUnitImage = sprite;
                    });
                    unit.IsEmptyLinkUnit = false;
                }
                else
                {
                    unit.LinkOutSideCircleImage = ResourceManager.Instance.Load("icon_circle_deco", ResourceType.Common);
                    unit.LinkUnitImage          = ResourceManager.Instance.Load("icon_empty2", ResourceType.Menu);
                    unit.IsEmptyLinkUnit        = true;
                }

                // indexがm_UnitPartyCurrentとその前後の時にアイコンとステータスを更新する.
                if ((index == m_UnitPartyCurrent) ||
                    (index == m_UnitPartyCurrent - 1) ||
                    (index == m_UnitPartyCurrent + 1))
                {
                    MainMenuUtil.SetPartySelectUnitData(ref unit, unitData, linkData, party.PartyData);
                }
                else if (unit.OutSideCircleImage == null)
                {
                    unit.OutSideCircleImage = ResourceManager.Instance.Load("icon_circle_deco", ResourceType.Common);
                }

                unitDataModel.OnClicked += () =>
                {
                    OnSelectParamUnit(unit);
                };
                unitList.Add(unit);

                partyPanelModel.AddUnit(unitDataModel);
            }

            unitList[0].PartyCharaIndex = GlobalDefine.PartyCharaIndex.LEADER;
            unitList[1].PartyCharaIndex = GlobalDefine.PartyCharaIndex.MOB_1;
            unitList[2].PartyCharaIndex = GlobalDefine.PartyCharaIndex.MOB_2;
            unitList[3].PartyCharaIndex = GlobalDefine.PartyCharaIndex.MOB_3;

            paertParam.Units = unitList;

            //-------------------------
            // スキル
            //-------------------------
            int skillDataIndex = 0;
            if (unitList[0].UnitData.id > 0)
            {
                List <UnitSkillAtPartyContext> skillList = new List <UnitSkillAtPartyContext>();

                var skillDataModel = new ListItemModel((uint)skillDataIndex++);

                UnitSkillAtPartyContext leaderSkill = new UnitSkillAtPartyContext(skillDataModel);
                leaderSkill.setupLeaderSkill(unitList[0].CharaMaster.skill_leader);
                skillList.Add(leaderSkill);

                paertParam.Skills = skillList;

                partyPanelModel.AddSkill(skillDataModel);

#if BUILD_TYPE_DEBUG
                Debug.Log("*************** UnitSkillAtPartyContext *********************");
#endif
            }

            paertParam.SelectLinkAction = OnSelectLink;
            m_PartyParamPanel.PartyParams.Add(paertParam);
        }

        //--------------------------------------
        // 主人公
        //--------------------------------------
        // アセットバンドルの読み込み
        uint currentHeroID = MasterDataUtil.GetCurrentHeroID();
        AssetBundler.Create().
        Set(string.Format("hero_{0:D4}", currentHeroID),
            (o) =>
        {
            Texture2D texture      = o.GetTexture2D(string.Format("tex_hero_perform_l_{0:D4}", currentHeroID), TextureWrapMode.Clamp);
            Texture2D texture_mask = o.GetTexture2D(string.Format("tex_hero_perform_l_{0:D4}_mask", currentHeroID), TextureWrapMode.Clamp);
            foreach (var paertParam in m_PartyParamPanel.PartyParams)
            {
                paertParam.HeroImage      = texture;
                paertParam.HeroImage_mask = texture_mask;
            }
        }).Load();
    }
    public void CreatePartyParam(int party_id, MainMenuTutorialHeroSelect heroSelect)
    {
        MasterDataDefaultParty masterParty = MasterFinder <MasterDataDefaultParty> .Instance.Find(party_id);

        //-------------------------
        // ユニット設定
        //-------------------------
        List <PartyMemberUnitContext> unitList = new List <PartyMemberUnitContext>();
        int unitDataIndex = 0;

        for (int n = 0; n < 4; ++n)
        {
            uint unit_id    = 0;
            uint unit_level = 0;
            switch (n)
            {
            case 0:
                unit_id    = masterParty.party_chara0_id;
                unit_level = masterParty.party_chara0_level;
                break;

            case 1:
                unit_id    = masterParty.party_chara1_id;
                unit_level = masterParty.party_chara1_level;
                break;

            case 2:
                unit_id    = masterParty.party_chara2_id;
                unit_level = masterParty.party_chara2_level;
                break;

            case 3:
                unit_id    = masterParty.party_chara3_id;
                unit_level = masterParty.party_chara3_level;
                break;

            default:
                break;
            }

            var unitDataModel           = new PartyMemberUnitListItemModel((uint)unitDataIndex++);
            PartyMemberUnitContext unit = new PartyMemberUnitContext(unitDataModel);

            unit.IsActiveStatus = true;
            if (unit_id != 0)
            {
                PacketStructUnit unitData = new PacketStructUnit();
                unitData.id    = unit_id;
                unitData.level = unit_level;

                if (unitData != null)
                {
                    UnitIconImageProvider.Instance.Get(
                        unitData.id,
                        sprite =>
                    {
                        unit.UnitImage = sprite;
                    });
                }
                else
                {
                    unit.OutSideCircleImage = ResourceManager.Instance.Load("icon_circle_deco", ResourceType.Common);
                    unit.UnitImage          = ResourceManager.Instance.Load("icon_empty", ResourceType.Menu);
                }

                unit.UnitData = unitData;
                SetUnitData(ref unit, unitData);

                unitDataModel.OnLongPressed += () =>
                {
                    OnLongPressParamUnit(unit, heroSelect);
                };
            }
            else
            {
                unit.UnitImage = ResourceManager.Instance.Load("icon_empty", ResourceType.Menu);
            }

            unitDataModel.OnShowedNext += () =>
            {
                unitDataModel.ShowStatus();
            };

            unitList.Add(unit);
        }

        unitList[0].PartyCharaIndex = GlobalDefine.PartyCharaIndex.LEADER;
        unitList[1].PartyCharaIndex = GlobalDefine.PartyCharaIndex.MOB_1;
        unitList[2].PartyCharaIndex = GlobalDefine.PartyCharaIndex.MOB_2;
        unitList[3].PartyCharaIndex = GlobalDefine.PartyCharaIndex.MOB_3;

        Units = unitList;
    }
    /// <summary>
    /// パーティユニットを変更する
    /// </summary>
    /// <param name="unit_unique_id"></param>
    public void ChangePartyUnit(long unit_unique_id)
    {
        PacketStructUnit       slectUnitData = UserDataAdmin.Instance.SearchChara(unit_unique_id); // 選択したユニット
        PartyMemberUnitContext selectUnit;

        if (m_SelectPartyCharaIndex == GlobalDefine.PartyCharaIndex.ERROR)
        {
            // 選択されていない場合は空いてるパーティを選ぶ
            selectUnit = m_PartyMemberUnitGroup.Units.Find(value => value.UnitData == null);
        }
        else
        {
            selectUnit = m_PartyMemberUnitGroup.Units.Find(value => value.PartyCharaIndex == m_SelectPartyCharaIndex);
        }

        if (slectUnitData == null)
        {
            return;
        }
        if (selectUnit == null)
        {
            return;
        }

        GlobalDefine.PartyCharaIndex charaIndex = CheckPartyInUnit(unit_unique_id);
        if (charaIndex != GlobalDefine.PartyCharaIndex.ERROR)
        {
            //パーティ内で入れ替える
            if (charaIndex == GlobalDefine.PartyCharaIndex.LEADER && selectUnit.UnitData == null)
            {
                //パーティ選択枠が空で入れ替えのキャラがリーダーの場合はやめる
                return;
            }
            PartyMemberUnitContext partyUnit   = m_PartyMemberUnitGroup.Units.Find(value => value.PartyCharaIndex == charaIndex);
            PacketStructUnit       tmpUnitData = selectUnit.UnitData;

            selectUnit.UnitData = slectUnitData;
            partyUnit.UnitData  = tmpUnitData;

            // 画像変更
            if (partyUnit.UnitData != null)
            {
                UnitIconImageProvider.Instance.Get(
                    partyUnit.UnitData.id,
                    sprite =>
                {
                    partyUnit.UnitImage = sprite;
                },
                    true);
                partyUnit.LinkIcon       = MainMenuUtil.GetLinkMark(partyUnit.UnitData);
                partyUnit.IsEnalbeSelect = true;
                MasterDataParamChara _master = MasterFinder <MasterDataParamChara> .Instance.Find((int)partyUnit.UnitData.id);

                partyUnit.IconSelect = MainMenuUtil.GetElementCircleSprite(_master.element);
                partyUnit.IsElement  = true;
            }
            else
            {
                partyUnit.UnitImage      = ResourceManager.Instance.Load("icon_empty2");
                partyUnit.LinkIcon       = null;
                partyUnit.IsEnalbeSelect = false;
                partyUnit.IsElement      = false;
            }

            UnitIconImageProvider.Instance.Get(
                selectUnit.UnitData.id,
                sprite =>
            {
                selectUnit.UnitImage = sprite;
            },
                true);
            selectUnit.LinkIcon       = MainMenuUtil.GetLinkMark(selectUnit.UnitData);
            selectUnit.IsEnalbeSelect = true;
            MasterDataParamChara _selectMaster = MasterFinder <MasterDataParamChara> .Instance.Find((int)selectUnit.UnitData.id);

            selectUnit.IconSelect = MainMenuUtil.GetElementCircleSprite(_selectMaster.element);
            selectUnit.IsElement  = true;

            SetupLinkChara(selectUnit);
            SetupLinkChara(partyUnit);

            ChangeStatus(partyUnit.UnitData, partyUnit.PartyCharaIndex, GetPartyPacketStructUnits());
        }
        else
        {
            if (selectUnit.UnitData != null)
            {
                UnitIconImageProvider.Instance.Reset(selectUnit.UnitData.id);
            }

            //入れ替え
            selectUnit.UnitData = slectUnitData;
            UnitIconImageProvider.Instance.Get(
                selectUnit.UnitData.id,
                sprite =>
            {
                selectUnit.UnitImage = sprite;
            },
                true);
            selectUnit.LinkIcon       = MainMenuUtil.GetLinkMark(selectUnit.UnitData);
            selectUnit.IsEnalbeSelect = true;
            MasterDataParamChara _selectMaster = MasterFinder <MasterDataParamChara> .Instance.Find((int)selectUnit.UnitData.id);

            selectUnit.IconSelect = MainMenuUtil.GetElementCircleSprite(_selectMaster.element);
            selectUnit.IsElement  = true;

            SetupLinkChara(selectUnit);
        }

        ChangeStatus(slectUnitData, selectUnit.PartyCharaIndex, GetPartyPacketStructUnits());
        m_IsPartyMemberChange = true;
        CheckUnitSpace();
    }