Exemplo n.º 1
0
 public void UnTryCostume(CharGame charGame)
 {
     if (m_itemTryOn == null)
     {
         return;
     }
     if (charGame == null)
     {
         charGame = AutoTileMap_Editor.Instance.Agent.GetComponentInChildren <CharGame>();
     }
     if (m_itemRawTry == null)
     {
         charGame.RemoveEquipment(m_itemTryOn);
     }
     else
     {
         PropertysGame.Instance.CheckItemBeforeEquip(charGame, m_itemRawTry.ItemType);
         string error = "";
         if (charGame.AddEquipment(m_itemRawTry, ref error) == false)
         {
             return;
         }
     }
     m_itemRawTry = null;
     m_itemTryOn  = null;
 }
Exemplo n.º 2
0
    //----------Outfits---------//
    public void ShowOutfits(GComponent lastPopup, CharGame charGame, SerializablePropertys propertys)
    {
        ItemChar itemChar = charGame.DataChar;

        var pm_choise = new QuickControlList();

        for (int i = 0; i < itemChar.ItemByType.Length; i++)
        {
            ItemChar.Items items = itemChar.ItemByType[i];
            if (items.ItemList != null && items.ItemList.Length > 0)
            {
                Item.EItemType eItemType = (Item.EItemType)i;
                pm_choise.AddBt(Item.StrEItemType[i], (EventContext context) =>
                {
                    this._showOutfits2(charGame, pm_choise.contentPane, eItemType, items, propertys);
                });
            }
        }
        pm_choise.AddBt("Cancel", (EventContext context) =>
        {
            pm_choise.Dispose();
        });
        pm_choise.SetParent(InputFieldHelper.Instance.PopUp);
        lastPopup.visible = false;
        pm_choise.SetOnDispose(() =>
        {
            lastPopup.visible = true;
        });
    }
Exemplo n.º 3
0
    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;
            });
        }
    }
Exemplo n.º 4
0
 public void CheckItemBeforeEquip(CharGame charGame, Item.EItemType itemType)
 {
     if (itemType == Item.EItemType.hair)
     {
         UnEquip(charGame, Item.EItemType.accessories);
     }
     else if (itemType == Item.EItemType.accessories)
     {
         UnEquip(charGame, Item.EItemType.hair);
     }
 }
