private void _onBuy1(string slug, SerializablePropertys.Property property, SerializablePackages.PayBy payBy)
    {
        _controlShop.contentPane.visible = false;
        string name_item = NameOf(property, slug);
        // string last_text = InputFieldHelper.Instance.LastTextChatBottom();
        string text = string.Format("{0} costs ${1} {2}", name_item, payBy.coin, DefineAON.CoinName);

        text += "\nThank you very much for your purchase!";
        // text += string.Format("\nThe {0} was putted in your Bag!", name_item);
        InputFieldHelper.Instance.ShowChatBottom(text, true, (TypingEffectByLine ty) =>
        {
            PropertysGame.PropertyChar pChar = PropertysGame.Instance.AddItem(m_dataRaw, slug);
            RefreshDataSelect();
            if (property.IsOutfit || property.IsPet)
            {
                _onBuy2(name_item, slug, property, pChar);
            }
            else
            {
                if (mOnBuy != null)
                {
                    mOnBuy(_controlShop);
                }
            }
        });
    }
    private void _onBuy(string slug, SerializablePropertys.Property property, SerializablePackages.PayBy payBy)
    {
        if (payBy.coin <= 0)
        {
            //Free
            _onBuy1(slug, property, payBy);
            return;
        }
        int currentCoin = TriggerGame.Instance.WorldFlag["Coin"];

        if (currentCoin < payBy.coin)
        {
            string name_item = NameOf(property, slug);
            string text      = string.Format("Sorry, {0} costs ${1} {2}, you don't have enough!", name_item, payBy.coin, DefineAON.CoinName);
            _controlShop.contentPane.visible = false;
            InputFieldHelper.Instance.ShowChatBottom(text, true, (TypingEffectByLine ty) =>
            {
                _controlShop.contentPane.visible = true;
            });
        }
        else
        {
            TriggerGame.Instance.WorldFlag.DoAdd("Coin", -payBy.coin);
            _onBuy1(slug, property, payBy);
        }
    }
        public static PropertyChar CreateFromSlug(SerializablePropertys.Property propertyBase, string slug)
        {
            PropertyChar pc = new PropertyChar();

            pc.Slug         = slug;
            pc.PropertyBase = propertyBase;
            return(pc);
        }
    private void _showCertificates(SerializablePropertys.Property propertyData, PropertyChar propertyOwn)
    {
        controlPropertys.ResetSelectItem();

        controlPropertys.SetItemName(propertyData.Name);

        controlPropertys.SetItemDes(propertyData.Des);

        controlPropertys.LoadImageItem(propertyData.RefIcon);
    }
 public PropertyChar GetCertificates(SerializablePropertys.Property property)
 {
     for (int i = 0; i < PropertysChar.Count; i++)
     {
         var p = PropertysChar[i];
         if (p.PropertyBase.IsCertificates && p.PropertyBase == property)
         {
             return(p);
         }
     }
     return(null);
 }
 private void _addAllPets(SerializablePackages.Package package, SerializablePropertys propertys)
 {
     package.RemoveAll();
     for (int i = 0; i < propertys.Count; i++)
     {
         SerializablePropertys.Property p = propertys.PropertyByIndex(i);
         if (p._Type == SerializablePropertys.EType.Pet)
         {
             package.AddProperty(propertys.SlugByIndex(i));
         }
     }
 }
    private void _onEquipLate(string name_item, string slug, SerializablePropertys.Property property)
    {
        string text = string.Format("{0} has been added in your bag!", name_item);

        InputFieldHelper.Instance.ShowChatBottom(text, true, (TypingEffectByLine ty) =>
        {
            if (mOnBuy != null)
            {
                mOnBuy(_controlShop);
            }
        });
    }
 private string NameOf(SerializablePropertys.Property property, string slug)
 {
     if (property == null)
     {
         return("Item not found");
     }
     else if (!string.IsNullOrEmpty(property.Name))
     {
         return(property.Name);
     }
     else if (!string.IsNullOrEmpty(slug))
     {
         return(slug);
     }
     return("Item name is NULL");
 }
 private void _onBuy2(string name_item, string slug, SerializablePropertys.Property property, PropertysGame.PropertyChar pChar)
 {
     InputFieldHelper.Instance.ShowChatBottom("Do you want to equip now?", false, (TypingEffectByLine ty) =>
     {
         var pm_choise = new QuickControlList();
         pm_choise.AddBt("Equip", (EventContext context) =>
         {
             pm_choise.Dispose();
             _onEquipNow(name_item, slug, property, pChar);
         });
         pm_choise.AddBt("Later", (EventContext context) =>
         {
             pm_choise.Dispose();
             _onEquipLate(name_item, slug, property);
         });
         pm_choise.SetParent(InputFieldHelper.Instance.PopUp);
     });
 }
    private void _showPet(SerializablePropertys propertys, SerializablePropertys.Property propertyData, PropertyChar propertyOwn)
    {
        controlPropertys.ResetSelectItem();

        controlPropertys.SetItemName(propertyData.Name);

        controlPropertys.SetItemDes(propertyData.Des);

        if (string.IsNullOrEmpty(propertyData.RefSlug))
        {
            InputFieldHelper.Instance.ShowNoti("Item model is null");
            return;
        }
        controlPropertys.LoadModelItem("pets/" + propertyData.RefSlug);

        if (propertyOwn != null)
        {
            bool isEquip = propertyOwn.IsActive;
            if (!isEquip)
            {
                controlPropertys.AddAction("Equip", () =>
                {
                    // basicMecanimControl.Pet = propertyData.RefSlug;
                    EquipPet(propertyOwn);
                    _refreshPets(propertys, false);
                });
            }
            else
            {
                controlPropertys.SetItemDes("Item is equipped");
                controlPropertys.AddAction("Unequip", () =>
                {
                    // basicMecanimControl.Pet = "";
                    UnquipCurrentPet();
                    _refreshPets(propertys, false);
                });
            }
        }
    }
    private void _onEquipNow(string name_item, string slug, SerializablePropertys.Property property, PropertysGame.PropertyChar pChar)
    {
        if (property.IsOutfit)
        {
            var charGame = AutoTileMap_Editor.Instance.Agent.GetComponentInChildren <CharGame>();
            PropertysGame.Instance.Equip(charGame, pChar);
        }
        else if (property.IsPet)
        {
            PropertysGame.Instance.EquipPet(pChar);
        }

        string text = string.Format("{0} is equipped!", name_item);

        InputFieldHelper.Instance.ShowChatBottom(text, true, (TypingEffectByLine ty) =>
        {
            if (mOnBuy != null)
            {
                mOnBuy(_controlShop);
            }
        });
    }
