Esempio n. 1
0
        public string Collect(Sandbox sandbox)
        {
            int ready = AmountReady;

            if (ready == 0)
            {
                return("Nothing to collect");
            }
            var spoils = production.spoils;

            if (spoils.count > 0)
            {
                sandbox.storage.Add(new StackedItems(spoils.item, spoils.count * ready), -1);
            }
            xp         += production.xp * ready;
            sandbox.xp += production.xp * ready;

            amount -= ready;

            lastCollect = lastCollect.AddHours(ready * production.hours);
            if (amount <= 0)
            {
                production = null;
            }

            return($"Collected {spoils.count * ready}x {spoils.item} {GainProduction(ready)}");
        }
        /// <summary>
        /// コンストラクタ
        /// </summary>
        public RecipeSelectWindowController()
        {
            // レシピ選択ウィンドウの初期化
            recipeSelectWindow = new RecipeSelectWindow();

            productionRecipe = new ProductionRecipe();

            SetRecipeListToCombox();    // レシピをコンボボックスへ

            // イベント登録
            recipeSelectWindow.RegisterEventOnRecipeNameListComboBox(RecipiListSelected);
            recipeSelectWindow.RegisterEventOnNumberOfProductionTextBox(RequestNumberOfProductinChanged);
            recipeSelectWindow.RegisterEventBuildingListComboBox(BuildingSelected);
            recipeSelectWindow.RegisterEventPurityRadioButton(ChangePurityRadio);
            recipeSelectWindow.RegisterEventOverclockNumberSlider(SliderValueChanged);
            recipeSelectWindow.RegisterEventOverclockNumberTextBox(OverclockTextChanged);
            recipeSelectWindow.RegisterEventOnConfirmButtton(ConfirmButtonClicked);
            recipeSelectWindow.RegisterEventOnCancelButtton(CancelButtonClicked);

            // 鉱石純度ラジオを非表示
            recipeSelectWindow.ChangeVisibiilityRadios(0);

            // オーバークロックだけ初期値を入れる
            productionRecipe.BuildingToUse.OverclockingNumber = 100;
        }
Esempio n. 3
0
        /// <summary>
        /// レシピの追加
        /// </summary>
        /// <param name="newRecipe">追加するレシピ</param>
        public void AddRecipe(ProductionRecipe newRecipe)
        {
            // リストになければ追加(これ多分いらない)
            if (!productionRecipes.Contains(newRecipe))
            {
                productionRecipes.Add(newRecipe);
            }

            RefreshListPanels(); // リストの再表示
        }
        internal static async Task Produce(Player player, int tileIndex, ProductionRecipe recipe, int amount, ISocketMessageChannel channel)
        {
            House house = await LoadHouse(player, channel);

            Sandbox sb = house.sandbox;

            recipe.Consume(sb, amount);
            sb.tiles[tileIndex].Start(recipe, amount);
            await house.Save();

            await SandboxActions.InspectTile(player, sb, "house", tileIndex, channel);
        }
Esempio n. 5
0
        /// <summary>
        /// レシピの順序入れ替え
        /// </summary>
        /// <param name="position">入れ替え対象の位置</param>
        /// <param name="direction">入れ替える方向(-1:上, 1:下)</param>
        private void ChangeRecipeListOrder(int position, int direction)
        {
            // 入れ替える前にレシピ内に保持してある順番を入れ替えておく
            productionRecipes[position].Position             = position - direction;
            productionRecipes[position + direction].Position = position;

            // 入れ替える(0番目と最後はボタンを無効化しているのでぬるぽはしないはず…)
            ProductionRecipe swap = productionRecipes[position + direction];

            productionRecipes[position + direction] = productionRecipes[position];
            productionRecipes[position]             = swap;

            RefreshListPanels(); // リストの再表示
        }
Esempio n. 6
0
        public string Cancel(Sandbox sandbox)
        {
            sandbox.treasury += production.cost * amount;
            string result = $"Returned {production.cost * amount} Coins" + Environment.NewLine;

            Utils.Map(production.materials, (stack, i) =>
            {
                sandbox.storage.Add(new StackedItems(stack.item, stack.count * amount), -1);
                result += $"Returned {stack.count * amount}x {stack.item}" + Environment.NewLine;
                return(true);
            });
            amount     = 0;
            production = null;
            return(result);
        }
        internal static async Task ProduceAmount(Player player, Sandbox sb, string source, int tileIndex, int productIndex, int amount, ISocketMessageChannel channel)
        {
            SandboxTile      tile   = sb.tiles[tileIndex];
            ProductionRecipe recipe = ProductionRecipes.Get(tile.type, tile.productionOptions[productIndex]);

            await player.EditUI(null, DUtils.BuildEmbed($"Product {recipe} from {tile.Name}", null, null, player.userSettings.Color,
                                                        DUtils.NewField("Select Amount",
                                                                        $"{EUI.ok} Produce **[{amount}]**" + Environment.NewLine +
                                                                        $"{EUI.prev}|{EUI.lowerthan}|{EUI.greaterthan}|{EUI.next}"
                                                                        + Environment.NewLine +
                                                                        $" -5 | -1 | +1 | +5 |" + Environment.NewLine +
                                                                        $"Or `amount` command: `amount 10`"),
                                                        recipe.ToField(amount)
                                                        ).Build(), channel, MsgType.TileProduce, $"{source};{tileIndex};{productIndex};{amount}");
        }