Exemplo n.º 5
0
    /*
     *  public void OnGUI() {
     *          if(!m_show)
     *                  return;
     *          var lastSkin = GUI.skin;
     *          GUI.skin = GUISkinGrid;
     *          OnGUIIn();
     *          GUI.skin = lastSkin;
     *  }
     *
     *  public void OnGUIIn() {
     *          float offsetBoxOut = 8;
     *          float w = 500;
     *          float h = 300;
     *          Rect rect = new Rect((Screen.width - w) - 20, (Screen.height - h) - 20, w , h);
     *          {
     *                  Rect rectBox = new Rect(rect.x - offsetBoxOut, rect.y - offsetBoxOut, rect.width + offsetBoxOut * 2, rect.height + offsetBoxOut * 2);
     *                  GUI.Box( rectBox, "", GUISkinGrid.box);
     *                  GameGui.IgnoreMouseByBox( rectBox);
     *          }
     *          GUI.Label( new Rect(rect.x + 6, rect.y + 6, 60, DefineAON.GAME_Height_Label),"Shop", GUISkinGrid.label);
     *          if(GUI.Button(new Rect(rect.x + rect.width - 76, rect.y + 4, 60, DefineAON.GAME_Height_Label),"Close", GUISkinGrid.button)){
     *                  UnTryCostume(null);
     *                  m_show = false;
     *                  if(mOnCloseShop != null){
     *                          var callback = mOnCloseShop;
     *                          mOnCloseShop = null;
     *                          callback();
     *                  }
     *                  return;
     *          }
     *          float offsetBoxIn = 4;
     *          float top = 44;
     *          float bot = 110;
     *          float offset_x_list = 10;
     *          var rectView = new Rect(rect.x + offset_x_list + offsetBoxIn, rect.y + top + offsetBoxIn, rect.width - offset_x_list - offset_x_list - offsetBoxIn * 2, rect.height - top - bot - offsetBoxIn * 2);
     *          OnGUIItems(rectView);
     *          if(m_indextItemSeleted >= 0 && m_indextItemSeleted < m_package.propertys.Count){
     *                  OnGUIItemInfo(new Rect(rect.x + offset_x_list + offsetBoxIn, rect.y + rect.height - bot + 20, rect.width - offset_x_list - offset_x_list - offsetBoxIn * 2, bot - 20));
     *          }
     *  }
     *
     *  private void OnGUIItems( Rect rectView){
     *          GUI.Box(rectView, "", GUISkinGrid.box);
     *          if(m_GUI_Items_Left.Length == 0){
     *                  // var listStyleLabel = GUI.skin.label;
     *                  // float h_title = listStyleLabel.CalcHeight( g, widthContent) + 8 + 8;
     *                  GUI.Label(rectView, new GUIContent("Empty"), GUISkinGrid.label);
     *          }else
     *          {
     *                  if(m_indextItemSeleted >= m_GUI_Items_Left.Length){
     *                          m_indextItemSeleted = m_GUI_Items_Left.Length - 1;
     *                  }
     *                  var rectContent = new Rect(rectView.x, rectView.y, rectView.width - 16, m_GUI_Items_Left.Length * 32f);
     *                  m_scrollPos = GUI.BeginScrollView(rectView, m_scrollPos, rectContent, false, false);
     *                  var indextItemNext = GUI.SelectionGrid( new Rect(rectContent.x + 14, rectContent.y, rectContent.width - 14, rectContent.height), m_indextItemSeleted, m_GUI_Items_Left, 1, GUISkinGrid.label);
     *                  if(indextItemNext != m_indextItemSeleted){
     *                          m_indextItemSeleted = indextItemNext;
     *                  }
     *                  GUI.DrawTexture( new Rect(rectView.x, rectView.y + m_indextItemSeleted * 32f + 5, 12, 20), TexSelected);
     *                  var StyleRightText = GUISkinGrid.customStyles[6];
     *                  GUI.SelectionGrid( new Rect(rectContent.x + 14, rectContent.y, rectContent.width - 14, rectContent.height), m_indextItemSeleted, m_GUI_Items_Right, 1, StyleRightText);
     *                  GUI.EndScrollView();
     *          }
     *  }
     *
     *  private void OnGUIItemInfo( Rect rect){
     *          GUI.Box( rect, "", GUISkinGrid.box);
     *          var slug = m_package.propertys[m_indextItemSeleted];
     *          var payBy = m_package.payBys[m_indextItemSeleted];
     *          var propertyData = m_dataRaw.PropertyBySlug(slug);
     *          float yGui = rect.y;
     *          if(propertyData == null){
     *                  GUI.Label(new Rect(rect.x + 8, yGui, rect.width - 8, 32), "Item not found in database", GUISkinGrid.label);
     *                  return;
     *          }
     *          // GUI.Label(new Rect(rect.x + 8, yGui, rect.width - 8, 32), propertyData.Name, GUISkinGrid.label);
     *          // yGui += 32f;
     *          if(!string.IsNullOrEmpty(propertyData.Des)){
     *                  GUI.Label(new Rect(rect.x + 8, yGui, rect.width - 8, 64), propertyData.Des, GUISkinGrid.label);
     *          }
     *          float wBtRight = 80;
     *          float yRightBt = rect.x + rect.width - 16 - wBtRight;
     *          yGui = rect.y + rect.height - 34;
     *          if(GUI.Button(new Rect(yRightBt, yGui, wBtRight, DefineAON.GAME_Height_Label), "Buy", GUISkinGrid.button)){
     *                  PropertysGame.Instance.AddItem( m_dataRaw, slug);
     *                  return;
     *          }
     *          OnGUIItemEquip( rect, propertyData);
     *  }
     *
     *  private void OnGUIItemEquip( Rect rect, SerializablePropertys.Property property){
     *          if(!property.CanEquip)
     *                  return;
     *          float yGui = rect.y + rect.height - 34;
     *          float xGui = rect.x + 8;
     *          float wBtRight = 80;
     *          float wLeft = rect.width - 16;
     *          float yRightBt = rect.x + rect.width - 16 - wBtRight;
     *          if(string.IsNullOrEmpty(property.ItemEquip)){
     *                  GUI.Label(new Rect(xGui, yGui, wLeft, DefineAON.GAME_Height_Label), "Item Equip empty", GUISkinGrid.label);
     *                  return;
     *          }
     *          var item = AutoTileMap_Editor.Instance.ItemCharData.FetchItemByGlobalSlug(property.ItemEquip);
     *          if(item == null){
     *                  GUI.Label(new Rect(xGui, yGui, wLeft, DefineAON.GAME_Height_Label), "Item Equip not found in database", GUISkinGrid.label);
     *                  return;
     *          }
     *          var charGame = AutoTileMap_Editor.Instance.Agent.GetComponentInChildren<CharGame>();
     *          if(item.SlugChar != charGame.SlugChar){
     *                  GUI.Label(new Rect(xGui, yGui, wLeft, DefineAON.GAME_Height_Label), "Warning: Your character can't use this item.", GUISkinGrid.label);
     *                  return;
     *          }
     *          Item currentItem = charGame.GetCurrentItem(item.ItemType);
     *          if(currentItem != null && item.SlugGlobal == currentItem.SlugGlobal){
     *                  if(m_itemTryOn != null && currentItem.SlugGlobal == m_itemTryOn.SlugGlobal){
     *                          GUI.Label(new Rect(xGui, yGui, wLeft, DefineAON.GAME_Height_Label), "Costumes is trying", GUISkinGrid.label);
     *                          yGui -= 32f;
     *                          if(GUI.Button(new Rect(yRightBt, yGui, wBtRight, DefineAON.GAME_Height_Label), "UnTry")){
     *                                  UnTryCostume(charGame);
     *                                  return;
     *                          }
     *                  }else
     *                  {
     *                          GUI.Label(new Rect(xGui, yGui, wLeft, DefineAON.GAME_Height_Label), "Costumes are in use", GUISkinGrid.label);
     *                          return;
     *                  }
     *          }else
     *          {
     *                  yGui -= 32f;
     *                  if(GUI.Button(new Rect(yRightBt, yGui, wBtRight, DefineAON.GAME_Height_Label), "Try on")){
     *                          UnTryCostume(charGame);
     *                          TryCostume(charGame, currentItem, item);
     *                          return;
     *                  }
     *          }
     *  }
     *
     *  public void ShowWithDataOnGUi(SerializablePropertys dataRaw, SerializablePackages.Package package, OnCloseShop onCloseShop){
     *          m_show = true;
     *          mOnCloseShop = onCloseShop;
     *          m_dataRaw = dataRaw;
     *          m_package = package;
     *          m_indextItemSeleted = 0;
     *          var propertys = m_package.propertys;
     *          m_GUI_Items_Left = new GUIContent[propertys.Count];
     *          m_GUI_Items_Right = new GUIContent[propertys.Count];
     *          for( int i = 0; i < propertys.Count; i++){
     *                  var slug = propertys[i];
     *                  if(string.IsNullOrEmpty(slug)){
     *                          m_GUI_Items_Left[i] = new GUIContent("Item is empty");
     *                  }else
     *                  {
     *                          var propertyData = m_dataRaw.PropertyBySlug(slug);
     *                          if(propertyData == null){
     *                                  m_GUI_Items_Left[i] = new GUIContent("Item not found");
     *                          }else if(!string.IsNullOrEmpty(propertyData.Name)){
     *                                  m_GUI_Items_Left[i] = new GUIContent(propertyData.Name);
     *                          }else if(!string.IsNullOrEmpty(slug)){
     *                                  m_GUI_Items_Left[i] = new GUIContent(slug);
     *                          }else
     *                          {
     *                                  m_GUI_Items_Left[i] = new GUIContent("Name is NULL");
     *                          }
     *                  }
     *                  var payBy = m_package.payBys[i];
     *                  if(payBy == null){
     *                          m_GUI_Items_Right[i] = new GUIContent("NULL");
     *                  }else
     *                  {
     *                          m_GUI_Items_Right[i] = new GUIContent(payBy.coin.ToString() + " $");
     *                  }
     *          }
     *  }
     *
     */

    private void TryCostume(CharGame charGame, Item raw, Item next)
    {
        PropertysGame.Instance.CheckItemBeforeEquip(charGame, next.ItemType);
        string error = "";

        if (charGame.AddEquipment(next, ref error) == false)
        {
            return;
        }
        m_itemRawTry = raw;
        m_itemTryOn  = next;
    }
