public void ResetFormation(List <ExpeditionHeroProto> heros)
        {
//			FormationsDictionary.Clear();
//			List<PositionInfo> posList = teams.posInfos;
//			int count = posList.Count;
//			for(int i = 0;i<count;i++)
//			{
//				PositionInfo posInfo = posList[i];
//				FormationsDictionary[(FormationPosition)posInfo.posIndex] = (uint)posInfo.heroId;
//			}
            _expeditionRoleDictionary.Clear();
            int count = heros.Count;
            ExpeditionHeroProto heroProto;

            for (int i = 0; i < count; i++)
            {
                heroProto = heros[i];
                if (GameProxy.instance.IsPlayer((uint)heroProto.heroId))
                {
                    ExpeditionHeroInfo expeditionInfo = new ExpeditionHeroInfo(GameProxy.instance.PlayerInfo, heroProto.hpPercent / 10000.0f);
                    _expeditionRoleDictionary.Add((uint)heroProto.heroId, expeditionInfo);
                }
                HeroInfo info = HeroProxy.instance.GetHeroInfo((uint)heroProto.heroId);
                if (info != null)
                {
                    ExpeditionHeroInfo expeditionInfo = new ExpeditionHeroInfo(info, heroProto.hpPercent / 10000.0f);
                    _expeditionRoleDictionary.Add((uint)heroProto.heroId, expeditionInfo);
                }
            }
        }
        //死亡下阵
        public void CheckDeadHeroAtFormation()
        {
            LuaTable formationModelLua    = (LuaTable)LuaScriptMgr.Instance.CallLuaFunction("gamemanager.GetModel", "formation_model")[0];
            LuaTable formationTeamInfoLua = (LuaTable)formationModelLua.GetLuaFunction("GetFormationTeam").Call((int)FormationTeamType.expeditionTeam)[0];


            List <FormationPosition> posList = FormationsDictionary.GetKeys();
            int  count   = posList.Count;
            bool hasDead = false;

            for (int i = 0; i < count; i++)
            {
                FormationPosition  key  = posList[i];
                ExpeditionHeroInfo info = GetExpeditionHeroInfo(FormationsDictionary[key]);
                if (info.hpRate <= 0)
                {
                    hasDead = true;
                    FormationsDictionary.Remove(key);
                    formationTeamInfoLua.GetLuaFunction("RemoveHeroByFormationPosition").Call(formationTeamInfoLua, (int)key);
                }
            }
            if (hasDead)
            {
                ExpeditionController.instance.CLIENT2LOBBY_Expedition_Formation_Change_REQ();
            }
        }
        public static int CompareHeroByQualityDesc(ExpeditionHeroInfo info1, ExpeditionHeroInfo info2)
        {
            int compare = -RoleUtil.CompareRoleDataPower(info1.roleInfo, info2.roleInfo);

            if (compare != 0)
            {
                return(compare);
            }
            return(RoleUtil.CompareRoleByQualityDesc(info1.roleInfo, info2.roleInfo));
        }
        public void UpdateExpeditionRole(Dictionary <int, int> roleInfoDic)
        {
            List <int> keys = roleInfoDic.GetKeys();

            int count = keys.Count;
            int id;

            for (int i = 0; i < count; i++)
            {
                id = keys[i];
                ExpeditionHeroInfo info = GetExpeditionHeroInfo((uint)id);
                if (info != null)
                {
                    info.hpRate = roleInfoDic[id] / 10000.0f;
                }
            }
        }
        public void UpdateExpeditionRoleFromLua()
        {
            _expeditionRoleDictionary.Clear();
            LuaTable expeditionModelLua = (LuaTable)LuaScriptMgr.Instance.CallLuaFunction("gamemanager.GetModel", "expedition_model")[0];
            LuaTable roleDic            = (LuaTable)expeditionModelLua["expeditionRoleDictionary"];
            LuaTable roleDicData        = (LuaTable)roleDic["data"];
            int      instanceId         = 0;
            float    hpRate             = 0;

            foreach (DictionaryEntry kvp in roleDicData.ToDictTable())
            {
                LuaTable v = (LuaTable)kvp.Value;
                instanceId = v["instanceID"].ToString().ToInt32();
                hpRate     = v["hpRate"].ToString().ToFloat();
                ExpeditionHeroInfo info = GetExpeditionHeroInfo((uint)instanceId);
                if (info != null)
                {
                    info.hpRate = hpRate;
                }
            }
        }
        public ExpeditionHeroInfo GetExpeditionHeroInfo(uint instanceId)
        {
            if (_expeditionRoleDictionary.ContainsKey(instanceId))
            {
                return(_expeditionRoleDictionary[instanceId]);
            }
            ExpeditionHeroInfo expeditionInfo;

            if (GameProxy.instance.IsPlayer(instanceId))
            {
                expeditionInfo = new ExpeditionHeroInfo(GameProxy.instance.PlayerInfo, 1);
                _expeditionRoleDictionary.Add(instanceId, expeditionInfo);
                return(expeditionInfo);
            }
            HeroInfo info = HeroProxy.instance.GetHeroInfo(instanceId);

            if (info != null)
            {
                expeditionInfo = new ExpeditionHeroInfo(info, 1);
                _expeditionRoleDictionary.Add(instanceId, expeditionInfo);
                return(expeditionInfo);
            }
            return(null);
        }
 public static int CompareHeroByQualityAsc(ExpeditionHeroInfo info1, ExpeditionHeroInfo info2)
 {
     return(RoleUtil.CompareRoleDataPower(info1.roleInfo, info2.roleInfo));
 }