void OnChooseSelectFood()
    {
        if (RestaurantController.Instance() == null)
        {
            return;
        }
        if (curSelectFoodItem == null)
        {
            MessageBoxLogic.OpenOKBox(3049, 1000);
            return;
        }

        Tab_RestaurantFood curTabFood = TableManager.GetRestaurantFoodByID(curSelectFoodItem.FoodID, 0);

        if (null == curTabFood)
        {
            LogModule.ErrorLog("cur food id is not defined in table");
            return;
        }

        if (curTabFood.OpenLevel > RestaurantController.Instance().CurRestaurant().m_RestaurantLevel)
        {
            // 此菜品将在等级{0}开启
            MessageBoxLogic.OpenOKBox(StrDictionary.GetClientDictionaryString("#{1989}", curTabFood.OpenLevel));
            return;
        }
        RestaurantController.Instance().OnChooseFoodFinish(curSelectFoodItem.FoodID);
        curSelectFoodItem = null;
    }
    public void OnItemClick()
    {
        Tab_RestaurantFood curFood = TableManager.GetRestaurantFoodByID(m_foodID, 0);

        if (null == curFood)
        {
            LogModule.ErrorLog("OnItemClick::curTabData is null");
            return;
        }
        if (null == RestaurantData.m_PlayerRestaurantInfo)
        {
            LogModule.ErrorLog("OnItemClick::RestaurantData.m_PlayerRestaurantInfo is null");
            return;
        }
        if (null == m_parentWindow)
        {
            LogModule.ErrorLog("OnItemClick::m_parentWindow is null");
            return;
        }
        if (curFood.OpenLevel > RestaurantData.m_PlayerRestaurantInfo.m_RestaurantLevel)
        {
            return;
        }
        m_parentWindow.OnFoodItemClick(this);
        if (RestaurantController.Instance().NewPlayerGuide_Step == 1 && m_foodID == 0)
        {
            RestaurantController.Instance().NewPlayerGuide(2);
        }
    }
    // 全部上菜完成
    void OnFinishServingAllClick()
    {
        if (!m_bSelfData)
        {
            GUIData.AddNotifyData("#{2017}");
            return;
        }
        if (null == m_curRestaurant)
        {
            return;
        }
        // 超出当日完成次数上限
        int nTodayFinishNum = GameManager.gameManager.PlayerDataPool.CommonData.GetCommonData((int)Games.UserCommonData.USER_COMMONDATA.CD_RESTAURANT_FINISHFOOD_NUM);

        if (nTodayFinishNum >= RestaurantData.FinishFoodMax)
        {
            MessageBoxLogic.OpenOKBox(1563, 1000);
            return;
        }
        bool bHavePreDesk = false;
        int  nCostYuanBao = 0;

        for (int i = 0; i < m_curRestaurant.m_Desks.Length; i++)
        {
            if (m_curRestaurant.m_Desks[i].m_DestState != RestaurantData.DeskState.PrepareFood)
            {
                continue;
            }
            int nFoodID = m_curRestaurant.m_Desks[i].m_FoodID;
            Tab_RestaurantFood curTableFood = TableManager.GetRestaurantFoodByID(nFoodID, 0);
            if (null == curTableFood)
            {
                LogModule.ErrorLog("OnFinishServingAllClick:: curTableFood is null FoodID =" + nFoodID.ToString());
                continue;
            }
            bHavePreDesk = true;

            int nCurDestCostYuanBao = 0;
            int nLeftTenMinues      = m_curRestaurant.m_Desks[i].GetFoodLeftTime() / 600;
            if (m_curRestaurant.m_Desks[i].GetFoodLeftTime() % 600 != 0)
            {
                nLeftTenMinues = nLeftTenMinues + 1;
            }
            if (nLeftTenMinues <= 0)
            {
                nLeftTenMinues = 1;
            }
            nCurDestCostYuanBao = nLeftTenMinues * curTableFood.CostYuanBao;
            nCostYuanBao        = nCostYuanBao + nCurDestCostYuanBao;
        }
        if (false == bHavePreDesk)
        {
            MessageBoxLogic.OpenOKBox(2381, 1000);
            return;
        }
        MessageBoxLogic.OpenCostBox(GCGame.Utils.GetDicByID(11362), null, GCGame.Utils.GetDicByID(11361), GCGame.Utils.GetDicByID(11363),
                                    "qian3", "X" + nCostYuanBao, OnFinishServingAll);
    }
