备份CatanBuilding瘦身独立工程
This commit is contained in:
93
Assets/Scripts/Aquarium/UI/AquariumUpdatePopupPanel.cs
Normal file
93
Assets/Scripts/Aquarium/UI/AquariumUpdatePopupPanel.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
using asap.core;
|
||||
using game;
|
||||
using GameCore;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class AquariumUpdatePopupPanel : MonoBehaviour
|
||||
{
|
||||
Transform map;
|
||||
RewardItemNew[] rewards;
|
||||
Button btn_sure;
|
||||
bool isShowBox;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
btn_sure = transform.Find("root/bg/btn_sure/btn_green").GetComponent<Button>();
|
||||
map = transform.Find("root/bg/rewards");
|
||||
rewards = map.GetComponentsInChildren<RewardItemNew>();
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
OpenBox();
|
||||
btn_sure.onClick.AddListener(OnBtnSure);
|
||||
}
|
||||
void OnBtnSure()
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.AquariumUpdatePopupPanel);
|
||||
}
|
||||
void OpenBox()
|
||||
{
|
||||
var _dataProvider = GContext.container.Resolve<FishingBoxDataProvier>();
|
||||
Dictionary<int, int> FishingBoxs = _dataProvider.Data.FishingBoxs;
|
||||
isShowBox = false;
|
||||
int index = 0;
|
||||
|
||||
foreach (var box in FishingBoxs)
|
||||
{
|
||||
var boxCount = box.Value;
|
||||
if (boxCount > 0)
|
||||
{
|
||||
int id = box.Key;
|
||||
|
||||
isShowBox = true;
|
||||
rewards[index].SetData(new ItemData(id, boxCount));
|
||||
}
|
||||
rewards[index].gameObject.SetActive(boxCount > 0);
|
||||
index++;
|
||||
if (index >= 5)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
map.gameObject.SetActive(isShowBox);
|
||||
}
|
||||
private void OnDisable()
|
||||
{
|
||||
if (isShowBox)
|
||||
{
|
||||
var _dataProvider = GContext.container.Resolve<FishingBoxDataProvier>();
|
||||
Dictionary<int, int> FishingBoxs = _dataProvider.Data.FishingBoxs;
|
||||
var FishingNewBoxs = _dataProvider.Data.FishingNewBoxs;
|
||||
int index = 0;
|
||||
|
||||
foreach (var box in FishingBoxs)
|
||||
{
|
||||
var boxCount = box.Value;
|
||||
if (boxCount > 0)
|
||||
{
|
||||
int id = box.Key;
|
||||
if (FishingNewBoxs.ContainsKey(id))
|
||||
{
|
||||
FishingNewBoxs[id] += boxCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
FishingNewBoxs.Add(id, boxCount);
|
||||
}
|
||||
}
|
||||
index++;
|
||||
if (index >= 5)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_dataProvider.Data.FishingBoxs.Clear();
|
||||
_dataProvider.Data.Save();
|
||||
GContext.Publish(new ShowData(null, RewardType.FishBoxOpen, 1));
|
||||
}
|
||||
GContext.Publish(new FaceUICloseEvent());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user