예제 #1
0
        private void blockReversalInputTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            //TODO add watermark

            var text = this.BlockReversalInputTextBox.Text;

            SlotInput slotInput = new SlotInput(text);

            if (slotInput.IsReversalValid)
            {
                BlockReversalErrorTextBlock.Visibility = Visibility.Hidden;
                BlockReversalEnableButton.IsEnabled    = true;
            }
            else
            {
                BlockReversalErrorTextBlock.Visibility = Visibility.Visible;

                if (!string.IsNullOrEmpty(text))
                {
                    BlockReversalErrorTextBlock.Text = "Invalid Input";
                }

                BlockReversalEnableButton.IsEnabled = false;
            }
        }
예제 #2
0
        private void enableButton_Click(object sender, RoutedEventArgs e)
        {
            int slotNumber = 0;

            if (Slot1R.IsChecked != null && Slot1R.IsChecked.Value)
            {
                slotNumber = 1;
            }
            else if (Slot2R.IsChecked != null && Slot2R.IsChecked.Value)
            {
                slotNumber = 2;
            }
            else if (Slot3R.IsChecked != null && Slot3R.IsChecked.Value)
            {
                slotNumber = 3;
            }


            var slotInput = new SlotInput(InputTextBox.Text);

            _reversalTool.SetInputInSlot(slotNumber, slotInput);



            _reversalTool.StartWakeupReversalLoop(slotInput, 100, true);


            this.ReversalActivation(true);
        }
예제 #3
0
    public IEnumerator MutliplyItem(SlotInput si)
    {
        float elapsed = 0.0f;

        si.LockSlot();
        if (!Ongoing.ContainsKey(si))
        {
            Ongoing.Add(si, 1);
        }
        else
        {
            Ongoing[si] += 1;
        }
        while (elapsed < MultiplyTime)
        {
            elapsed += Interval;
            yield return(new WaitForSeconds(Interval));
        }
        Ongoing[si] -= 1;
        IncreaseItemQuantity(si.StoredItem);
        if (Ongoing[si] <= 0)
        {
            Ongoing.Remove(si);
            si.UnlockSlot();
        }
    }
예제 #4
0
        private void button11_Click(object sender, EventArgs e)
        {
            BlockReversalButtonEnable();
            SlotInput slotInput = new SlotInput(textBox1.Text);

            _reversalTool.SetInputInSlot(1, slotInput);
            this._reversalTool.StartBlockReversalLoop(slotInput, this.trackBar2.Value, 0);
        }
예제 #5
0
        private void button6_Click(object sender, EventArgs e)
        {
            ReversalButtonEnable();
            SlotInput slotInput = new SlotInput(textBox1.Text);

            _reversalTool.SetInputInSlot(1, slotInput);

            _reversalTool.StartWakeupReversalLoop(slotInput, trackBar2.Value);
        }
        public void Input_Test(string input, string expectedInput)
        {
            //Arrange
            SlotInput slotInput = new SlotInput(input);

            //Act
            var result = slotInput.Input;

            //Assert
            Assert.AreEqual(expectedInput, result);
        }
        public void ReversalFrameIndex_Test(string input, int reversalFrameIndex)
        {
            //Arrange
            SlotInput slotInput = new SlotInput(input);

            //Act
            var result = slotInput.ReversalFrameIndex;

            //Assert
            Assert.AreEqual(reversalFrameIndex, result);
        }