Exemplo n.º 6
0
    public void UnEquipAll()
    {
        CharGame charGame = AutoTileMap_Editor.Instance.Agent.GetComponentInChildren <CharGame>();

        foreach (var p in PropertysChar)
        {
            if (p.EquipSlot >= 0)
            {
                UnEquip(charGame, p);
            }
        }
        UnquipCurrentPet();
    }
 public void ShowBag()
 {
     if (pm_choise_bag != null)
     {
         ShowNoti("Bag was show");
         return;
     }
     if (_popUp != null)
     {
         for (int i = 0; i < _popUp.numChildren; i++)
         {
             if (_popUp.GetChildAt(i).visible)
             {
                 ShowNoti("Can't show Bag when Talking");
                 return;
             }
         }
     }
     HideMenu();
     // Show Bag
     pm_choise_bag = new QuickControlList();
     pm_choise_bag.AddBt("Outfits", (EventContext context) =>
     {
         // Debug.Log("Click Costume");
         CharGame c = AutoTileMap_Editor.Instance.Agent.GetComponentInChildren <CharGame>();
         PropertysGame.Instance.ShowOutfits(pm_choise_bag.contentPane, c, AutoTileMap_Editor.Instance.MapsData.Propertys);
     });
     pm_choise_bag.AddBt("Pets", (EventContext context) =>
     {
         PropertysGame.Instance.ShowPets(pm_choise_bag.contentPane, AutoTileMap_Editor.Instance.MapsData.Propertys);
     });
     pm_choise_bag.AddBt("Items", (EventContext context) =>
     {
         PropertysGame.Instance.ShowItems(pm_choise_bag.contentPane);
     });
     pm_choise_bag.AddBt("Certificates", (EventContext context) =>
     {
         PropertysGame.Instance.ShowCertificates(pm_choise_bag.contentPane, AutoTileMap_Editor.Instance.MapsData.Propertys);
     });
     pm_choise_bag.AddBt("Cancel", (EventContext context) =>
     {
         pm_choise_bag.Dispose();
         pm_choise_bag = null;
     });
     pm_choise_bag.SetParent(PopUp);
     pm_choise_bag.SetOnDispose(() =>
     {
         ShowMenu();
     });
 }
