bool OnToggleCharacter(DungeonHero hero, bool bSelected) { if (m_MainLayout.DragContainer != null) { OnCharacterRelease(true); } if (bSelected == true) { if (m_CurrentTeam.ContainsIDN(hero.Creature.Info.IDN) == true) { Tooltip.Instance.ShowMessageKey("CreatureNotUseSame"); return(false); } for (int i = 0; i < m_MainLayout.m_Characters.Length; ++i) { UICharacterContainer container = m_MainLayout.m_Characters[i]; if (container.Character == null) { for (int j = 0; j < i; ++j) { if (m_MainLayout.m_Characters[j].Character.Creature.Info.Position > hero.CreatureInfo.Position) { m_MainLayout.Reposition(i, j); m_MainLayout.Batch(j); break; } } container.Init(AssetManager.GetCharacterAsset(hero.Creature.Info.ID, hero.Creature.SkinName), UICharacterContainer.Mode.UI_Normal, "social"); if (container.Character != null) { container.Character.Creature = hero.Creature; } m_MainLayout.UpdateBatch(); SaveTeamData(); UpdateCharacterInfo(true); return(true); } } return(false); } else { UICharacterContainer container = Array.Find(m_MainLayout.m_Characters, c => c.IsInit == true && c.Character.Creature.Idx == hero.Creature.Idx); container.Uninit(); m_MainLayout.Rebatch(); if (m_CurrentTeam.LeaderCreatureIdx == hero.Creature.Idx) { OnChangedLeaderSkillChanged(null); } SaveTeamData(); UpdateCharacterInfo(true); } return(true); }