Esempio n. 1
0
        public void processMainData(string api, NameValueCollection client, string server)
        {
            dynamic clientjson = DynamicJson.Parse(client["outdatacode"]);

            switch (api)
            {
            case RequestUrls.GetUserInfo:
            {
                im.dataHelper.ReadUserInfo(server);
                im.uiHelper.setUserInfo();
                im.autoOperation.SetTeamInfo();
                break;
            }

            //建造
            case RequestUrls.DevelopGun:
            {
                dynamic serverjson = DynamicJson.Parse(server);

                int buildslot = Convert.ToInt32(clientjson.build_slot);
                int resultid  = Convert.ToInt32(serverjson.gun_id);
                im.uiHelper.setDevelopingTimer(im.timer, buildslot, resultid, CommonHelper.ConvertDateTimeInt(DateTime.Now));
                im.uiHelper.setStatusBarText_InThread(String.Format("建造结果: {0} 于建造槽{1}", Data.gunInfo[resultid].name, buildslot));
                break;
            }


            case RequestUrls.FinishDevelopGun:
            {
                im.uiHelper.setFactoryTimerDefault(Convert.ToInt32(clientjson.build_slot));
                break;
            }

            //后勤有关
            case RequestUrls.StartOperation:
            {
                Models.AutoOperationInfo ao = null;
                im.mainWindow.Dispatcher.Invoke(() =>
                    {
                        ao = new Models.AutoOperationInfo(Convert.ToInt32(clientjson.team_id), Convert.ToInt32(clientjson.operation_id));
                    });

                im.autoOperation.AddTimerStartOperation(ao);
                break;
            }

            case RequestUrls.FinishOperation:
            {
                Models.AutoOperationInfo ao = im.autoOperation.FindOperation(Convert.ToInt32(clientjson.operation_id));

                im.mainWindow.Dispatcher.Invoke(() =>
                    {
                        im.autoOperation.operationList.Remove(ao);
                    });

                break;
            }

            case RequestUrls.AbortOperation:
            {
                Models.AutoOperationInfo ao = im.autoOperation.FindOperation(Convert.ToInt32(clientjson.operation_id));
                im.autoOperation.operationList.Remove(ao);
                break;
            }

            //资源恢复
            case RequestUrls.RecoverResource:
            {
                break;
            }
            }
        }
Esempio n. 2
0
        public void processMainData(string api, NameValueCollection client, string server)
        {
            dynamic clientjson = DynamicJson.Parse(client["outdatacode"]);

            switch (api)
            {
            case RequestUrls.GetUserInfo:
            {
                im.dataHelper.ReadUserInfo(server);
                im.uiHelper.setUserInfo();
                im.autoOperation.SetTeamInfo();
                break;
            }

            //建造
            case RequestUrls.DevelopGun:
            {
                dynamic serverjson = DynamicJson.Parse(server);

                int buildslot = Convert.ToInt32(clientjson.build_slot);
                int resultid  = Convert.ToInt32(serverjson.gun_id);
                Task.Run(() =>
                    {
                        im.serverHelper.UploadBuildResult(clientjson, resultid);
                    });

                im.uiHelper.setDevelopingTimer(im.timer, buildslot, resultid, CommonHelper.ConvertDateTimeInt(DateTime.Now));
                im.uiHelper.setStatusBarText_InThread(String.Format("建造结果: {0} 于建造槽{1}", Data.gunInfo[resultid].name, (buildslot + 1) / 2));

                if (im.logger.GetIfBuildLog())
                {
                    string logstr = String.Format("[人形建造]人力: {0}, 弹药: {1}, 口粮: {2}, 零件: {3}, 建造结果: {4}", Convert.ToInt32(clientjson.mp), Convert.ToInt32(clientjson.ammo), Convert.ToInt32(clientjson.mre), Convert.ToInt32(clientjson.part), Data.gunInfo[resultid].name);
                    im.logger.LogBuildResult(logstr);
                }
                break;
            }


            case RequestUrls.FinishDevelopGun:
            {
                im.uiHelper.setFactoryTimerDefault(Convert.ToInt32(clientjson.build_slot));
                break;
            }

            case RequestUrls.DevelopEquip:
            {
                dynamic serverjson = DynamicJson.Parse(server);

                int buildslot = Convert.ToInt32(clientjson.build_slot);
                int resultid  = Convert.ToInt32(serverjson.equip_id);
                Task.Run(() =>
                    {
                        im.serverHelper.UploadBuildResult(clientjson, resultid);
                    });

                im.uiHelper.setDevelopingTimer(im.timer, buildslot, resultid, CommonHelper.ConvertDateTimeInt(DateTime.Now), true);
                im.uiHelper.setStatusBarText_InThread(String.Format("建造结果: {0} 于建造槽{1}", Data.equipInfo[resultid].name, (buildslot + 1) / 2));

                if (im.logger.GetIfBuildLog())
                {
                    string logstr = String.Format("[装备建造]人力: {0}, 弹药: {1}, 口粮: {2}, 零件: {3}, 建造结果: {4}", Convert.ToInt32(clientjson.mp), Convert.ToInt32(clientjson.ammo), Convert.ToInt32(clientjson.mre), Convert.ToInt32(clientjson.part), Data.equipInfo[resultid].name);
                    im.logger.LogBuildResult(logstr);
                }
                break;
            }

            case RequestUrls.FinishDeveloEquip:
            {
                im.uiHelper.setFactoryTimerDefault(Convert.ToInt32(clientjson.build_slot), true);
                break;
            }

            //后勤有关
            case RequestUrls.StartOperation:
            {
                Models.AutoOperationInfo ao = null;
                im.mainWindow.Dispatcher.Invoke(() =>
                    {
                        ao = new Models.AutoOperationInfo(Convert.ToInt32(clientjson.team_id), Convert.ToInt32(clientjson.operation_id));
                    });

                im.autoOperation.AddTimerStartOperation(ao);
                break;
            }

            case RequestUrls.FinishOperation:
            {
                Models.AutoOperationInfo ao = im.autoOperation.FindOperation(Convert.ToInt32(clientjson.operation_id));

                im.mainWindow.Dispatcher.Invoke(() =>
                    {
                        im.autoOperation.operationList.Remove(ao);
                    });

                break;
            }

            case RequestUrls.AbortOperation:
            {
                Models.AutoOperationInfo ao = im.autoOperation.FindOperation(Convert.ToInt32(clientjson.operation_id));
                im.autoOperation.operationList.Remove(ao);
                break;
            }

            //资源恢复
            case RequestUrls.RecoverResource:
            {
                break;
            }
            }
        }