Exemple #12
0
    // [SerializeField]
    // public Propertys Items = new Propertys();
    // [SerializeField]
    // public Propertys Certificates = new Propertys();
    // [SerializeField]
    // public Propertys Pet = new Propertys();
    // [SerializeField]
    // public Propertys House = new Propertys();

    // public Propertys GetByType( EType t){
    //     return Outfit;
    // }


    // public Property PropertyBySlug(EType type, string slugName)
    // {
    //     var index = Outfit.key.IndexOf(slugName);
    //     if (index < 0)
    //         return null;
    //     return Outfit[index];
    // }

    public SerializablePropertys.Property Add(string slugName)
    {
        SerializablePropertys.Property p = new SerializablePropertys.Property(slugName);
        all.Add(p);
        return(p);
    }
    private void _tryOnItem(CharGame charGame, Item rawItem, Item tryItem, string slug, SerializablePropertys.Property property, SerializablePackages.PayBy payBy)
    {
        _controlShop.contentPane.visible = false;
        {
            // Cam
            var   cam           = AutoTileMap_Editor.Instance.CamControler;
            float _camXAngle_to = cam.camXAngle;
            float _y_to         = cam.yCam;
            // float _y_to = 0;
            float   _distance_to = cam.minDistance;
            Vector3 _target_to   = charGame.transform.position;
            cam.MoveCamTo(_camXAngle_to, _y_to, _distance_to, _target_to, () =>
            {
                // cam.canControl = true;
                // cam.target = charGame.transform;
            });
        }
        UnTryCostume(charGame);
        TryCostume(charGame, rawItem, tryItem);
        {
            var b = AutoTileMap_Editor.Instance.Agent.GetComponent <BasicMecanimControl>();
            if (b != null)
            {
                b.TriggerTalk();
            }
        }
        var pm_choise = new QuickControlList();

        pm_choise.AddBt("Untry", (EventContext context) =>
        {
            // Debug.Log("Click Cancel");
            pm_choise.Dispose();
            UnTryCostume(charGame);
            _controlShop.contentPane.visible = true;
        });
        pm_choise.AddBt("Buy", (EventContext context) =>
        {
            // Debug.Log("Click Buy");
            pm_choise.Dispose();
            UnTryCostume(charGame);
            _onBuy(slug, property, payBy);
        });
        pm_choise.SetParent(InputFieldHelper.Instance.PopUp);
        // Hide chatBottom
        var chatBottom = InputFieldHelper.Instance.GComponent_ChatBottom;

        if (chatBottom != null && chatBottom.visible)
        {
            chatBottom.visible = false;
            pm_choise.SetOnDispose(() =>
            {
                chatBottom.visible = true;
            });
        }
    }
