Пример #1
0
        public ProduceOrder CreateProduceOrder(int PlanetID, int BuildingID)
        {
            IInsert      query;
            ProduceOrder item;
            object       result;

            LogEnter();

            item = new ProduceOrder()
            {
                PlanetID = PlanetID, BuildingID = BuildingID
            };

            Log(LogLevels.Information, $"Inserting into Order table ()");
            query = new Insert().Into(BotsDB.OrderTable)
                    .Set(OrderTable.BotID, item.BotID);
            result = Try(query).OrThrow <PIODataException>("Failed to insert");

            item.OrderID = Convert.ToInt32(result);

            Log(LogLevels.Information, $"Inserting into ProduceOrder table (OrderID={item.OrderID},PlanetID={item.PlanetID}, BuildingID={BuildingID})");
            query = new Insert().Into(BotsDB.ProduceOrderTable)
                    .Set(ProduceOrderTable.OrderID, item.OrderID)
                    .Set(ProduceOrderTable.PlanetID, item.PlanetID)
                    .Set(ProduceOrderTable.BuildingID, item.BuildingID);
            result = Try(query).OrThrow <PIODataException>("Failed to insert");

            item.ProduceOrderID = Convert.ToInt32(result);
            return(item);
        }
Пример #2
0
    /// <summary>
    /// 打开确认面板
    /// </summary>
    /// <param name="type">操作类型</param>
    public void OpenConfim(MsgProduceConfim confim)//消耗数据
    {
        ProduceOrder type = confim.OrderType;

        m_SelectProduceTid = confim.Tid;
        switch (type)
        {
        case ProduceOrder.Produce:      //生产
            m_ReturnTitle.text = string.Format(TableUtil.GetLanguageString("production_text_1025"),
                                               TableUtil.GetItemName(m_FoundryProxy.GetItemByProduceKey(m_SelectProduceTid).Id));
            m_HintLabel.text = "";
            break;

        case ProduceOrder.Canel:      //取消生产
            m_ReturnTitle.text = TableUtil.GetLanguageString("production_text_1026");
            m_HintLabel.text   = TableUtil.GetLanguageString("production_text_1041");
            m_IconList.Clear();
            Item[]           items   = m_FoundryProxy.GetEffectItem(m_SelectProduceTid);
            EffectElement?[] effects = m_FoundryProxy.GetEffectElementsByProduceTid(m_SelectProduceTid);
            for (int i = 0; i < items.Length; i++)
            {
                IconManager.Instance.LoadItemIcon <IconCommon>(IconConstName.ICON_COMMON, m_ReturnItemRoot,
                                                               (icon) =>
                {
                    m_IconList.Add(icon);
                    icon.SetData(TableUtil.GetItemIconTid(items[i].Id), items[i].Quality, (int)effects[i].Value.Value);
                });
            }

            break;

        case ProduceOrder.Recevie:      //领取 不要图标
            m_ReturnTitle.text = TableUtil.GetLanguageString("production_text_1028");
            m_HintLabel.text   = "";
            break;

        case ProduceOrder.SpeedUp:      //加速
            m_ReturnTitle.text = TableUtil.GetLanguageString("production_text_1027");
            m_HintLabel.text   = TableUtil.GetLanguageString("production_text_1040");
            m_IconList.Clear();
            IconManager.Instance.LoadItemIcon <IconCommon>(IconConstName.ICON_COMMON, m_ReturnItemRoot,
                                                           (icon) =>
            {
                m_IconList.Add(icon);
                icon.SetData(TableUtil.GetItemIconTid(GameConstant.CurrencyConst.RECHARGE_CURRENCY_ITEM_TID),
                             TableUtil.GetItemQuality(GameConstant.CurrencyConst.RECHARGE_CURRENCY_ITEM_TID), (int)confim.ExpendNum);
            });
            break;

        default:
            break;
        }
    }
Пример #3
0
        /// <summary>
        /// 创建请求处理器
        /// </summary>
        public static RequestProcessor CreateProcessor(RequestContext context)
        {
            RequestProcessor processor = null;

            if (context.Service == "PNRImportWithoutPat")
            {
                processor = new PNRImportWithoutPat();
            }
            else if (context.Service == "PNRImport")
            {
                processor = new PNRImport();
            }
            else if (context.Service == "ProduceOrder")
            {
                processor = new ProduceOrder();
            }
            else if (context.Service == "ProduceOrder2")
            {
                processor = new ProduceOrder2();
            }
            else if (context.Service == "ApplyRefund")
            {
                processor = new ApplyRefund();
            }
            else if (context.Service == "ApplyPostpone")
            {
                processor = new ApplyPostpone();
            }
            else if (context.Service == "OrderPay")
            {
                processor = new PayOrder();
            }
            else if (context.Service == "PayOrderByPayType")
            {
                processor = new PayOrderByPayType();
            }
            else if (context.Service == "PayApplyform")
            {
                processor = new PayApplyform();
            }
            else if (context.Service == "PayApplyformByPayType")
            {
                processor = new PayApplyformByPayType();
            }
            else if (context.Service == "QueryOrder")
            {
                processor = new QueryOrder();
            }
            else if (context.Service == "QueryApplyform")
            {
                processor = new QueryApplyform();
            }
            else if (context.Service == "QueryFlights")
            {
                processor = new QueryFlights();
            }
            else if (context.Service == "QueryFlightStop")
            {
                processor = new QueryFlightStop();
            }
            else if (context.Service == "QueryFlight")
            {
                processor = new QueryFlight();
            }
            else if (context.Service == "AutoPay")
            {
                processor = new AutoPay();
            }
            else if (context.Service == "ManualPay")
            {
                processor = new ManualPay();
            }
            if (processor != null)
            {
                processor.Context = context;
            }
            return(processor);
        }
