コード例 #1
0
ファイル: CraftingRecipes.cs プロジェクト: henon/manic_digger
        public void Load(string[] csvLines)
        {
            this.csv = new Csv();
            this.csv.LoadCsv(csvLines);
            for (int i = 1; i < csv.data.Length; i++)
            {
                CraftingRecipe r = new CraftingRecipe();

                int outputId = GetBlockId(csv.Get(i, "Output"));
                int outputAmount = csv.GetInt(i, "OutputAmount");
                int input0Id = GetBlockId(csv.Get(i, "Input0"));
                int input0Amount = csv.GetInt(i, "Input0Amount");
                int input1Id = GetBlockId(csv.Get(i, "Input1"));
                int input1Amount = csv.GetInt(i, "Input1Amount");
                int input2Id = GetBlockId(csv.Get(i, "Input2"));
                int input2Amount = csv.GetInt(i, "Input2Amount");

                if (input0Id != -1)
                {
                    r.ingredients.Add(new Ingredient() { Type = input0Id, Amount = input0Amount });
                }
                if (input1Id != -1)
                {
                    r.ingredients.Add(new Ingredient() { Type = input1Id, Amount = input1Amount });
                }
                if (input2Id != -1)
                {
                    r.ingredients.Add(new Ingredient() { Type = input2Id, Amount = input2Amount });
                }

                if (outputId == -1) { throw new FormatException(); }
                if (r.ingredients.Count == 0) { throw new FormatException("Invalid ingredients in recipe " + i); }

                r.output = new Ingredient() { Type = outputId, Amount = outputAmount };
                craftingrecipes.Add(r);
            }
        }
コード例 #2
0
ファイル: GameData.cs プロジェクト: henon/manic_digger
 public void Load(string[] csv, string[] defaultmaterialslots, string[] lightlevels)
 {
     this.csv = new Csv();
     this.csv.LoadCsv(csv);
     int count = 256;
     Initialize(count);
     Update();
     for (int i = 0; i < 10; i++)
     {
         mDefaultMaterialSlots[i] = int.Parse(defaultmaterialslots[i]);
     }
     for (int i = 0; i < 16; i++)
     {
         mLightLevels[i] = float.Parse(lightlevels[i], System.Globalization.CultureInfo.InvariantCulture);
     }
 }