Пример #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;
 }
Пример #2
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;
    }
Пример #3
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;
    }