Пример #4
0
        public Task CreateTaskFromProduceOrder(Worker Worker, ProduceOrder ProduceOrder)
        {
            bool result;

            ResourceTypeIDs[] missingResourceTypeID;
            Building          building;
            Stack             stack;
            Task task;

            building = AssertExists <Building>(() => client.GetBuilding(ProduceOrder.BuildingID), $"BuildingID={ProduceOrder.BuildingID}");

            Log(LogLevels.Information, $"Checking if building as enough resources to produce (BuildingID={ProduceOrder.BuildingID})");
            missingResourceTypeID = Try(() => client.GetMissingResourcesToProduce(ProduceOrder.BuildingID)).OrThrow <PIOInternalErrorException>("Failed to check resources");
            if ((missingResourceTypeID == null) || (missingResourceTypeID.Length == 0))
            {
                Log(LogLevels.Information, $"Checking if worker is on site (WorkerID={Worker.WorkerID}, BuildingID={ProduceOrder.BuildingID})");
                result = Try(() => client.WorkerIsInBuilding(Worker.WorkerID, building.BuildingID)).OrThrow <PIOInternalErrorException>("Failed to check worker location");
                if (result)
                {
                    Log(LogLevels.Information, $"Worker is on site, creating produce task");
                    task = Try(() => client.Produce(Worker.WorkerID)).OrThrow <PIOInternalErrorException>("Failed to create task");
                }
                else
                {
                    Log(LogLevels.Information, $"Worker is not on site, creating moveto task");
                    task = Try(() => client.MoveToBuilding(Worker.WorkerID, building.BuildingID)).OrThrow <PIOInternalErrorException>("Failed to create task");
                }
                return(task);
            }
            else
            {
                Log(LogLevels.Information, $"Checking if worker is carrying missing resource (PlanetID={Worker.PlanetID})");
                if ((Worker.ResourceTypeID != null) && missingResourceTypeID.Contains(Worker.ResourceTypeID.Value))
                {
                    Log(LogLevels.Information, $"Worker is carrying missing resource, checking if worker is on site (WorkerID={Worker.WorkerID}, BuildingID={ProduceOrder.BuildingID})");
                    result = Try(() => client.WorkerIsInBuilding(Worker.WorkerID, building.BuildingID)).OrThrow <PIOInternalErrorException>("Failed to check worker location");
                    if (result)
                    {
                        Log(LogLevels.Information, $"Worker is on site, creating store task");
                        task = Try(() => client.Store(Worker.WorkerID)).OrThrow <PIOInternalErrorException>("Failed to create task");
                        return(task);
                    }
                    else
                    {
                        Log(LogLevels.Information, $"Worker is not on site, creating moveto task");
                        task = Try(() => client.MoveToBuilding(Worker.WorkerID, building.BuildingID)).OrThrow <PIOInternalErrorException>("Failed to create task");
                        return(task);
                    }
                }
                else
                {
                    Log(LogLevels.Information, $"Trying to find missing resource (PlanetID={Worker.PlanetID}, ResourceTypeID={missingResourceTypeID[0]})");
                    stack = Try(() => client.FindStack(Worker.PlanetID, missingResourceTypeID[0])).OrThrow("Failed to find missing resource");
                    if (stack == null)
                    {
                        Log(LogLevels.Information, $"Missing resource not found, cannot create task");
                        return(null);
                    }
                    else
                    {
                        Log(LogLevels.Information, $"Missing resource found, checking if worker can carry to");
                        result = Try(() => client.WorkerIsInBuilding(Worker.WorkerID, stack.BuildingID)).OrThrow <PIOInternalErrorException>("Failed to check worker location");
                        if (result)
                        {
                            Log(LogLevels.Information, $"Worker can access resource, creating take task");
                            task = Try(() => client.Take(Worker.WorkerID, missingResourceTypeID[0])).OrThrow <PIOInternalErrorException>("Failed to create task");
                            return(task);
                        }
                        else
                        {
                            Log(LogLevels.Information, $"Missing resource found, creating moveto task");
                            task = Try(() => client.MoveToBuilding(Worker.WorkerID, stack.BuildingID)).OrThrow <PIOInternalErrorException>("Failed to create task");
                            return(task);
                        }
                    }
                }
            }
        }