Esempio n. 1
0
    void ShopOffer()
    {
        _clickedButton = EventSystem.current.currentSelectedGameObject;
        string buttonName = _clickedButton.name;
        Offer  offer      = _offers[Int32.Parse(buttonName)];

        //AcceptSellTerms
        switch (offer.SellProd)
        {
        case "CarryCnt":
            _messagePanelHandler.ShowMessage("Are you sure you want to acquire this slot at this level for " + offer.PayAmount + " " + offer.PayProd + "(s)?", MessagePanel.PanelType.YesNo, () => { DoShop(offer); });
            return;

        case "Life":
            _messagePanelHandler.ShowMessage("Are you sure you want to buy a life now for " + offer.PayAmount + " " + offer.PayProd + "(s)?", MessagePanel.PanelType.YesNo, () => { DoShop(offer); });
            return;
        }
        switch (offer.PayProd)
        {
        case "Money":
            _messagePanelHandler.ShowMessage("Are you sure you want to Spend " + offer.PayAmount + " cash?", MessagePanel.PanelType.YesNo, () => { DoShop(offer); });
            return;
        }
        _messagePanelHandler.ShowMessage("Are you sure you want to Spend " + offer.PayAmount + " " + offer.PayProd + "(s)?", MessagePanel.PanelType.YesNo, () => { DoShop(offer); });
    }
Esempio n. 2
0
    private void DoResearch()
    {
        //Set the Target Research
        _clickedButton = EventSystem.current.currentSelectedGameObject;
        string buttonName = _clickedButton.name;
        int    researchId = Int32.Parse(buttonName);

        Research          research          = null;
        CharacterResearch characterResearch = null;

        for (int i = 0; i < _researches.Count; i++)
        {
            if (_researches[i].Id == researchId)
            {
                research = _researches[i];
                break;
            }
        }
        if (research == null)
        {
            throw new Exception("Research is not available ");
        }
        research.Print();
        for (int i = 0; i < _characterResearches.Count; i++)
        {
            if (_characterResearches[i].ResearchId == researchId)
            {
                characterResearch = _characterResearches[i];
                break;
            }
        }
        int nextLevel = characterResearch != null ? characterResearch.Level + 1 : 1;

        //Check criteria
        if (!ResearchUpgradeIsValid(research))
        {
            _messagePanelHandler.ShowMessage("Invalid Research!", MessagePanel.PanelType.Ok);
            return;
        }
        //Process the pay
        var payAmount = research.CalculatePrice(nextLevel);

        if (_characterManager.CharacterSetting.Coin < payAmount)
        {
            _messagePanelHandler.ShowMessage("You don't have enough Coin ! ", MessagePanel.PanelType.Ok);
            return;
        }
        _characterManager.AddCharacterSetting("Coin", -payAmount);
        MakeResearching(research, nextLevel);
        NewResearchInProgress(researchId);
        _messagePanelHandler.ShowMessage(research.Name + " is in progress ! ", MessagePanel.PanelType.Ok);
    }
Esempio n. 3
0
 private bool ValidateText(string str, int maxLength = 250)
 {
     if (str.Length < 3)
     {
         _messagePanelHandler.ShowMessage(str + " is a bit too short !!!  ", MessagePanel.PanelType.Ok);
         return(false);
     }
     if (str.Length > maxLength)
     {
         _messagePanelHandler.ShowMessage("Your reply is a bit too Long remove" + (str.Length - maxLength) + " characters) !!!  ", MessagePanel.PanelType.Ok);
         return(false);
     }
     return(true);
 }
Esempio n. 4
0
 private bool ValidateText(string str, int maxLength = 12)
 {
     if (str.Length < 3)
     {
         _messagePanelHandler.ShowMessage(str + " is a bit too short !!!  ", MessagePanel.PanelType.Ok);
         return(false);
     }
     if (str.Length > maxLength)
     {
         _messagePanelHandler.ShowMessage(str + " is a bit too Long (less than " + maxLength + ") !!!  ", MessagePanel.PanelType.Ok);
         return(false);
     }
     return(true);
 }
Esempio n. 5
0
 public void OnPointerClick(PointerEventData eventData)
 {
     if (TargetResearch == null)
     {
         return;
     }
     if (_time < DateTime.Now)
     {
         SceneSettings.GoToResearchScene();
     }
     else
     {
         _messagePanelHandler.ShowMessage("Are you sure you want to buy out your wait time for " + TimeHandler.GemTimeValue(_time - DateTime.Now) + " gem(s)?",
                                          MessagePanel.PanelType.YesNo,
                                          SpendGem,
                                          SceneSettings.GoToResearchScene);
     }
 }
