Example #1
0
        public async void Init()
        {
            MainPage.Current.ActiveProgressRing();
            try
            {
                QueryList.Clear();
                string jsonResult = await LinqHelper.GetSearchData(SearchModel, "SearchQuery");

                if (SearchModel.ExportType.HasValue && SearchModel.ExportType.Value == ExportType.AllPages)
                {
                    var result = JsonConvert.DeserializeObject <JsonResultTemplate <SearchQuery> >(jsonResult);
                    if (result.ResultCode == (int)ResultCodeType.操作成功)
                    {
                        result.Data.ToList().ForEach(item => { QueryList.Add(item); });
                    }
                }
                else
                {
                    var result = JsonConvert.DeserializeObject <JsonSearchResultTemplate <SearchQuery> >(jsonResult);
                    SearchModel.TotalCount = result.Data.TotalSize;
                    SearchModel.PageIndex  = result.Data.PageIndex;
                    SearchModel.PageSize   = result.Data.PageSize;
                    result.Data.Data.ToList().ForEach(item => { QueryList.Add(item); });
                }
            }
            catch (Exception ex)
            {
                await MainPage.ShowErrorMessage(ex.Message);
            }
            finally
            {
                MainPage.Current.InActiveProgressRing();
            }
        }
        private void InstantiateAgent()
        {
            if (npc.GetConstruct(typeof(Barrack)) == null)
            {
                agentCountQuery.Clear();
                return;
            }
            List <QueryItem <Soldier, float> > agentItems = agentCountQuery.QueryItemList();

            for (int i = 0; i < agentItems.Count; i++)
            {
                if (agentItems[i].value >= AgentBuyDelay[agentItems[i].key])
                {
                    if (CheckEnoughGoldToBuyAgent(agentItems[i].key) == NodeState.Success && createAgentDelayCounter > 0.2f)
                    {
                        CreateAgent(agentItems[i].key);
                        agentCountQuery.RemoveAt(i);
                        createAgentDelayCounter = 0.0f;
                        break;
                    }
                }
            }
        }