コード例 #1
0
ファイル: RecipesBase.cs プロジェクト: samuto/HelloWorld
 internal Recepe Find(Slot[] Grid)
 {
     string key = Recepe.GetKeyFromGrid(Grid);
     if (recepies.ContainsKey(key))
         return recepies[key];
     return null;
 }
コード例 #2
0
ファイル: CraftingTable.cs プロジェクト: samuto/HelloWorld
 public CraftingTable()
 {
     for (int i = 0; i < Grid.Length; i++)
     {
         Grid[i] = new Slot();
     }
 }
コード例 #3
0
ファイル: Inventory.cs プロジェクト: samuto/HelloWorld
 public Inventory()
 {
     // An inventory is made of 100% empty slots :)
     for (int i = 0; i < Slots.Length; i++)
     {
         Slots[i] = new Slot();
     }
 }
コード例 #4
0
ファイル: GuiCraftingForm.cs プロジェクト: samuto/HelloWorld
 protected override bool OnBeforeTransfer(Controls.GuiPanel guiSlot, Controls.GuiStackControl guiStack, Slot slot)
 {
     if (slot == craftingTable.Product)
     {
         PickUpProduct();
         return true;
     }
     return false;
 }
コード例 #5
0
ファイル: GuiCraftingForm.cs プロジェクト: samuto/HelloWorld
 protected override bool OnPickUp(Controls.GuiPanel guiSlot, Controls.GuiStackControl guiStack, Slot slot)
 {
     if (slot == craftingTable.Product)
     {
         PickUpProduct();
         return true;
     }
     else
     {
         BindAll();
         return false;
     }
 }
コード例 #6
0
ファイル: GuiFurnaceForm.cs プロジェクト: samuto/HelloWorld
 protected override bool OnBeforeTransfer(Controls.GuiPanel guiSlot, Controls.GuiStackControl guiStack, Slot slot)
 {
     if (slot == furnace.Fuel)
     {
         // we can only use blocks as fuel if they have HOF greater than 0
         return stackInHand.AsEntity.HeatOfCombustion <= 0;
     }
     else if (slot == furnace.Product)
     {
         return true;
     }
     return false;
 }
コード例 #7
0
ファイル: Recepe.cs プロジェクト: samuto/HelloWorld
        internal static string GetKeyFromGrid(Slot[] Grid)
        {
            List<int> ids = new List<int>();
            int minX = 3;
            int maxX = 0;
            int minY = 3;
            int maxY = 0;
            int x, y;
            for (int i = 0; i < 9; i++)
            {
                x = i % 3;
                y = i / 3;
                if (Grid[i].IsNotEmpty)
                {
                    if (x < minX)
                        minX = x;
                    if (x > maxX)
                        maxX = x;
                    if (y < minY)
                        minY = y;
                    if (y > maxY)
                        maxY = y;
                }
            }
            string key = "";
            for (y = minY; y <= maxY; y++)
            {
                for (x = minX; x <= maxX; x++)
                {

                    int i = x + y * 3;
                    if (Grid[i].Content.IsEmpty)
                    {
                        key += "0";
                        continue;
                    }
                    int id = Grid[i].Content.Id;
                    if (!ids.Contains(id))
                    {
                        ids.Add(id);
                    }
                    key += ids.IndexOf(id) + 1;
                }
                key += ",";
            }
            key += string.Join(":", ids);
            return key;
        }
コード例 #8
0
ファイル: GuiInventoryForm.cs プロジェクト: samuto/HelloWorld
        protected GuiPanel CreateAndBindGuiSlot(Slot slot, int x, int y)
        {
            GuiPanel panel = new GuiPanel()
            {
                Location = new SlimDX.Vector2(x * slotSize, y * slotSize),
                Size = new SlimDX.Vector2(slotSize, slotSize),
                Text = "",
                Tag = slot

            };
            panel.OnClick += new EventHandler<EventArgs>(slot_OnClick);
            AddControl(panel);

            // add moveable control...
            GuiStackControl guiStack = new GuiStackControl();
            guiStack.Size = new SlimDX.Vector2(GuiScaling.ItemSize, GuiScaling.ItemSize);
            guiStack.Tag = slot.Content;
            panel.AddControl(guiStack);
            guiStack.CenterInParent();
            BindControl(guiStack);

            return panel;
        }
コード例 #9
0
ファイル: RecipesBase.cs プロジェクト: samuto/HelloWorld
 internal Recepe Find(Slot input)
 {
     return Find(new Slot[] { input, new Slot(), new Slot(), new Slot(), new Slot(), new Slot(), new Slot(), new Slot(), new Slot() });
 }
コード例 #10
0
ファイル: GuiInventoryForm.cs プロジェクト: samuto/HelloWorld
 protected virtual void OnAfterPickUp(GuiPanel guiSlot, GuiStackControl guiStack, Slot slot)
 {
 }
コード例 #11
0
ファイル: GuiInventoryForm.cs プロジェクト: samuto/HelloWorld
 protected virtual bool OnPickUp(GuiPanel guiSlot, GuiStackControl guiStack, Slot slot)
 {
     return false;
 }
コード例 #12
0
ファイル: GuiInventoryForm.cs プロジェクト: samuto/HelloWorld
 protected virtual bool OnBeforeTransfer(GuiPanel guiSlot, GuiStackControl guiStack, Slot slot)
 {
     return false;
 }
コード例 #13
0
ファイル: GuiInventoryForm.cs プロジェクト: samuto/HelloWorld
 protected virtual void OnAfterTransfer(GuiPanel guiSlot, GuiStackControl guiStack, Slot slot)
 {
 }
コード例 #14
0
ファイル: GuiCraftingForm.cs プロジェクト: samuto/HelloWorld
 protected override void OnAfterTransfer(Controls.GuiPanel guiSlot, Controls.GuiStackControl guiStack, Slot slot)
 {
     BindAll();
 }