Esempio n. 6
0
    public void OnDrop(PointerEventData eventData)
    {
        ItemData draggedItem = eventData.pointerDrag.GetComponent <ItemData>();

        if (draggedItem == null)
        {
            return;
        }
        if (draggedItem.ItemIns == null)
        {
            return;
        }
        _messagePanelHandler.ShowMessage("Are you sure you want to Recycle this Item for %50 of Cost ?", MessagePanel.PanelType.YesCancel, () => { DeleteItem(draggedItem.ItemIns); });
    }
Esempio n. 7
0
    public void OnPointerClick(PointerEventData eventData)
    {
        if (ItemIns == null)
        {
            return;
        }
        Button btn = this.transform.parent.GetComponentInChildren <Button>();

        if (!btn.interactable)
        {
            return;
        }
        if (_time < DateTime.Now)
        {
            SceneSettings.GoToRecipeScene();
        }
        else
        {
            _messagePanelHandler.ShowMessage("Are you sure you want to buy out your wait time for " + TimeHandler.GemTimeValue(_time - DateTime.Now) + " gem(s)?",
                                             MessagePanel.PanelType.YesNo,
                                             SpendGem,
                                             SceneSettings.GoToRecipeScene);
        }
    }
Esempio n. 8
0
    public void OnDrop(PointerEventData eventData)
    {
        ItemData      draggedItem = eventData.pointerDrag.GetComponent <ItemData>();
        ItemMixture   mixedItem   = eventData.pointerDrag.GetComponent <ItemMixture>();
        ItemEquipment equipedItem = eventData.pointerDrag.GetComponent <ItemEquipment>();

        if (mixedItem == null && draggedItem == null && equipedItem == null)
        {
            return;
        }
        if (mixedItem != null)
        {
            if (mixedItem.ItemIns == null)
            {
                return;
            }
            if (!mixedItem.ReadyToUse())
            {
                return;
            }
        }
        if (draggedItem != null)
        {
            if (draggedItem.ItemIns == null)
            {
                return;
            }
        }
        if (equipedItem != null)
        {
            if (equipedItem.ItemIns == null)
            {
                return;
            }
        }
        ItemData existingItem = this.transform.GetComponentInChildren <ItemData>();

        if (existingItem == null)
        {
            return;
        }
        //Item from Mixture Area
        if (mixedItem != null)
        {
            if (mixedItem.ItemIns != null)
            {
                //#################################### not empty slot
                if (existingItem.ItemIns != null && existingItem.ItemIns.Item.Id != mixedItem.ItemIns.Item.Id)
                {
                    _inv.PrintMessage("New item should be placed in an empty inventory slot", Color.yellow);
                }
                //#################################### empty slot
                else
                {
                    if (_inv.AddItemToInventory(mixedItem.ItemIns.Item, mixedItem.ItemIns.UserItem.StackCnt, existingItem.SlotIndex))
                    {
                        //Delete mixedItem Item
                        mixedItem.LoadEmpty();
                        _inv.UpdateInventory();
                    }
                }
                return;
            }
        }
        //Item from equipments Area
        if (equipedItem != null)
        {
            if (equipedItem.ItemIns != null)
            {
                //#################################### not empty slot
                if (existingItem.ItemIns != null)
                {
                    _inv.PrintMessage("New item should be placed in an empty inventory slot", Color.yellow);
                }
                //#################################### empty slot
                else
                {
                    //Set the slot Item
                    existingItem.ItemIns = equipedItem.ItemIns;
                    existingItem.transform.parent.name         = existingItem.transform.name = existingItem.ItemIns.Item.Name;
                    existingItem.GetComponent <Image>().sprite = existingItem.ItemIns.Item.GetSprite();
                    var stackCntText = existingItem.transform.GetComponentInChildren <TextMeshProUGUI>();
                    stackCntText.text = existingItem.ItemIns.UserItem.StackCnt > 1 ? existingItem.ItemIns.UserItem.StackCnt.ToString() : "";
                    existingItem.ItemIns.UserItem.Order    = existingItem.SlotIndex;
                    existingItem.ItemIns.UserItem.Equipped = false;
                    //unload new Item to equipments
                    equipedItem.LoadItem(null);
                    _inv.UpdateInventory();
                }
                return;
            }
        }
        if (draggedItem != null)
        {
            if (SlotIndex != draggedItem.SlotIndex)
            {
                //#################################### Empty slot logic swap
                if (existingItem.ItemIns == null)
                {
                    //Swap Parent
                    draggedItem.transform.SetParent(existingItem.transform.parent);
                    existingItem.transform.SetParent(draggedItem.Parent);
                    draggedItem.Parent = null;
                    //Swap positions
                    existingItem.transform.position = existingItem.transform.parent.position;
                    draggedItem.transform.position  = draggedItem.transform.parent.position;
                    //Swap SlotIndex
                    var temp2 = existingItem.SlotIndex;
                    existingItem.SlotIndex             = draggedItem.SlotIndex;
                    draggedItem.ItemIns.UserItem.Order = draggedItem.SlotIndex = temp2;
                    //Swapping names
                    existingItem.transform.parent.name = "Empty";
                    draggedItem.transform.parent.name  = draggedItem.ItemIns.Item.Name;
                    _inv.UpdateInventory();
                }
                //#################################### Stacking: Same items Stack them together
                else if (existingItem.ItemIns.Item.Id == draggedItem.ItemIns.Item.Id)
                {
                    if (existingItem.ItemIns.UserItem.StackCnt + draggedItem.ItemIns.UserItem.StackCnt > existingItem.ItemIns.Item.MaxStackCnt)
                    {
                        draggedItem.ItemIns.UserItem.StackCnt  = draggedItem.ItemIns.UserItem.StackCnt - (existingItem.ItemIns.Item.MaxStackCnt - existingItem.ItemIns.UserItem.StackCnt);
                        existingItem.ItemIns.UserItem.StackCnt = existingItem.ItemIns.Item.MaxStackCnt;
                    }
                    else
                    {
                        existingItem.ItemIns.UserItem.StackCnt = draggedItem.ItemIns.UserItem.StackCnt + existingItem.ItemIns.UserItem.StackCnt;
                        draggedItem.ItemIns.UserItem.StackCnt  = 0;
                    }
                    var stackCntText = existingItem.transform.GetComponentInChildren <TextMeshProUGUI>();
                    if (existingItem.ItemIns.UserItem.StackCnt > 1)
                    {
                        stackCntText.text = existingItem.ItemIns.UserItem.StackCnt.ToString();
                    }
                    _inv.UpdateInventory();
                }
                else
                {
                    Recipe newRecipe = _inv.CheckRecipes(existingItem.ItemIns.Item.Id, draggedItem.ItemIns.Item.Id);
                    //#################################### Mixing
                    if (newRecipe != null)
                    {
                        if (newRecipe.FirstItemCnt <= existingItem.ItemIns.UserItem.StackCnt)
                        {
                            if (newRecipe.SecondItemCnt <= draggedItem.ItemIns.UserItem.StackCnt)
                            {
                                if (_itemMixture.ItemIns != null)
                                {
                                    _inv.PrintMessage("You are already making an Item", Color.yellow);
                                }
                                else
                                {
                                    //Mixing items Logic (Lambda) can also be 2 func in it :  () => { InstantiateObject(thingToSpawn); InstantiateObject(thingToSpawn, thingToSpawn); }
                                    _messagePanelHandler.ShowMessage(newRecipe.GetDescription(), MessagePanel.PanelType.YesCancel, () => { MixItemData(ref existingItem, ref draggedItem, newRecipe); });
                                }
                            }
                            else //Not enough materials
                            {
                                _inv.PrintMessage("Not enough " + draggedItem.ItemIns.Item.Name +
                                                  " in the inventory, You need " +
                                                  (newRecipe.SecondItemCnt - draggedItem.ItemIns.UserItem.StackCnt) + " more", Color.yellow);
                            }
                        }
                        else //Not enough materials
                        {
                            _inv.PrintMessage("Not enough " + existingItem.ItemIns.Item.Name + " in the inventory, You need " +
                                              (newRecipe.FirstItemCnt - existingItem.ItemIns.UserItem.StackCnt) + " more", Color.yellow);
                        }
                    }
                    //#################################### Swaping: Unmixable items Stack them together
                    else
                    {
                        //Swap Parent
                        draggedItem.transform.SetParent(existingItem.transform.parent);
                        existingItem.transform.SetParent(draggedItem.Parent);
                        draggedItem.Parent = null;
                        //Swap positions
                        existingItem.transform.position = existingItem.transform.parent.position;
                        draggedItem.transform.position  = draggedItem.transform.parent.position;
                        //Swap SlotIndex
                        var temp2 = existingItem.SlotIndex;
                        existingItem.ItemIns.UserItem.Order = existingItem.SlotIndex = draggedItem.SlotIndex;
                        draggedItem.ItemIns.UserItem.Order  = draggedItem.SlotIndex = temp2;
                        //Swapping names
                        existingItem.transform.parent.name = existingItem.ItemIns.Item.Name;
                        draggedItem.transform.parent.name  = draggedItem.ItemIns.Item.Name;

                        _inv.UpdateInventory();
                    }
                }
            }
        }
    }
Esempio n. 9
0
 public void GoToStartScene()
 {
     _messagePanelHandler.ShowMessage("Are you sure you want to lose all your progress with " + _settings.Name + "?", MessagePanel.PanelType.YesNo, StartNewCharacter);
 }
Esempio n. 10
0
 public void BuyTime()
 {
     _messagePanelHandler.ShowMessage("Are you sure you want to buy out your wait time " + _buyText.text + " gem(s)?",
                                      MessagePanel.PanelType.YesNo,
                                      () => { SpendGem(); });
 }