//-------------------------------------------------------- // [Author]: 第二世界 // [ Date ]: Monday, March 04, 2019 //-------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; //成交记录 namespace Snxxz.UI { public class TransactionRecordWin : Window { [SerializeField] ScrollerController m_ScrollerController; [SerializeField] ScrollerController m_ScrollerControllerType; [SerializeField] Button m_ClosButton; [SerializeField] GameObject m_TypeTip; [SerializeField] Text m_TypeText; [SerializeField] Button m_TypeButon; [SerializeField] GameObject m_TextObj; AuctionInquiryModel model { get { return ModelCenter.Instance.GetModel(); } } AuctionHelpModel auctionHelpModel { get { return ModelCenter.Instance.GetModel(); } } private List AuctionRecordList = new List(); ItemTipsModel itemTipsModel { get { return ModelCenter.Instance.GetModel(); } } int AuctionType = 0; int MaxCount = 0; #region Built-in protected override void BindController() { m_ScrollerController.OnRefreshCell += OnRefreshGridCell; m_ScrollerControllerType.OnRefreshCell += OnRefreshGridCellType; m_ScrollerController.lockType = EnhanceLockType.KeepVertical; var count = FuncConfigConfig.Get("AuctionHouse").Numerical3; MaxCount = int.Parse(count); } protected override void AddListeners() { m_ClosButton.AddListener(() => { CloseImmediately(); }); m_TypeButon.AddListener(() => { if (!m_TypeTip.activeSelf) { m_TypeTip.SetActive(true); } }); } protected override void OnPreOpen() { AuctionType = 0; AuctionInquiry.Instance.SendQueryAuctionRecord(AuctionType);//查询拍卖记录 if (m_TypeTip.activeSelf) { m_TypeTip.SetActive(false); } m_TypeText.text = GetTextName(AuctionType); OnCreateGridTypeCell(m_ScrollerControllerType); OnCreateGridCell(m_ScrollerController); } protected override void OnAfterOpen() { model.PlayerAuctionRecordUpdate += PlayerAuctionRecordUpdate; } protected override void OnPreClose() { model.PlayerAuctionRecordUpdate -= PlayerAuctionRecordUpdate; } protected override void OnAfterClose() { } #endregion private void PlayerAuctionRecordUpdate() { OnCreateGridCell(m_ScrollerController); } private void OnCreateGridCell(ScrollerController gridCtrl) { GetAuctionRecordList(); if (AuctionRecordList.Count > 0) { m_TextObj.SetActive(false); } else { m_TextObj.SetActive(true); } gridCtrl.Refresh(); for (int i = 0; i < AuctionRecordList.Count; i++) { if (i < MaxCount) { gridCtrl.AddCell(ScrollerDataType.Header, i); } } gridCtrl.Restart(); } private void OnRefreshGridCell(ScrollerDataType type, CellView cell) { int index = cell.index; var auctionRecord = AuctionRecordList[index]; var itemConfig = ItemConfig.Get(auctionRecord.ItemID); if (itemConfig == null) { DebugEx.LogError("物品表没有找到该物品,物品ID为" + auctionRecord.ItemID); return; } ItemCell itemCell = cell.transform.Find("ItemCell1").GetComponent(); Text textName = cell.transform.Find("ItemName").GetComponent(); RichText transactionStatusText = cell.transform.Find("TransactionStatusText").GetComponent(); Text timeText = cell.transform.Find("TimeText").GetComponent(); ItemCellModel cellModel = new ItemCellModel(itemConfig.ID, true, (ulong)1); GameObject SuccessfulBiddingObj = cell.transform.Find("SuccessfulBiddingObj").gameObject;//竞拍成功(竞拍成功) TextEx SuccessfulBiddingText = cell.transform.Find("SuccessfulBiddingObj/SuccessfulBiddingText").GetComponent(); Text JadeMoney = cell.transform.Find("SuccessfulBiddingObj/JadeMoney").GetComponent(); GameObject AuctionFailedObj = cell.transform.Find("AuctionFailedObj").gameObject;//竞拍失败 Text JadeMoney_1 = cell.transform.Find("AuctionFailedObj/JadeMoney").GetComponent(); switch (auctionRecord.RecordResult) { case 0://流拍 transactionStatusText.gameObject.SetActive(true); SuccessfulBiddingObj.SetActive(false); AuctionFailedObj.SetActive(false); if (AuctionType == 0) { transactionStatusText.text = Language.Get("PMH_11"); } else if (AuctionType == 1) { transactionStatusText.text = Language.Get("PMH_12"); } break; case 1://拍卖成交(竞拍成功) SuccessfulBiddingObj.SetActive(true); transactionStatusText.gameObject.SetActive(false); AuctionFailedObj.SetActive(false); var name = UIHelper.ServerStringTrim(auctionRecord.BidderName); SuccessfulBiddingText.text = Language.Get("PMH_15", name); JadeMoney.text = auctionRecord.BidderPrice.ToString(); break; case 2://回收 transactionStatusText.gameObject.SetActive(true); SuccessfulBiddingObj.SetActive(false); AuctionFailedObj.SetActive(false); transactionStatusText.text = Language.Get("PMH_14"); break; case 3://竞价成功 SuccessfulBiddingObj.SetActive(true); transactionStatusText.gameObject.SetActive(false); AuctionFailedObj.SetActive(false); string strName = string.Empty; SuccessfulBiddingText.text = Language.Get("PMH_13"); JadeMoney.text = auctionRecord.BidderPrice.ToString(); break; case 4://竞价失败 AuctionFailedObj.SetActive(true); SuccessfulBiddingObj.SetActive(false); transactionStatusText.gameObject.SetActive(false); JadeMoney_1.text = auctionRecord.BidderPrice.ToString(); break; } itemCell.Init(cellModel); itemCell.button.SetListener(() => { ItemAttrData attrData = new ItemAttrData(itemConfig.ID, true, (ulong)1); itemTipsModel.SetItemTipsModel(attrData); }); textName.text = itemConfig.ItemName; timeText.text = auctionRecord.TimeStr; } private void OnCreateGridTypeCell(ScrollerController gridCtrl) { gridCtrl.Refresh(); for (int i = 0; i < 3; i++) { gridCtrl.AddCell(ScrollerDataType.Header, i); } gridCtrl.Restart(); } private void OnRefreshGridCellType(ScrollerDataType type, CellView cell) { int idnex = cell.index; Text textName = cell.transform.Find("Text").GetComponent(); Button button = cell.GetComponent