예제 #8
0
    public void OnDrop(PointerEventData eventData)
    {
        if (PlayerData.Slots[SlotID] == null)
        {
            return;
        }
        ItemInput droppedItem = eventData.pointerDrag.GetComponent <ItemInput>();
        SlotInput otherSlot   = droppedItem.GetComponent <ItemInput>().OriginalParent.GetComponent <SlotInput>();

        if (otherSlot == this || IsLocked || otherSlot.IsLocked)
        {
            return;
        }
        Debug.Assert(PlayerData.Slots[SlotID].transform.childCount == 0 || PlayerData.Slots[SlotID].transform.childCount == 1);
        if (!CraftingSlot && !otherSlot.CraftingSlot && !IsStructureSlot && !otherSlot.IsStructureSlot ||
            CraftingSlot && otherSlot.CraftingSlot ||
            IsStructureSlot && otherSlot.IsStructureSlot)
        {
            SlotToSlot(droppedItem, otherSlot);
        }
        else if (CraftingSlot && !otherSlot.CraftingSlot && !otherSlot.IsStructureSlot)
        {
            SlotCraftTransfer(droppedItem, otherSlot, PlayerData.CraftingInventory, PlayerData.NumCraftingSlots,
                              PlayerData.CraftingSlots, PlayerData.CraftingItems, Pd.GetInventory());
        }
        else if (!CraftingSlot && otherSlot.CraftingSlot && !otherSlot.IsStructureSlot)
        {
            SlotCraftTransfer(droppedItem, otherSlot, Pd.GetInventory(), PlayerData.NumItemSlots,
                              PlayerData.Slots, PlayerData.Items, PlayerData.CraftingInventory);
        }
        else if (Pd.CurrentTile.Structure.Value != null)
        {
            Dictionary <String, Item> structureInventory = Pd.CurrentTile.Structure.Value.GetComponent <StructureData>().Inventory;
            List <GameObject>         itContainer        = Pd.CurrentTile.Structure.Value.GetComponent <StructureData>().ItemContainer;
            if (IsStructureSlot && !otherSlot.IsStructureSlot)
            {
                SlotStructureTransfer(droppedItem, otherSlot, structureInventory, PlayerData.NumStructSlots, PlayerData.StructureSlots, itContainer, Pd.GetInventory());
            }
            else if (!IsStructureSlot && otherSlot.IsStructureSlot)
            {
                SlotStructureTransfer(droppedItem, otherSlot, Pd.GetInventory(), PlayerData.NumItemSlots, PlayerData.Slots, PlayerData.Items, structureInventory);
            }
        }
    }
예제 #9
0
    protected void SlotCraftTransfer(ItemInput droppedItem, SlotInput otherSlot, Dictionary <string, Item> InventoryAdd, int numSlots,
                                     List <GameObject> slotsContainer, List <GameObject> itemsContainer, Dictionary <string, Item> InventoryRemove)
    {
        Item it   = otherSlot.StoredItem;
        var  type = it.GetType();
        var  obj  = (Item)Activator.CreateInstance(type, it);

        obj.ActiveContainer = null;
        obj.SetQuantity(1);
        Pd.AddItem(
            obj,
            InventoryAdd,
            numSlots,
            slotsContainer,
            itemsContainer,
            true
            );
        Pd.RemoveItem(it, 1, InventoryRemove);
    }
예제 #10
0
 protected void SlotToSlot(ItemInput droppedItem, SlotInput otherSlot)
 {
     if (PlayerData.Slots[this.SlotID].transform.childCount == 1)
     {
         otherSlot.StoredItem      = this.StoredItem;
         otherSlot.StoredItem.Slot = otherSlot.SlotID;
         GameObject thisItem = PlayerData.Slots[this.SlotID].GetComponentInChildren <ItemInput>().gameObject;
         thisItem.transform.SetParent(otherSlot.transform);
         thisItem.transform.localPosition = Vector2.zero;
     }
     else
     {
         otherSlot.StoredItem.Slot = this.SlotID;
         otherSlot.StoredItem      = null;
     }
     droppedItem.transform.SetParent(this.transform);
     droppedItem.transform.localPosition = Vector2.zero;
     this.StoredItem      = droppedItem.GetComponent <ItemInput>().Item;
     this.StoredItem.Slot = this.SlotID;
 }
