private void ReceivedUserData(Hashtable result)
    {
        Debug.Log("received");

        LoginResponseParameter response = new LoginResponseParameter();

        response.InitialParameterObjectFromHashtable(result);
        if (response.FailType.HasValue)
        {
            Debug.Log(response.FailType.ToString());
            if (response.FailType == LoginFailType.BeAttacked)
            {
                this.m_ProgressBar.gameObject.SetActive(false);
                this.m_WaitingBehavior.Show();
            }
        }
        else
        {
            LoginSuccessResponseParameter paramter = response.Response;

            if (!string.IsNullOrEmpty(paramter.PlayerAccountID))
            {
                if (CommonHelper.PlatformType == PlatformType.Nd)
                {
                    NdAccountUtility.Instance.InitialAccount(paramter.PlayerAccountID);
                }
            }

            PlayerConfigData playerConfigData = ConfigUtilities.ConfigInterface.Instance.PlayerConfigHelper.GetPlayerData(paramter.PlayerLevel);

            UserData userData = new UserData();
            userData.PlayerID             = paramter.PlayerID;
            userData.Name                 = paramter.PlayerName;
            userData.Level                = paramter.PlayerLevel;
            userData.Exp                  = paramter.PlayerExp;
            userData.ConfigData           = playerConfigData;
            userData.Honour               = paramter.PlayerHonour;
            userData.CurrentStoreGold     = paramter.PlayerGold;
            userData.CurrentStoreFood     = paramter.PlayerFood;
            userData.CurrentStoreOil      = paramter.PlayerOil;
            userData.CurrentStoreGem      = paramter.PlayerGem;
            userData.RemainingCD          = paramter.PlayerShieldRemainSecond;
            userData.PlunderTotalGold     = paramter.PlunderTotalGold;
            userData.PlunderTotalFood     = paramter.PlunderTotalFood;
            userData.PlunderTotalOil      = paramter.PlunderTotalOil;
            userData.RemoveTotalObject    = paramter.RemoveTotalObject;
            userData.IsRegisterSuccessful = paramter.IsRegistered;
            userData.IsNewbie             = paramter.IsNewbie;
            userData.DestoryBuildings     = new Dictionary <BuildingType, int>();
            for (int i = 0; i < (int)BuildingType.Length; i++)
            {
                BuildingType type = (BuildingType)i;
                if (paramter.DestroyBuildingDict != null && paramter.DestroyBuildingDict.ContainsKey(type))
                {
                    userData.DestoryBuildings.Add(type, paramter.DestroyBuildingDict[type]);
                }
                else
                {
                    userData.DestoryBuildings.Add(type, 0);
                }
            }
            userData.ProduceArmies = new Dictionary <ArmyType, int>();
            for (int i = 0; i < (int)ArmyType.Length; i++)
            {
                ArmyType type = (ArmyType)i;
                if (paramter.ProduceArmyDict != null && paramter.ProduceArmyDict.ContainsKey(type))
                {
                    userData.ProduceArmies.Add(type, paramter.ProduceArmyDict[type]);
                }
                else
                {
                    userData.ProduceArmies.Add(type, 0);
                }
            }

            userData.ArmyProgress = new Dictionary <ArmyType, ProgressInformation>();
            foreach (ArmyProgressParameter param in paramter.ArmiesProgress)
            {
                ProgressInformation progressInfo = new ProgressInformation()
                {
                    Level = param.ArmyLevel, StartNo = param.ArmyStartNO
                };
                userData.ArmyProgress.Add(param.ArmyType, progressInfo);
            }

            userData.ItemProgress = new Dictionary <ItemType, ProgressInformation>();
            foreach (ItemProgressParameter param in paramter.ItemsProgress)
            {
                ProgressInformation progressInfo = new ProgressInformation()
                {
                    Level = param.ItemLevel, StartNo = param.ItemStartNO
                };
                userData.ItemProgress.Add(param.ItemType, progressInfo);
            }

            userData.MercenaryProgress = new Dictionary <MercenaryType, int>();
            foreach (MercenaryProgressParameter param in paramter.MercenaryProgress)
            {
                userData.MercenaryProgress.Add(param.MercenaryType, param.MercenaryStartNO);
            }

            userData.AttackLogs = new List <LogData>();
            foreach (MatchLogParameter param in paramter.AttackLog)
            {
                userData.AttackLogs.Add(this.GenerateLogData(param));
            }

            userData.DefenseLogs = new List <LogData>();
            foreach (MatchLogParameter param in paramter.DefenseLog)
            {
                userData.DefenseLogs.Add(this.GenerateLogData(param));
            }

            userData.PlayerBuffs = new List <BuffData>();
            foreach (PlayerBuffParameter param in paramter.Buffs)
            {
                BuffData buffData = new BuffData();
                buffData.RelatedPropsType = param.RelatedProps;
                buffData.RemainingCD      = param.RemainingTime;
                buffData.BuffConfigData   = ConfigInterface.Instance.PropsConfigHelper.GetPropsData(param.RelatedProps).FunctionConfigData as PropsBuffConfigData;
                userData.PlayerBuffs.Add(buffData);
            }

            List <BuildingData>            buildings   = new List <BuildingData>();
            Dictionary <int, BuildingData> builderHuts = new Dictionary <int, BuildingData>();

            List <ArmyData> armies = new List <ArmyData>();
            List <ItemData> items  = new List <ItemData>();
            List <ObjectUpgrade <ArmyType> > armyUpgrades             = new List <ObjectUpgrade <ArmyType> >();
            List <ObjectUpgrade <ItemType> > itemUpgrades             = new List <ObjectUpgrade <ItemType> >();
            Dictionary <MercenaryIdentity, MercenaryData> mercenaries = new Dictionary <MercenaryIdentity, MercenaryData>();
            foreach (BuildingParameter param in paramter.Buildings)
            {
                BuildingData data = this.GenerateBuildingData(param, armies, items, mercenaries, armyUpgrades, itemUpgrades, userData);
                buildings.Add(data);
                if (data.BuildingID.buildingType == BuildingType.BuilderHut)
                {
                    builderHuts.Add(data.BuildingID.buildingNO, data);
                }
            }

            for (int i = 0; i < buildings.Count; i++)
            {
                BuildingData      buildingData = buildings[i];
                BuildingParameter param        = paramter.Buildings[i];
                if (param.BuilderBuildingNO.HasValue)
                {
                    /*
                     * int builderLevel = builderHuts[param.BuilderBuildingNO.Value].Level;
                     * BuilderConfigData builderData = ConfigInterface.Instance.BuilderConfigHelper.GetBuilderData(builderLevel);
                     * buildingData.ActorWorkEfficiency = builderData.BuildEfficiency;
                     */
                    buildingData.BuilderBuildingNO = param.BuilderBuildingNO.Value;
                }

                if (buildingData.ConfigData.ProduceGoldEfficiency == 0 && buildingData.Level > 0)
                {
                    userData.GoldMaxCapacity += buildingData.ConfigData.StoreGoldCapacity;
                }
                if (buildingData.ConfigData.ProduceFoodEfficiency == 0 && buildingData.Level > 0)
                {
                    userData.FoodMaxCapacity += buildingData.ConfigData.StoreFoodCapacity;
                }
                if (buildingData.ConfigData.ProduceOilEfficiency == 0 && buildingData.Level > 0)
                {
                    userData.OilMaxCapacity += buildingData.ConfigData.StoreOilCapacity;
                }
                if (buildingData.ConfigData.CanStoreProps)
                {
                    userData.PropsMaxCapacity += buildingData.ConfigData.StorePropsCapacity;
                }
            }

            foreach (BuildingData buildingData in buildings)
            {
                if (buildingData.ConfigData.StoreGoldCapacity > 0 && buildingData.ConfigData.ProduceGoldEfficiency == 0)
                {
                    buildingData.CurrentStoreGold = userData.CurrentStoreGold * buildingData.ConfigData.StoreGoldCapacity / userData.GoldMaxCapacity;
                }
                if (buildingData.ConfigData.StoreFoodCapacity > 0 && buildingData.ConfigData.ProduceFoodEfficiency == 0)
                {
                    buildingData.CurrentStoreFood = userData.CurrentStoreFood * buildingData.ConfigData.StoreFoodCapacity / userData.FoodMaxCapacity;
                }
                if (buildingData.ConfigData.StoreOilCapacity > 0 && buildingData.ConfigData.ProduceOilEfficiency == 0)
                {
                    buildingData.CurrentStoreOil = userData.CurrentStoreOil * buildingData.ConfigData.StoreOilCapacity / userData.OilMaxCapacity;
                }
            }

            List <RemovableObjectData> removableObjects = new List <RemovableObjectData>();
            foreach (RemovableObjectParameter param in paramter.RemovableObjects)
            {
                removableObjects.Add(this.GenerateRemovableData(param));
            }

            List <TaskInformation> tasks = new List <TaskInformation>();
            if (paramter.OpenedTasks != null)
            {
                foreach (OpeningTaskParameter task in paramter.OpenedTasks)
                {
                    TaskInformation taskInfo = new TaskInformation();
                    taskInfo.TaskID           = task.TaskID;
                    taskInfo.Status           = TaskStatus.Opened;
                    taskInfo.RemainingSeconds = task.RemainingSeconds;
                    if (task.ConditionProgresses != null)
                    {
                        taskInfo.ConditionProgresses = new Dictionary <int, TaskProgressInformation>();
                        foreach (ConditionProgressParameter conditionProgress in task.ConditionProgresses)
                        {
                            taskInfo.ConditionProgresses.Add(conditionProgress.ConditionID, new TaskProgressInformation()
                            {
                                StartValue = conditionProgress.StartValue
                            });
                        }
                    }
                    tasks.Add(taskInfo);
                }
            }
            if (paramter.CompletedTasks != null)
            {
                foreach (int taskID in paramter.CompletedTasks)
                {
                    TaskInformation taskInfo = new TaskInformation();
                    taskInfo.TaskID = taskID;
                    taskInfo.Status = TaskStatus.Completed;
                    tasks.Add(taskInfo);
                }
            }

            Dictionary <int, PropsData> props = new Dictionary <int, PropsData>();
            foreach (PropsParameter p in paramter.Props)
            {
                PropsData data = new PropsData();
                data.RemainingCD      = p.RemainingCD.HasValue ? p.RemainingCD.Value : 0;
                data.RemainingUseTime = p.RemainingUseTimes;
                data.PropsType        = p.PropsType;
                data.PropsConfigData  = ConfigInterface.Instance.PropsConfigHelper.GetPropsData(p.PropsType);
                data.PropsNo          = p.PropsNo;
                data.IsInBattle       = p.IsInBattle;
                props.Add(p.PropsNo, data);
            }

            List <DefenseObjectData> defenseObjects = new List <DefenseObjectData>();
            foreach (DefenseObjectParameter d in paramter.DefenseObjects)
            {
                DefenseObjectData data = new DefenseObjectData();
                data.Position        = new TilePosition(d.PoistionColumn, d.PositionRow);
                data.DefenseObjectID = d.DefenseObjectID;
                data.Name            = ConfigInterface.Instance.PropsConfigHelper.GetPropsData(d.RelatedProps).Name;
                data.ConfigData      = new DefenseObjectConfigWrapper(ConfigInterface.Instance.PropsConfigHelper.GetPropsData(d.RelatedProps).FunctionConfigData);
                defenseObjects.Add(data);
            }

            List <AchievementBuildingData> achievementBuildings = new List <AchievementBuildingData>();
            foreach (AchievementBuildingParameter a in paramter.AchievementBuildings)
            {
                AchievementBuildingData data = new AchievementBuildingData();
                data.AchievementBuildingType = a.AchievementBuildingType;
                data.BuildingNo       = a.AchievementBuildingNo;
                data.BuildingPosition = new TilePosition(a.PositionColumn, a.PositionRow);
                data.Life             = a.Life;
                data.ConfigData       = ConfigInterface.Instance.AchievementBuildingConfigHelper.GetAchievementBuildingData(a.AchievementBuildingType);
                achievementBuildings.Add(data);
            }

            LogicController.Instance.Initialize(userData, buildings, armies, items, armyUpgrades, itemUpgrades, removableObjects, tasks, mercenaries, props, defenseObjects,
                                                paramter.RemovableObjectStartNo, paramter.PropsStartNo, achievementBuildings, paramter.AchievementBuildingStartNo);
            LogicTimer.Instance.InitialTimer(paramter.ServerTick);
            this.m_IsUserLogined = true;
        }
    }
 /// <summary>
 /// Initializes the configuration utils
 /// </summary>
 public static void Initialize()
 {
     configData = new PlayerConfigData();
 }