Exemple #14
0
    private bool OnGuiBot(SerializablePropertys data, List <FlagAction> listFlagAction, TilesetAON tilesetAON, Rect rect)
    {
        if (data == null)
        {
            return(false);
        }
        float yGui      = rect.y + 4;
        float widthLeft = 200;

        AONGUI.Label(new Rect(rect.x + 4, yGui + DefineAON.GUI_Y_Label, widthLeft, DefineAON.GUI_Height_Label), "Edit property:");
        yGui += 32f;
        {
            comboBoxSlug.UpdateListContent(data.AllKey);
            comboBoxSlug.Empty             = "Not selected";
            comboBoxSlug.SelectedItemIndex = slugIndext;
            comboBoxSlug.Rect.x            = rect.x;
            comboBoxSlug.Rect.y            = yGui;
            comboBoxSlug.Rect.width        = widthLeft;
            comboBoxSlug.Rect.height       = 32f;
            comboBoxSlug.Show(rect.height - yGui, "defause", true, false, (int next) => {
                slugIndext = next;
            });
        }
        // if(comboBoxSlug.IsDropDownListVisible){
        //  return true;
        // }
        yGui   = rect.y + 4;
        rect.x = rect.x + widthLeft + 4;
        if (slugIndext < 0 || slugIndext >= data.AllKey.Count)
        {
            return(true);
        }

        AONGUI.Button(new Rect(rect.x, yGui + DefineAON.GUI_Y_Button, 120, DefineAON.GUI_Height_Button), "Remove by slug", () => {
            data.Remove(slugIndext);
        });

        SerializablePropertys.Property property = data.PropertyByIndex(slugIndext);
        AONGUI.Button(new Rect(rect.x + 130, yGui + DefineAON.GUI_Y_Button, 120, DefineAON.GUI_Height_Button), "Duplicate by slug", () => {
            var n = data.Copy(slugIndext);
            if (n >= 0)
            {
                slugIndext = n;
            }
        });
        yGui += 32f;
        AONGUI.Label(new Rect(rect.x, yGui + DefineAON.GUI_Y_Label, 40, DefineAON.GUI_Height_Label), "Name");
        AONGUI.TextField(new Rect(rect.x + 40, yGui + DefineAON.GUI_Y_TextField, widthLeft - 40, DefineAON.GUI_Height_TextField), property.Name, (string text) => {
            property.Name = text;
        });
        yGui += 32f;

        AONGUI.Label(new Rect(rect.x, yGui + DefineAON.GUI_Y_Label, 40, DefineAON.GUI_Height_Label), "Des");
        AONGUI.TextField(new Rect(rect.x + 40, yGui + DefineAON.GUI_Y_TextField, widthLeft - 40, DefineAON.GUI_Height_TextField), property.Des, (string text) => {
            property.Des = text;
        });
        yGui += 32f;

        string[] strType = SerializablePropertys.StrEType;
        AONGUI.SelectionGrid(new Rect(rect.x, yGui, rect.width, 24f), (int)property._Type, strType, strType.Length, tilesetAON.ListStyleGrid, (int next) => {
            var tNext = (SerializablePropertys.EType)next;
            if (tNext != property._Type)
            {
                property._Type = tNext;
            }
        });

        yGui += 32f;

        // if(property.IsItem){
        //  property.StackInBag = GUI.Toggle(new Rect( rect.x, yGui + DefineAON.GUI_Y_Label, widthLeft, DefineAON.GUI_Height_Label ), property.StackInBag, "Can Stack in bag");
        //  yGui += 32f;
        // }

        // property.CanEquip = GUI.Toggle(new Rect( rect.x, yGui + DefineAON.GUI_Y_Label, widthLeft, DefineAON.GUI_Height_Label ), property.CanEquip, " Can Equip");
        if (property.IsOutfit)
        {
            // float xGui = rect.x + widthLeft + 4;
            float xGui = rect.x;
            AONGUI.Label(new Rect(xGui, yGui + DefineAON.GUI_Y_Label, 60, DefineAON.GUI_Height_Label), "Item :");
            xGui += 60;
            string[] str         = AutoTileMap_Editor.Instance.ItemCharData.StrItemList;
            var      combobox    = ComboBoxHelper.Instance.StringN(str);
            var      hash        = "item";
            int      currentItem = ComboBoxHelper.Instance.IndextOfStringN(str, property.RefSlug);
            if (currentItem == -1)
            {
                if (property.RefSlug != null && property.RefSlug != "")
                {
                    combobox.Empty = property.RefSlug + " (not found)";
                }
                else
                {
                    combobox.Empty = "NULL";
                }
            }
            combobox.SelectedItemIndex = currentItem;
            combobox.Rect.x            = xGui;
            combobox.Rect.y            = yGui;
            combobox.Rect.width        = widthLeft;
            combobox.Rect.height       = 32f;
            float limitHeight = 32f * 6;
            combobox.Show(limitHeight, hash, (int nextItem) => {
                property.RefSlug = str[nextItem];
            });
            if (combobox.IsDropDownWithHash(hash))
            {
                yGui += limitHeight;
                return(false);
            }
            yGui += 32f;
        }

        // property.CanUsing = GUI.Toggle(new Rect( rect.x, yGui + DefineAON.GUI_Y_Label, widthLeft, DefineAON.GUI_Height_Label ), property.CanUsing, " Can Using");
        if (property.IsItem)
        {
            // float xGui = rect.x + widthLeft + 4;
            float xGui = rect.x;
            AONGUI.Label(new Rect(xGui, yGui + DefineAON.GUI_Y_Label, 60, DefineAON.GUI_Height_Label), "Action :");
            xGui += 60;
            var combobox          = ComboBoxHelper.Instance.FlagAction(listFlagAction);
            var hash              = "property";
            int currentFlagAction = FlagAction.IndextFlagAction(listFlagAction, property.ActionUsing);
            if (currentFlagAction == -1)
            {
                if (property.ActionUsing != null && property.ActionUsing != "")
                {
                    combobox.Empty = property.ActionUsing + " (not found)";
                }
                else
                {
                    combobox.Empty = "NULL";
                }
            }
            combobox.SelectedItemIndex = currentFlagAction;
            combobox.Rect.x            = xGui;
            combobox.Rect.y            = yGui;
            combobox.Rect.width        = widthLeft;
            combobox.Rect.height       = 32f;
            float limitHeight = 32f * 6;
            combobox.Show(limitHeight, hash, (int nextAction) => {
                property.ActionUsing = listFlagAction[nextAction].Name;
            });
            if (combobox.IsDropDownWithHash(hash))
            {
                yGui += limitHeight;
                return(false);
            }
            yGui += 32f;
        }

        // property.Consume = GUI.Toggle(new Rect( rect.x, yGui + DefineAON.GUI_Y_Label, widthLeft, DefineAON.GUI_Height_Label ), property.Consume, "Consumable");
        // yGui += 32f;

        if (property.IsPet)
        {
            AONGUI.Label(new Rect(rect.x, yGui + DefineAON.GUI_Y_Label, 40, DefineAON.GUI_Height_Label), "Pet");
            AONGUI.TextField(new Rect(rect.x + 40, yGui + DefineAON.GUI_Y_TextField, widthLeft - 40, DefineAON.GUI_Height_TextField), property.RefSlug, (string text) => {
                property.RefSlug = text;
            });

            AONGUI.Button(new Rect(rect.x + widthLeft + 10, yGui + DefineAON.GUI_Y_TextField, 40, DefineAON.GUI_Height_TextField), "Pick", () => {
                InputFieldHelper.Instance.ShowPickModel((string topic, string pet) => {
                    Debug.Log(topic + "/" + pet);
                    property.RefSlug = topic + "/" + pet;
                    InputFieldHelper.Instance.HidePickModel();
                });
            });
            yGui += 32f;
        }

        if (property.IsItem || property.IsCertificates)
        {
            AONGUI.Label(new Rect(rect.x, yGui + DefineAON.GUI_Y_Label, 40, DefineAON.GUI_Height_Label), "Icon");
            AONGUI.TextField(new Rect(rect.x + 40, yGui + DefineAON.GUI_Y_TextField, widthLeft - 40, DefineAON.GUI_Height_TextField), property.RefIcon, (string text) => {
                property.RefIcon = text;
            });
            AONGUI.Button(new Rect(rect.x + widthLeft + 10, yGui + DefineAON.GUI_Y_TextField, 40, DefineAON.GUI_Height_TextField), "Pick", () => {
                InputFieldHelper.Instance.ShowPickIcon((string topic, string icon) => {
                    // Debug.Log(topic + "/" + icon);
                    property.RefIcon = topic + "/" + icon;
                    InputFieldHelper.Instance.HidePickIcon();
                });
            });
            yGui += 32f;
        }
        return(false);
    }