예제 #11
0
 // Use this for initialization
 private void Awake()
 {
     DiscoveredTiles = new HashSet <Tile>();
     VisionRange     = PlayerNode["VisionRange"];
     for (int i = 0; i < PlayerData.NumItemSlots + PlayerData.NumCraftingSlots; i++)
     {
         GameObject Is = Instantiate(InventorySlot);
         PlayerData.Slots.Add(Is);
         PlayerData.Slots[i].GetComponent <SlotInput>().SlotID = i;
         if (i >= PlayerData.NumItemSlots)
         {
             PlayerData.CraftingSlots.Add(Is);
             PlayerData.CraftingSlots[i - PlayerData.NumItemSlots] = PlayerData.Slots[i];
             PlayerData.Slots[i].transform.SetParent(CraftingPanel.transform, false);
             PlayerData.CraftingSlots[i - PlayerData.NumItemSlots].GetComponent <SlotInput>().CraftingSlot = true;
         }
         else
         {
             PlayerData.Slots[i].transform.SetParent(this.SlotPanel.transform, false);
             PlayerData.Slots[i].GetComponent <SlotInput>().CraftingSlot = false;
         }
     }
     for (int i = 0; i < PlayerData.NumStructSlots; i++)
     {
         GameObject Is = Instantiate(InventorySlot);
         PlayerData.Slots.Add(Is);
         int       idx = i + PlayerData.NumItemSlots + PlayerData.NumCraftingSlots;
         SlotInput sI  = PlayerData.Slots[idx].GetComponent <SlotInput>();
         sI.SlotID          = idx;
         sI.CraftingSlot    = false;
         sI.IsStructureSlot = true;
         StructureSlots.Add(Is);
         StructureSlots[i].transform.SetParent(StructurePanel.transform, false);
         FOWStructures = new List <GameObject>();
         AllStructures = new HashSet <GameObject>();
     }
 }
예제 #12
0
    protected void SlotStructureTransfer(ItemInput droppedItem, SlotInput otherSlot, Dictionary <string, Item> InventoryAdd, int numSlots,
                                         List <GameObject> slotsContainer, List <GameObject> itemsContainer, Dictionary <string, Item> InventoryRemove)
    {
        SlotCraftTransfer(droppedItem, otherSlot, InventoryAdd, numSlots,
                          slotsContainer, itemsContainer, InventoryRemove);
        //Granary
        if (Pd.CurrentTile.Structure.Value.GetComponent <StructureData>() is GranaryData &&
            InventoryRemove == Pd.GetInventory())
        {
            GranaryData gD = (GranaryData)Pd.CurrentTile.Structure.Value.GetComponent <StructureData>();

            /*foreach (GameObject g in itemsContainer) {
             *  if (g.gameObject == null) {
             *      itemsContainer.Remove(g);
             *  }
             * }*/
            GameObject asdf = itemsContainer.Find(g => g.gameObject && g.GetComponent <ItemInput>().Item.GetName().Equals(droppedItem.Item.GetName()));
            if (!(asdf.GetComponent <ItemInput>().Item is Food))
            {
                return;
            }
            gD.StartCoroutine(gD.MutliplyItem(asdf.gameObject.transform.parent.GetComponent <SlotInput>()));
        }
        //Torch
        if (!(Pd.CurrentTile.Structure.Value.GetComponent <StructureData>() is GranaryData) &&
            InventoryRemove == Pd.GetInventory() && droppedItem.Item.GetName().Equals(Global.ItemNames[ItemList.Torch]))
        {
            Pd.FOWStructures.Add(Pd.CurrentTile.Structure.Value);
            Debug.Log("hello");
        }
        else if (!(Pd.CurrentTile.Structure.Value.GetComponent <StructureData>() is GranaryData) &&
                 !(InventoryRemove == Pd.GetInventory()) && droppedItem.Item.GetName().Equals(Global.ItemNames[ItemList.Torch]))
        {
            Pd.FOWStructures.Remove(Pd.CurrentTile.Structure.Value);
        }
    }
예제 #13
0
        private void button5_Click(object sender, EventArgs e)
        {
            SlotInput slotInput = new SlotInput(textBox1.Text);

            _reversalTool.SetInputInSlot(3, slotInput);
        }