Esempio n. 8
0
        /// <summary>
        /// レシピ追加ボタン
        /// </summary>
        private void AddRecipeButtonClicked(object sender, EventArgs e)
        {
            RecipeSelectWindowController recipeSelectController = new RecipeSelectWindowController();

            recipeSelectController.ShowRecipeSelectWindow(parentWindow);

            ProductionRecipe productionRecipe = recipeSelectController.ProductionRecipe;

            if (productionRecipe != null)
            {
                AddRecipe(productionRecipe);
            }

            recipeSelectController = null;
        }
Esempio n. 9
0
 internal void Start(ProductionRecipe recipe, int amount)
 {
     production  = recipe;
     this.amount = amount;
     lastCollect = DateTime.UtcNow;
 }
Esempio n. 10
0
        /// <summary>
        /// 生産物と要求物のリストを生成して表示まで
        /// </summary>
        private void CreateProductionAndRequiredList()
        {
            List <string[]> materialList = new List <string[]>();

            // レシピのリストを逆転したものを用意
            List <ProductionRecipe> reversed = new List <ProductionRecipe>(productionRecipes);

            reversed.Reverse();

            foreach (ProductionRecipe recipe in reversed)
            {
                int i = 0;
                // 要求素材から検索して同名があれば数値だけ追加、なければ名前と追加
                foreach (RequiredMaterial requiredMaterial in recipe.RequiredMaterials)
                {
                    bool flag = false;
                    foreach (string[] material in materialList)
                    {
                        if (material[0].Equals(requiredMaterial.Name) && !material[1].Equals("0"))
                        {
                            flag        = true;
                            material[1] = Math.Round(double.Parse(material[1]) - recipe.ActualRequiredNumberOfMaterialsPerMin[i], 2).ToString();
                        }
                    }

                    if (!flag)
                    {
                        materialList.Add(new string[] { requiredMaterial.Name, (-recipe.ActualRequiredNumberOfMaterialsPerMin[i]).ToString() });
                    }
                    i++;
                }

                i = 0;
                bool exist = false;
                foreach (string[] production in materialList)
                {
                    if (production[0].Equals(recipe.ProductionMaterial.Name) && double.TryParse(production[1], out double pro) && pro > 0)
                    {
                        exist = true;
                        break;
                    }
                    i++;
                }

                if (exist)
                {
                    Console.WriteLine("Name:" + materialList[i][0]);
                    Console.WriteLine("Number:" + materialList[i][1]);
                    Console.WriteLine("Production:" + recipe.NumberOfMaterialProduction);
                    Console.WriteLine("Result:" + double.Parse(materialList[i][1]) + recipe.NumberOfMaterialProduction);
                    materialList[i][1] = (double.Parse(materialList[i][1]) + recipe.NumberOfMaterialProduction).ToString();
                }
                else
                {
                    materialList.Add(new string[] { recipe.ProductionMaterial.Name, recipe.NumberOfMaterialProduction.ToString() });
                }
            }

            // 表示用のリストとか作成
            List <MaterialWithNumOnButton> productionList = new List <MaterialWithNumOnButton>();
            List <MaterialWithNumOnButton> requiredList   = new List <MaterialWithNumOnButton>();

            foreach (string[] value in materialList)
            {
                if (double.Parse(value[1]) < 0)
                {
                    MaterialWithNumOnButton material = new MaterialWithNumOnButton();

                    // 名前と数値の設定
                    material.TextBlock_Name.Text   = value[0];
                    material.TextBlock_Number.Text = (-(double.Parse(value[1]))).ToString();

                    // ボタンイベントの追加
                    void RequiredListClicked(object sender, EventArgs e)
                    {
                        RecipeSelectWindowController recipeSelectController = new RecipeSelectWindowController();

                        recipeSelectController.ShowRecipeSelectWindow(value[0], -(double.Parse(value[1])), parentWindow);

                        ProductionRecipe productionRecipe = recipeSelectController.ProductionRecipe;

                        if (productionRecipe != null)
                        {
                            AddRecipe(productionRecipe);
                        }

                        recipeSelectController = null;
                    }

                    material.Button_RequestRecipeSelect.Click += RequiredListClicked;

                    requiredList.Add(material);
                }
                else if (double.Parse(value[1]) > 0)
                {
                    MaterialWithNumOnButton material = new MaterialWithNumOnButton();

                    // 名前と数値の設定
                    material.TextBlock_Name.Text   = value[0];
                    material.TextBlock_Number.Text = (double.Parse(value[1])).ToString();
                    productionList.Add(material);
                }
            }

            // 表示させる
            productionBlockTab.AddMaterialsToProductionListPanel(productionList);
            productionBlockTab.AddMaterialsToRequiredListPanel(requiredList);
        }