Exemplo n.º 8
0
    private void _showOutfits4(CharGame charGame, ItemChar.Items items, Item item, PropertyChar property)
    {
        var tryItem = AutoTileMap_Editor.Instance.ItemCharData.FetchItemByGlobalSlug(item.SlugGlobal);

        if (tryItem == null)
        {
            InputFieldHelper.Instance.ShowNoti("Item not found in database");
            return;
        }

        controlPropertys.ResetSelectItem();

        controlPropertys.LoadModelItem(tryItem.ItemPrefab);

        if (tryItem.SlugChar != charGame.SlugChar)
        {
            controlPropertys.SetItemDes("Your character can't use this item.");
            return;
        }

        if (property == null)
        {
            controlPropertys.SetItemName(item.Slug);
            controlPropertys.SetItemDes("You don't own this item.");
            return;
        }
        else
        {
            controlPropertys.SetItemName(property.NameUI);
        }
        if (property.EquipSlot == -1)
        {
            controlPropertys.AddAction("Equip", () =>
            {
                this.Equip(charGame, property);
                this._showOutfits4(charGame, items, item, property);
                this._refreshListOutfits(items);
            });
        }
        else
        {
            controlPropertys.SetItemDes("Item is equipped");
            controlPropertys.AddAction("Unequip", () =>
            {
                this.UnEquip(charGame, property);
                this._showOutfits4(charGame, items, item, property);
                this._refreshListOutfits(items);
            });
        }
    }