Beispiel #4
0
    void FinishPrepareDesk()
    {
        if (null == RestaurantController.Instance())
        {
            LogModule.ErrorLog("FinishPrepareDesk::RestaurantController.Instance() is null ");
            return;
        }
        if (!RestaurantController.Instance().SelfData)
        {
            GUIData.AddNotifyData("#{2017}");
            return;
        }
        if (null == m_curDestData)
        {
            LogModule.ErrorLog("FinishPrepareDesk:: m_curDestData is null");
            return;
        }
        int nTodayFinishNum = GameManager.gameManager.PlayerDataPool.CommonData.GetCommonData((int)Games.UserCommonData.USER_COMMONDATA.CD_RESTAURANT_FINISHFOOD_NUM);

        if (nTodayFinishNum >= RestaurantData.FinishFoodMax)
        {
            MessageBoxLogic.OpenOKBox(1563, 1000);
            return;
        }

        if (null == m_curDestData)
        {
            LogModule.ErrorLog("FinishPrepareDesk:: m_curDestData is null");
            return;
        }

        Tab_RestaurantFood curTableFood = TableManager.GetRestaurantFoodByID(m_curDestData.m_FoodID, 0);

        if (null == curTableFood)
        {
            LogModule.ErrorLog("FinishPrepareDesk:: curTableFood is null");
            return;
        }

        int nCostYuanBao   = 0;
        int nLeftTenMinues = m_curDestData.GetFoodLeftTime() / 600;

        if (m_curDestData.GetFoodLeftTime() % 600 != 0)
        {
            nLeftTenMinues = nLeftTenMinues + 1;
        }
        if (nLeftTenMinues <= 0)
        {
            nLeftTenMinues = 1;
        }
        nCostYuanBao = nLeftTenMinues * curTableFood.CostYuanBao;
        //string strTip = StrDictionary.GetClientDictionaryString("#{2339}", (int)nCostYuanBao);
        //string strTitle = StrDictionary.GetClientDictionaryString("#{1000}");
        //MessageBoxLogic.OpenOKCancelBox(strTip, strTitle, OnFinishPrepareDesk, null);
        MessageBoxLogic.OpenCostBox(Utils.GetDicByID(11362), null, Utils.GetDicByID(11361), Utils.GetDicByID(11363),
                                    "qian3", "X" + nCostYuanBao, OnFinishPrepareDesk);
    }
    void UpdateFood()
    {
        if (null == m_FoodListGrid)
        {
            LogModule.ErrorLog("m_FoodListGrid is null");
            return;
        }
        for (int i = 0; i < PageFoodMax && i < m_FoodItemWindow.Length; i++)
        {
            m_FoodItemWindow[i].Clear();
        }
        int nBeginIndex = m_nCurPage * PageFoodMax;

        for (int i = 0; i < PageFoodMax && i < m_FoodItemWindow.Length; i++)
        {
            int nIndex = nBeginIndex + i;
            if (nIndex < m_FoodList.Count)
            {
                Tab_RestaurantFood oFood = m_FoodList[nIndex];
                m_FoodItemWindow[i].SetData(this, oFood);
                m_FoodItemWindow[i].Index = i;
            }
        }
        m_FoodListGrid.Reposition();
        if (m_PageLable != null)
        {
            m_PageLable.text = (m_nCurPage + 1).ToString() + "/" + m_nMaxPageNum.ToString();
        }
        curSelectFoodItem = null;
        for (int i = 0; i < m_FoodItemSelectBG.Length; i++)
        {
            m_FoodItemSelectBG[i].SetActive(false);
        }
        for (int i = 0; i < m_FoodItemBG.Length; i++)
        {
            m_FoodItemBG[i].SetActive(true);
        }
        for (int i = 0; i < m_FoodItemWindow.Length && i < m_FoodList.Count; i++)
        {
            Tab_RestaurantFood oFood = m_FoodList[i];
            if (oFood != null && RestaurantData.m_PlayerRestaurantInfo != null)
            {
                if (oFood.OpenLevel <= RestaurantData.m_PlayerRestaurantInfo.m_RestaurantLevel)
                {
                    m_FoodItemWindow[i].OnItemClick();
                    break;
                }
            }
        }
    }
 public void RefreshFoodItemInfo()
 {
     for (int i = 0; i < DragPageMaxNum; ++i)
     {
         int itemIndex = i + startIndex;
         if (itemIndex <= m_FoodList.Count)
         {
             NGUITools.SetActive(m_gridFoodItemList[i].gameObject, true);
             Tab_RestaurantFood oFood = m_FoodList[itemIndex - 1];
             m_gridFoodItemList[i].SetData(this, oFood);
             m_gridFoodItemList[i].Index = i;
         }
         else
         {
             // NGUITools.SetActive(m_gridFoodItemList[i].gameObject, false);
         }
     }
     //m_FoodListGrid.Reposition();
 }
    public void SetData(RestaurantFoodWindow parent, Tab_RestaurantFood curTabData)
    {
        if (null == curTabData)
        {
            LogModule.ErrorLog("SetData::curTabData is null");
            return;
        }
        if (null == RestaurantData.m_PlayerRestaurantInfo)
        {
            LogModule.ErrorLog("SetData::curTabData is null");
            return;
        }
        if (curTabData.OpenLevel > RestaurantData.m_PlayerRestaurantInfo.m_RestaurantLevel)
        {
            if (null != m_BGSprite)
            {
                //m_BGSprite.SetActive(false);
            }
            if (null != m_GrayBGSprite)
            {
                //m_GrayBGSprite.SetActive(true);
                m_GrayBGSprite.SetActive(false);
            }

            /*
             *          if (m_LabelName != null)
             * {
             *  m_LabelName.color = m_GrayColor;
             * }
             * if (m_LabelDuraionTitle != null)
             * {
             *  m_LabelDuraionTitle.color = m_GrayColor;
             * }
             * if (m_LabelFoodLevelTitle != null)
             * {
             *  m_LabelFoodLevelTitle.color = m_GrayColor;
             * }
             * if (m_LabelDuraion != null)
             * {
             *  m_LabelDuraion.color = m_GrayColor;
             * }
             * if (m_LabelFoodLevel != null)
             * {
             *  m_LabelFoodLevel.color = m_GrayColor;
             *  //m_LabelFoodLevel.effectStyle = UILabel.Effect.None;
             * }
             *
             * if (m_LabelRrewardCoinTitle != null)
             * {
             *  m_LabelRrewardCoinTitle.color = m_GrayRewardColor;
             * }
             * if (m_LabelRrewardPlayerExpTitle != null)
             * {
             *  m_LabelRrewardPlayerExpTitle.color = m_GrayRewardColor;
             * }
             * if (m_LabelRrewardRestaurantExpTitle != null)
             * {
             *  m_LabelRrewardRestaurantExpTitle.color = m_GrayRewardColor;
             * }
             * if (m_LabelRrewardCoin != null)
             * {
             *  m_LabelRrewardCoin.color = m_GrayRewardColor;
             * }
             * if (m_LabelRrewardPlayerExp != null)
             * {
             *  m_LabelRrewardPlayerExp.color = m_GrayRewardColor;
             * }
             * if (m_LabelRrewardRestaurantExp)
             * {
             *  m_LabelRrewardRestaurantExp.color = m_GrayRewardColor;
             * }
             */
            if (m_MakeBtn != null)
            {
                // m_MakeBtn.SetActive(false);
                m_MakeBtn.GetComponent <UIImageButton>().isEnabled = false;
            }
        }
        else
        {
            if (null != m_BGSprite)
            {
                m_BGSprite.SetActive(true);
            }
            if (null != m_GrayBGSprite)
            {
                m_GrayBGSprite.SetActive(false);
            }

/*
 *          if (m_LabelName != null)
 *          {
 *              m_LabelName.color = m_NormalColor;
 *          }
 *          if (m_LabelDuraionTitle != null)
 *          {
 *              m_LabelDuraionTitle.color = m_NormalColor;
 *          }
 *          if (m_LabelFoodLevelTitle != null)
 *          {
 *              m_LabelFoodLevelTitle.color = m_NormalColor;
 *          }
 *
 *          if (m_LabelDuraion != null)
 *          {
 *              m_LabelDuraion.color = m_NormalColor;
 *          }
 *          if (m_LabelFoodLevel != null)
 *          {
 *              m_LabelFoodLevel.color = m_NormalColor;
 *              //m_LabelFoodLevel.effectStyle = UILabel.Effect.Shadow;
 *          }
 *
 *          if (m_LabelRrewardCoinTitle != null)
 *          {
 *              m_LabelRrewardCoinTitle.color = m_NormalRewardTitleColor;
 *          }
 *          if (m_LabelRrewardPlayerExpTitle != null)
 *          {
 *              m_LabelRrewardPlayerExpTitle.color = m_NormalRewardTitleColor;
 *          }
 *          if (m_LabelRrewardRestaurantExpTitle != null)
 *          {
 *              m_LabelRrewardRestaurantExpTitle.color = m_NormalRewardTitleColor;
 *          }
 *
 *          if (m_LabelRrewardCoin != null)
 *          {
 *              m_LabelRrewardCoin.color = m_NormalRewardColor;
 *          }
 *          if (m_LabelRrewardPlayerExp != null)
 *          {
 *              m_LabelRrewardPlayerExp.color = m_NormalRewardColor;
 *          }
 *          if (m_LabelRrewardRestaurantExp)
 *          {
 *              m_LabelRrewardRestaurantExp.color = m_NormalRewardColor;
 *          }
 */
            if (m_MakeBtn != null)
            {
                //m_MakeBtn.SetActive(true);
                m_MakeBtn.GetComponent <UIImageButton>().isEnabled = true;
            }
        }

        m_parentWindow = parent;
        //m_curTabData = curTabData;
        m_foodID         = curTabData.Id;
        m_LabelName.text = curTabData.Name;
        int nDurationSeconds      = curTabData.CookDuration;
        int nDurationTotalMinutes = nDurationSeconds / 60;
        int nDurationMinutes      = nDurationTotalMinutes % 60;
        int nDurationHours        = (nDurationTotalMinutes / 60) % 24;
        int nDurationDays         = nDurationTotalMinutes / 1440;

        string strDay      = StrDictionary.GetClientDictionaryString("#{2446}", nDurationDays);
        string strMinutes  = StrDictionary.GetClientDictionaryString("#{2448}", nDurationMinutes);
        string strHours    = StrDictionary.GetClientDictionaryString("#{2447}", nDurationHours);
        string strDuration = "";

        if (nDurationDays > 0)
        {
            strDuration += strDay;
        }
        if (nDurationHours > 0)
        {
            strDuration += strHours;
        }
        if (nDurationMinutes > 0)
        {
            strDuration += strMinutes;
        }
        m_LabelDuraion.text = strDuration;
        m_LabelRrewardRestaurantExp.text = curTabData.RestaurantExp.ToString();


        m_LabelRrewardCoin.gameObject.SetActive(false);
        m_LabelRrewardCoinTitle.gameObject.SetActive(false);
        m_LabelRrewardPlayerExp.gameObject.SetActive(false);
        m_LabelRrewardPlayerExpTitle.gameObject.SetActive(false);
        m_RrewardCoinGameobject.SetActive(false);
        m_RrewardPlayerExpGameobject.SetActive(false);

        if (curTabData.Money > 0)
        {
            m_LabelRrewardCoin.text = curTabData.Money.ToString();
            m_LabelRrewardCoin.gameObject.SetActive(true);
            m_LabelRrewardCoinTitle.gameObject.SetActive(true);
            m_RrewardCoinGameobject.SetActive(true);
        }

        if (curTabData.PlayerExp > 0)
        {
            m_LabelRrewardPlayerExp.text = curTabData.PlayerExp.ToString();
            m_LabelRrewardPlayerExp.gameObject.SetActive(true);
            m_LabelRrewardPlayerExpTitle.gameObject.SetActive(true);
            m_RrewardPlayerExpGameobject.SetActive(true);
        }

        for (int i = 0; i < m_ItemSlotLogic.Length; i++)
        {
            m_ItemSlotLogic[i].ClearInfo();
        }
        //m_FoodRewardItemTitle.SetActive(false);
        int nSlotIndex = 0;

        for (int i = 0; i < curTabData.getRewardItemIDCount() && i < m_ItemSlotLogic.Length; i++)
        {
            int nItemID    = curTabData.GetRewardItemIDbyIndex(i);
            int nItemCount = curTabData.GetRewardItemNumbyIndex(i);
            if (nItemCount <= 0)
            {
                //m_FoodRewardItemTitle.SetActive(false);
                m_ItemSlotLogic[i].gameObject.SetActive(false);
                continue;
            }
            Tab_CommonItem RewardItem = TableManager.GetCommonItemByID(nItemID, 0);
            if (null == RewardItem)
            {
                //m_FoodRewardItemTitle.SetActive(false);
                m_ItemSlotLogic[i].gameObject.SetActive(false);
                continue;
            }
            //m_FoodRewardItemTitle.SetActive(true);
            if (nSlotIndex < m_ItemSlotLogic.Length)
            {
                m_ItemSlotLogic[i].gameObject.SetActive(true);
                m_ItemSlotLogic[nSlotIndex].InitInfo(ItemSlotLogic.SLOT_TYPE.TYPE_RESTAURANT, nItemID, OnClickRewardItem, nItemCount.ToString(), true);
            }
            nSlotIndex++;
            //if (i < m_RewardItemIcon.Length && i < m_RewardItemFrameIcon.Length )
            //{
            //    int nItemID = curTabData.GetRewardItemIDbyIndex(i);
            //    Tab_CommonItem RewardItem = TableManager.GetCommonItemByID(nItemID.ToString(), 0);
            //    if (RewardItem != null)
            //    {
            //        m_RewardItemIcon[i].SetActive(true);
            //        m_RewardItemFrameIcon[i].SetActive(true);
            //        m_RewardItemIcon[i].GetComponent<UISprite>().spriteName = RewardItem.Icon;
            //        m_FoodRewardItemTitle.SetActive(true);
            //    }
            //    else
            //    {
            //        m_RewardItemIcon[i].SetActive(false);
            //        m_RewardItemFrameIcon[i].SetActive(false);
            //        m_FoodRewardItemTitle.SetActive(false);
            //    }
            //}
        }
        //m_LabelFoodLevel.text = curTabData.OpenLevel.ToString() + "级";
        //m_LabelFoodLevel.text = StrDictionary.GetClientDictionaryString("#{2787}", curTabData.OpenLevel);
        this.transform.Find("JingTiTitle/ItemIcon").GetComponent <UISprite>().spriteName = curTabData.Icon;
        m_LabelFoodLevel.text = curTabData.OpenLevel.ToString();
    }