Exemplo n.º 9
0
    private void _showOutfits3(CharGame charGame, ItemChar.Items items, SerializablePropertys propertys)
    {
        var l = items.ItemList;

        for (int i = 0; i < l.Length; i++)
        {
            Item         item        = l[i];
            PropertyChar propertyOwn = GetOutfit(item);
            var          bt          = controlPropertys.AddItem(item.Slug, () =>
            {
                _showOutfits4(charGame, items, item, propertyOwn);
            });
            _setCellOutfits(i, propertyOwn);
        }
    }
Exemplo n.º 10
0
 private void _showOutfits2(CharGame charGame, GComponent lastPopup, Item.EItemType eItemType, ItemChar.Items items, SerializablePropertys propertys)
 {
     _controlPropertys_Init();
     lastPopup.visible = false;
     controlPropertys._btClose.onClick.Clear();
     controlPropertys._btClose.onClick.Add(() =>
     {
         _controlPropertys_Dispose();
         lastPopup.visible = true;
     });
     controlPropertys.SetTitle(Item.StrEItemType[(int)eItemType]);
     controlPropertys.ResetListItem();
     controlPropertys.ResetSelectItem();
     _showOutfits3(charGame, items, propertys);
     _refreshListOutfits(items);
     controlPropertys.ShowOn(InputFieldHelper.Instance.PopUp);
 }
Exemplo n.º 11
0
    public bool UnEquip(CharGame charGame, Item.EItemType t)
    {
        int slot = (int)t;

        for (int i = 0; i < PropertysChar.Count; i++)
        {
            var pCheck = PropertysChar[i];
            if (pCheck.EquipSlot == slot)
            {
                if (UnEquip(charGame, pCheck) == false)
                {
                    InputFieldHelper.Instance.ShowNoti("Can't UnEquip which item same slot.");
                    return(true);
                }
            }
        }
        return(false);
    }
Exemplo n.º 12
0
    public void Equip(CharGame charGame, PropertyChar p)
    {
        if (!p.PropertyBase.IsOutfit)
        {
            InputFieldHelper.Instance.ShowNoti("ItemEquip it not the Outfit");
            return;
        }
        if (p.PropertyBase.RefSlug == null || p.PropertyBase.RefSlug == "")
        {
            InputFieldHelper.Instance.ShowNoti("ItemEquip empty");
            return;
        }
        var item = AutoTileMap_Editor.Instance.ItemCharData.FetchItemByGlobalSlug(p.PropertyBase.RefSlug);

        if (item == null)
        {
            InputFieldHelper.Instance.ShowNoti("ItemEquip not found");
            return;
        }
        if (charGame == null)
        {
            charGame = AutoTileMap_Editor.Instance.Agent.GetComponentInChildren <CharGame>();
        }
        if (charGame.SlugChar != item.SlugChar)
        {
            InputFieldHelper.Instance.ShowNoti("Your character can't use this item.");
            return;
        }
        ShopGame.Instance.UnTryCostume(charGame);
        UnEquip(charGame, item.ItemType);
        CheckItemBeforeEquip(charGame, item.ItemType);
        string error = "";

        if (charGame.AddEquipment(item, ref error) == false)
        {
            // m_tip = error;
            return;
        }
        p.EquipSlot            = (int)item.ItemType;
        ShouldUpdateGUIContent = true;
    }
Exemplo n.º 13
0
    public bool UnEquip(CharGame charGame, PropertyChar p)
    {
        if (p.PropertyBase.RefSlug == null || p.PropertyBase.RefSlug == "")
        {
            InputFieldHelper.Instance.ShowNoti("ItemEquip empty");
            return(false);
        }
        var item = AutoTileMap_Editor.Instance.ItemCharData.FetchItemByGlobalSlug(p.PropertyBase.RefSlug);

        if (item == null)
        {
            InputFieldHelper.Instance.ShowNoti("ItemEquip not found");
            return(false);
        }
        if (charGame == null)
        {
            charGame = AutoTileMap_Editor.Instance.Agent.GetComponentInChildren <CharGame>();
        }
        ShopGame.Instance.UnTryCostume(charGame);
        charGame.RemoveEquipment(item);
        p.EquipSlot            = -1;
        ShouldUpdateGUIContent = true;
        return(true);
    }