备份CatanBuilding瘦身独立工程
This commit is contained in:
111
Assets/Scripts/TravelMap/TraveMapDataManager.cs
Normal file
111
Assets/Scripts/TravelMap/TraveMapDataManager.cs
Normal file
@@ -0,0 +1,111 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class TraveMapDataManager
|
||||
{
|
||||
public List<TraveMapItemData> mapItemList = new List<TraveMapItemData>();
|
||||
public List<TraveMapItemData> mapShowItemData = new List<TraveMapItemData>();
|
||||
public int index = -1;
|
||||
public bool IsVisit { private set; get; } = false; //是否访问地图
|
||||
|
||||
public void Init(bool isVisit)
|
||||
{
|
||||
IsVisit = isVisit;
|
||||
Tables tables = GContext.container.Resolve<Tables>();
|
||||
int mapId = GContext.container.Resolve<CampDataMM>().Id;
|
||||
int maxID = mapId + 5;
|
||||
List<Construction> consDatas = tables.TbConstruction.DataList;
|
||||
List<MapData> mapDatas = tables.TbMapData.DataList;
|
||||
mapItemList.Clear();
|
||||
mapShowItemData.Clear();
|
||||
Construction cons = consDatas[0];
|
||||
MapData mapData= mapDatas[0];
|
||||
int count = 0;
|
||||
for (int i = 0; i < consDatas.Count; i++)
|
||||
{
|
||||
cons = consDatas[i];
|
||||
mapData = mapDatas[i];
|
||||
TraveMapItemData item = new TraveMapItemData();
|
||||
item.index = i;
|
||||
item.id = cons.ID;
|
||||
item.isVisit = IsVisit;
|
||||
item.icon = mapData.TravelMapIcon;
|
||||
item.name = $"{i + 1}.{LocalizationMgr.GetText(mapData.Name_l10n_key)}";
|
||||
if (mapId > cons.ID)
|
||||
{
|
||||
item.type = TraveMapType.unlocked;
|
||||
mapShowItemData.Add(item);
|
||||
}
|
||||
else if (mapId == cons.ID)
|
||||
{
|
||||
//CampData campData = GContext.container.Resolve<CampData>();
|
||||
//if (campData.IsCanSkyscraper)
|
||||
//{
|
||||
// item.type = TraveMapType.unlocked;
|
||||
// mapShowItemData.Add(item);
|
||||
//}
|
||||
//else
|
||||
{
|
||||
item.type = TraveMapType.current;
|
||||
}
|
||||
index = i;
|
||||
}
|
||||
else
|
||||
{
|
||||
item.type = TraveMapType.locked;
|
||||
}
|
||||
mapItemList.Add(item);
|
||||
count = i;
|
||||
if (maxID == cons.ID)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index == -1)
|
||||
{
|
||||
index = mapItemList.Count - 1;
|
||||
}
|
||||
bool isShowTips = true;
|
||||
if (cons.NextID == -1)
|
||||
{
|
||||
isShowTips = false;
|
||||
count++;
|
||||
TraveMapItemData item = new TraveMapItemData();
|
||||
item.index = count;
|
||||
item.icon = "";
|
||||
item.name = $"{count + 1}.{LocalizationMgr.GetText("UI_ToastPanel_24")}";
|
||||
item.type = TraveMapType.comingSoon;
|
||||
mapItemList.Add(item);
|
||||
}
|
||||
|
||||
//滑动框支持从下往上排列???
|
||||
mapItemList.Reverse();
|
||||
mapItemList[0].showTips = isShowTips;
|
||||
index = mapItemList.Count - 1 - index - 1;
|
||||
}
|
||||
|
||||
}
|
||||
public enum TraveMapType
|
||||
{
|
||||
//已解锁
|
||||
//当前
|
||||
//未解锁
|
||||
//敬请期待
|
||||
unlocked,
|
||||
current,
|
||||
locked,
|
||||
comingSoon,
|
||||
}
|
||||
public class TraveMapItemData
|
||||
{
|
||||
public int index;
|
||||
public int id;
|
||||
public string icon;
|
||||
public string name;
|
||||
public string description;
|
||||
public TraveMapType type;
|
||||
public bool showTips;
|
||||
public bool isVisit;
|
||||
}
|
||||
11
Assets/Scripts/TravelMap/TraveMapDataManager.cs.meta
Normal file
11
Assets/Scripts/TravelMap/TraveMapDataManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 354da10410343e14b96d298fedf9ff6d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
87
Assets/Scripts/TravelMap/TraveMapItem.cs
Normal file
87
Assets/Scripts/TravelMap/TraveMapItem.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
using asap.core;
|
||||
using EnhancedUI.EnhancedScroller;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class TraveMapItem : EnhancedScrollerCellView
|
||||
{
|
||||
public bool isRight;
|
||||
public Animation ani;
|
||||
public Image icon;
|
||||
public TMP_Text text_name;
|
||||
public Button btn_visit;
|
||||
public GameObject locked;
|
||||
public GameObject empty;
|
||||
public GameObject line;
|
||||
public GameObject bg_bra;
|
||||
public Image bar;
|
||||
public GameObject done;
|
||||
public GameObject ship;
|
||||
public TraveMapItemData data;
|
||||
public Action<TraveMapItemData> onClickAction;
|
||||
IUIService service;
|
||||
ShowImageData imageData = null;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
imageData = new ShowImageData(icon);
|
||||
service = GContext.container.Resolve<IUIService>();
|
||||
btn_visit.onClick.AddListener(OnClick);
|
||||
}
|
||||
private void OnClick()
|
||||
{
|
||||
onClickAction?.Invoke(data);
|
||||
}
|
||||
|
||||
public void PlayAni()
|
||||
{
|
||||
if (isRight)
|
||||
{
|
||||
ani.Play("ship_move");
|
||||
}
|
||||
else
|
||||
{
|
||||
ani.Play("ship_move_left");
|
||||
}
|
||||
}
|
||||
void SetIcon()
|
||||
{
|
||||
if (imageData == null)
|
||||
{
|
||||
imageData = new ShowImageData(icon);
|
||||
}
|
||||
imageData.SetName(data.icon);
|
||||
service.SetImageSprite(imageData);
|
||||
}
|
||||
public void SetData(TraveMapItemData _data)
|
||||
{
|
||||
data = _data;
|
||||
gameObject.SetActive(true);
|
||||
text_name.text = data.name;
|
||||
btn_visit.gameObject.SetActive(data.isVisit && data.type <= TraveMapType.current);
|
||||
SetIcon();
|
||||
if (data.index == 0)
|
||||
{
|
||||
locked.SetActive(false);
|
||||
empty.SetActive(false);
|
||||
line.SetActive(false);
|
||||
done.SetActive(false);
|
||||
ship.SetActive(false);
|
||||
bg_bra.SetActive(false);
|
||||
bar.fillAmount = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
locked.SetActive(data.type == TraveMapType.locked);
|
||||
empty.SetActive(data.type == TraveMapType.comingSoon);
|
||||
line.SetActive(data.type > TraveMapType.current);
|
||||
done.SetActive(data.type <= TraveMapType.current);
|
||||
ship.SetActive(data.type == TraveMapType.current);
|
||||
bg_bra.SetActive(true);
|
||||
bar.fillAmount = data.type <= TraveMapType.current ? 1 : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/TravelMap/TraveMapItem.cs.meta
Normal file
11
Assets/Scripts/TravelMap/TraveMapItem.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7f1024acd419a624daa8154358e4c238
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
95
Assets/Scripts/TravelMap/TraveMapScrollViewController.cs
Normal file
95
Assets/Scripts/TravelMap/TraveMapScrollViewController.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
using EnhancedUI.EnhancedScroller;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
public class TraveMapScrollViewController : EnhancedScroller, IEnhancedScrollerDelegate
|
||||
{
|
||||
TravelMapCtrl m_ctrl;
|
||||
EnhancedScroller m_Scroller;
|
||||
public TraveMapItem mapItemLeft;
|
||||
public TraveMapItem mapItemRight;
|
||||
List<TraveMapItemData> scrollerDataList = new List<TraveMapItemData>();
|
||||
int lastLeft = 0;
|
||||
|
||||
GameObject m_tips_noopen;
|
||||
public void Init(GameObject tips_noopen, EnhancedScroller scroller, TravelMapCtrl ctrl)
|
||||
{
|
||||
m_tips_noopen = tips_noopen;
|
||||
m_Scroller = scroller;
|
||||
m_ctrl = ctrl;
|
||||
scrollerDataList = m_ctrl.traveMapDataManager.mapItemList;
|
||||
//InitScrollerListData();
|
||||
lastLeft = scrollerDataList.Count % 2;
|
||||
m_Scroller.Delegate = this;
|
||||
m_Scroller.ReloadData();
|
||||
}
|
||||
public EnhancedScrollerCellView GetCellView(EnhancedScroller scroller, int dataIndex, int cellIndex)
|
||||
{
|
||||
TraveMapItem cellView;
|
||||
if (dataIndex % 2 == lastLeft)
|
||||
{
|
||||
cellView = scroller.GetCellView(mapItemLeft) as TraveMapItem;
|
||||
}
|
||||
else
|
||||
{
|
||||
cellView = scroller.GetCellView(mapItemRight) as TraveMapItem;
|
||||
}
|
||||
TraveMapItemData data = scrollerDataList[dataIndex];
|
||||
if (cellView.data != null && cellView.data.showTips)
|
||||
{
|
||||
//隐藏提示
|
||||
m_tips_noopen.SetActive(false);
|
||||
}
|
||||
if (data.showTips)
|
||||
{
|
||||
//显示提示
|
||||
m_tips_noopen.SetActive(true);
|
||||
}
|
||||
|
||||
cellView.SetData(data);
|
||||
cellView.onClickAction = OnClickMapItem;
|
||||
//cellView.gameObject.name = data.DataType + "-" + GetTypeDataIndex(data.DataType, dataIndex);
|
||||
return cellView;
|
||||
}
|
||||
|
||||
public float GetCellViewSize(EnhancedScroller scroller, int dataIndex)
|
||||
{
|
||||
return 541;
|
||||
}
|
||||
|
||||
public int GetNumberOfCells(EnhancedScroller scroller)
|
||||
{
|
||||
return scrollerDataList.Count;
|
||||
}
|
||||
|
||||
public void OnClickMapItem(TraveMapItemData data)
|
||||
{
|
||||
if (data.type == TraveMapType.current)
|
||||
{
|
||||
m_ctrl.InBuildAct();
|
||||
}
|
||||
else if (data.type == TraveMapType.unlocked)
|
||||
{
|
||||
m_ctrl.InVisit(data.index);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public TraveMapItem GetCurrentItem()
|
||||
{
|
||||
if (Container == null) return null;
|
||||
TraveMapItem[] items = Container.GetComponentsInChildren<TraveMapItem>();
|
||||
if (items == null || items.Length < 1) return null;
|
||||
|
||||
foreach (var item in items)
|
||||
{
|
||||
if (item.data.type == TraveMapType.current) return item;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f5909610f619b1b42897d958d965209d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
38
Assets/Scripts/TravelMap/TravelMapCampPhotoPanel.cs
Normal file
38
Assets/Scripts/TravelMap/TravelMapCampPhotoPanel.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using asap.core;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class TravelMapCampPhotoPanel : MonoBehaviour
|
||||
{
|
||||
Button btn_photo;
|
||||
UIDrag uiDrag;
|
||||
TravelMapPhotoPanel travelMapPhotoPanel;
|
||||
private void Awake()
|
||||
{
|
||||
btn_photo = transform.Find("root/btn_photo").GetComponent<Button>();
|
||||
uiDrag = transform.Find("root/drag").GetComponent<UIDrag>();
|
||||
travelMapPhotoPanel = transform.Find("TravelMapPhotoPanel").GetComponent<TravelMapPhotoPanel>();
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
btn_photo.onClick.AddListener(OnCaptureFishPhoto);
|
||||
uiDrag.OnBeginDragCall = () =>
|
||||
{
|
||||
|
||||
#if UNITY_EDITOR
|
||||
if (Input.GetMouseButton(0))
|
||||
#else
|
||||
if (Input.touchCount == 1)
|
||||
#endif
|
||||
{
|
||||
GContext.Publish(new SwitchVirtualCameraEvent() { type = 12, isDrag = true });
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void OnCaptureFishPhoto()
|
||||
{
|
||||
travelMapPhotoPanel.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Scripts/TravelMap/TravelMapCampPhotoPanel.cs.meta
Normal file
11
Assets/Scripts/TravelMap/TravelMapCampPhotoPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: faad672bdb603f04993141454e1c9632
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
63
Assets/Scripts/TravelMap/TravelMapCampReveiwPanel.cs
Normal file
63
Assets/Scripts/TravelMap/TravelMapCampReveiwPanel.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using asap.core;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class TravelMapCampReveiwPanel : MonoBehaviour
|
||||
{
|
||||
Button btn_close;
|
||||
Button btn_left;
|
||||
Button btn_right;
|
||||
UIDrag uiDrag;
|
||||
|
||||
TMP_Text text_name;
|
||||
TravelMapCtrl travelMapCtrl;
|
||||
private void Awake()
|
||||
{
|
||||
travelMapCtrl = GContext.container.Resolve<TravelMapCtrl>();
|
||||
uiDrag = transform.Find("root/drag").GetComponent<UIDrag>();
|
||||
btn_close = transform.Find("root/btn_close").GetComponent<Button>();
|
||||
btn_left = transform.Find("root/btn_left").GetComponent<Button>();
|
||||
btn_right = transform.Find("root/btn_right").GetComponent<Button>();
|
||||
text_name = transform.Find("root/title/text_title").GetComponent<TMP_Text>();
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
btn_close.onClick.AddListener(OnClose);
|
||||
btn_left.onClick.AddListener(OnLeft);
|
||||
btn_right.onClick.AddListener(OnRight);
|
||||
uiDrag.OnBeginDragCall = () =>
|
||||
{
|
||||
|
||||
#if UNITY_EDITOR
|
||||
if (Input.GetMouseButton(0))
|
||||
#else
|
||||
if (Input.touchCount == 1)
|
||||
#endif
|
||||
{
|
||||
GContext.Publish(new SwitchVirtualCameraEvent() { type = 12, isDrag = true });
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void OnLeft()
|
||||
{
|
||||
travelMapCtrl.OnLeft();
|
||||
}
|
||||
|
||||
private void OnRight()
|
||||
{
|
||||
travelMapCtrl.OnRight();
|
||||
|
||||
}
|
||||
|
||||
public void SetName(string name)
|
||||
{
|
||||
text_name.text = name;
|
||||
}
|
||||
private void OnClose()
|
||||
{
|
||||
|
||||
travelMapCtrl.OutVisit();
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/TravelMap/TravelMapCampReveiwPanel.cs.meta
Normal file
11
Assets/Scripts/TravelMap/TravelMapCampReveiwPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ed1f02bbe97c2ca41babe23600460122
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
148
Assets/Scripts/TravelMap/TravelMapCtrl.cs
Normal file
148
Assets/Scripts/TravelMap/TravelMapCtrl.cs
Normal file
@@ -0,0 +1,148 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using game;
|
||||
using Game;
|
||||
using GameCore;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
public class TravelMapCtrl
|
||||
{
|
||||
public TraveMapDataManager traveMapDataManager;
|
||||
Tables tables;
|
||||
GameObject _buildingObj;
|
||||
TravelMapCampReveiwPanel travelMapCampReveiw;
|
||||
int visitInidex = 0;
|
||||
TraveMapItemData traveMapItemData;
|
||||
public void Init(bool isVisit)
|
||||
{
|
||||
tables = GContext.container.Resolve<Tables>();
|
||||
traveMapDataManager = new TraveMapDataManager();
|
||||
traveMapDataManager.Init(isVisit);
|
||||
}
|
||||
|
||||
public async void InBuildAct()
|
||||
{
|
||||
ILoadResourceService loadResourceService = GContext.container.Resolve<ILoadResourceService>();
|
||||
CampDataMM campData = GContext.container.Resolve<CampDataMM>();
|
||||
bool isCanEnter = await loadResourceService.Loads(campData.AllPrefabs);
|
||||
if (isCanEnter)
|
||||
{
|
||||
InBuild();
|
||||
}
|
||||
else
|
||||
{
|
||||
var panel = await UIManager.Instance.ShowUI(UITypes.CloudTransitionPanel);
|
||||
panel.GetComponent<CloudTransitionPanel>().SetBtn(true, InBuild);
|
||||
}
|
||||
}
|
||||
|
||||
async void InBuild()
|
||||
{
|
||||
GContext.Publish(new UnloadActToNextAct("BuildAct"));
|
||||
await Awaiters.Seconds(0.5f);
|
||||
OnDestroy();
|
||||
}
|
||||
|
||||
public void OnLeft()
|
||||
{
|
||||
visitInidex--;
|
||||
InVisit(visitInidex);
|
||||
|
||||
}
|
||||
|
||||
public void OnRight()
|
||||
{
|
||||
visitInidex++;
|
||||
InVisit(visitInidex);
|
||||
}
|
||||
|
||||
public async Task InVisit(int index)
|
||||
{
|
||||
visitInidex = index;
|
||||
if (visitInidex < 0)
|
||||
{
|
||||
visitInidex = traveMapDataManager.mapShowItemData.Count - 1;
|
||||
}
|
||||
if (visitInidex >= traveMapDataManager.mapShowItemData.Count)
|
||||
{
|
||||
visitInidex = 0;
|
||||
}
|
||||
traveMapItemData = traveMapDataManager.mapShowItemData[visitInidex];
|
||||
ILoadResourceService loadResourceService = GContext.container.Resolve<ILoadResourceService>();
|
||||
Construction mapData = tables.TbConstruction.Get(traveMapItemData.id);
|
||||
string prefabName = mapData.Prefab;
|
||||
bool isCanEnter = await loadResourceService.Load(prefabName);
|
||||
if (isCanEnter)
|
||||
{
|
||||
await InVisit(mapData);
|
||||
}
|
||||
else
|
||||
{
|
||||
var panel = await UIManager.Instance.ShowUI(UITypes.CloudTransitionPanel);
|
||||
panel.GetComponent<CloudTransitionPanel>().SetBtn(true, async () => await InVisit(mapData));
|
||||
}
|
||||
}
|
||||
|
||||
async Task InVisit(Construction mapData)
|
||||
{
|
||||
await UIManager.Instance.ShowUI(UITypes.CloudTransitionPanel);
|
||||
await Awaiters.Seconds(0.5f);
|
||||
if (_buildingObj != null)
|
||||
{
|
||||
Addressables.ReleaseInstance(_buildingObj);
|
||||
_buildingObj = null;
|
||||
}
|
||||
_buildingObj = await Addressables.InstantiateAsync(mapData.Prefab).Task;
|
||||
GContext.Publish(new EventBGMSound(mapData.BGM));
|
||||
GContext.Publish(new EndTransition());
|
||||
if (_buildingObj == null)
|
||||
{
|
||||
Debug.LogError($"<color=red>TravelMapCtrl InVisit Error</color>");
|
||||
return;
|
||||
}
|
||||
|
||||
var buildComp = _buildingObj.GetComponentInChildren<Building>();
|
||||
if (buildComp != null)
|
||||
{
|
||||
buildComp.SetTimelineAllDone();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError($"<color=red>TravelMapCtrl InVisit Error</color>");
|
||||
}
|
||||
GContext.Publish(new SwitchVirtualCameraEvent() { type = 11, isDrag = true });
|
||||
if (travelMapCampReveiw == null)
|
||||
{
|
||||
GameObject go = await UIManager.Instance.ShowUI(UITypes.TravelMapCampReveiwPanel);
|
||||
travelMapCampReveiw = go.GetComponent<TravelMapCampReveiwPanel>();
|
||||
UIManager.Instance.DestroyUI(UITypes.TravelMapPanel);
|
||||
}
|
||||
travelMapCampReveiw.SetName(traveMapItemData.name);
|
||||
}
|
||||
public async void OutVisit()
|
||||
{
|
||||
visitInidex = 0;
|
||||
await UIManager.Instance.ShowUI(UITypes.TravelMapPanel);
|
||||
GContext.Publish(new EventMainBGM());
|
||||
UIManager.Instance.DestroyUI(UITypes.TravelMapCampReveiwPanel);
|
||||
travelMapCampReveiw = null;
|
||||
|
||||
if (_buildingObj != null)
|
||||
{
|
||||
Addressables.ReleaseInstance(_buildingObj);
|
||||
_buildingObj = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnDestroy()
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.TravelMapPanel);
|
||||
RestartShowHomeUIEvent restartShowHomeUIEvent = new RestartShowHomeUIEvent();
|
||||
GContext.Publish(restartShowHomeUIEvent);
|
||||
GContext.Publish(new MapShowEvent() { isShow = true });
|
||||
traveMapDataManager = null;
|
||||
GContext.container.Unregister<TravelMapCtrl>();
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/TravelMap/TravelMapCtrl.cs.meta
Normal file
11
Assets/Scripts/TravelMap/TravelMapCtrl.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 427b64b38b70eb34db967a389aa02827
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
72
Assets/Scripts/TravelMap/TravelMapPanel.cs
Normal file
72
Assets/Scripts/TravelMap/TravelMapPanel.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using asap.core;
|
||||
using game;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class TravelMapPanel : BasePanel
|
||||
{
|
||||
Button btn_close;
|
||||
GameObject tips_noopen;
|
||||
Transform item_wenli;
|
||||
TraveMapScrollViewController tvc;
|
||||
TraveMapDataManager mapDataManager;
|
||||
TravelMapCtrl travelMapCtrl;
|
||||
private void Awake()
|
||||
{
|
||||
Input.multiTouchEnabled = false;
|
||||
travelMapCtrl = GContext.container.Resolve<TravelMapCtrl>();
|
||||
mapDataManager = travelMapCtrl.traveMapDataManager;
|
||||
tips_noopen = transform.Find("root/tips_noopen").gameObject;
|
||||
tvc = transform.Find("root/ScrollView_map").GetComponent<TraveMapScrollViewController>();
|
||||
btn_close = transform.Find("root/btn_close").GetComponent<Button>();
|
||||
item_wenli = transform.Find("root/item_wenli");
|
||||
}
|
||||
protected override void Start()
|
||||
{
|
||||
tips_noopen.SetActive(false);
|
||||
tvc.Init(tips_noopen, tvc, travelMapCtrl);
|
||||
//tvc.cellViewVisibilityChanged = CellViewVisibilityChanged;
|
||||
//tvc.cellViewWillRecycle = CellViewWillRecycle;
|
||||
tvc.JumpToDataIndex(mapDataManager.index);
|
||||
GetOperationItem();
|
||||
//item_wenli.SetParent(tvc.Container, false);
|
||||
//item_wenli.GetComponent<RectTransform>().anchoredPosition = new Vector2(0, 0);
|
||||
//item_wenli.SetAsFirstSibling();
|
||||
btn_close.onClick.AddListener(OnClose);
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
if (tvc != null && item_wenli != null)
|
||||
{
|
||||
item_wenli.position = tvc.Container.position;
|
||||
}
|
||||
//UpdateActionChain();
|
||||
}
|
||||
public async void GetOperationItem()
|
||||
{
|
||||
if (mapDataManager.IsVisit)
|
||||
{
|
||||
//如果已经访问过了
|
||||
return;
|
||||
}
|
||||
if (tvc == null) return;
|
||||
TraveMapItem traveMapItem = tvc.GetCurrentItem();
|
||||
if (traveMapItem == null) return;
|
||||
traveMapItem.PlayAni();
|
||||
btn_close.gameObject.SetActive(false);
|
||||
await Awaiters.Seconds(3);
|
||||
GContext.Publish(new UnloadActToNextAct());
|
||||
await Awaiters.Seconds(0.5f);
|
||||
OnClose();
|
||||
}
|
||||
|
||||
private void OnClose()
|
||||
{
|
||||
//RestartShowHomeUIEvent restartShowHomeUIEvent = new RestartShowHomeUIEvent();
|
||||
//GContext.Publish(restartShowHomeUIEvent);
|
||||
//GContext.Publish(new MapShowEvent() { isShow = true });
|
||||
//关闭当前面板
|
||||
travelMapCtrl.OnDestroy();
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Scripts/TravelMap/TravelMapPanel.cs.meta
Normal file
11
Assets/Scripts/TravelMap/TravelMapPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b16ed476403fb3749982cdd8a77f899e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
214
Assets/Scripts/TravelMap/TravelMapPhotoPanel.cs
Normal file
214
Assets/Scripts/TravelMap/TravelMapPhotoPanel.cs
Normal file
@@ -0,0 +1,214 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using game;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityNative.Sharing;
|
||||
|
||||
public class TravelMapPhotoPanel : MonoBehaviour
|
||||
{
|
||||
Image icon_photo;
|
||||
TMP_Text text_map;
|
||||
Button btn_share;
|
||||
IUnityNativeSharing adapter;
|
||||
Button btn_next;
|
||||
Camera photo_camera;
|
||||
GameObject clickMask;
|
||||
CampDataMM campData;
|
||||
PlayerData playerData;
|
||||
Tables tables;
|
||||
byte[] bytes;
|
||||
string imageName;
|
||||
string savePath;
|
||||
private void Awake()
|
||||
{
|
||||
playerData = GContext.container.Resolve<PlayerData>();
|
||||
campData = GContext.container.Resolve<CampDataMM>();
|
||||
tables = GContext.container.Resolve<Tables>();
|
||||
|
||||
btn_share = transform.Find("root/btn_share/btn_green").GetComponent<Button>();
|
||||
btn_next = transform.Find("root/btn_next/btn_green").GetComponent<Button>();
|
||||
icon_photo = transform.Find("root/photo/icon_photo").GetComponent<Image>();
|
||||
photo_camera = transform.Find("photo_camera").GetComponent<Camera>();
|
||||
text_map = transform.Find("root/text_map").GetComponent<TMP_Text>();
|
||||
clickMask = transform.Find("root/clickMask").gameObject;
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
clickMask.SetActive(true);
|
||||
int PreID = campData.PreID;
|
||||
savePath = "";
|
||||
Construction data = tables.TbConstruction.DataMap[PreID];
|
||||
imageName = $"TravelMap.png";
|
||||
if (campData.SwitchBuildingData != null)
|
||||
{
|
||||
text_map.text = LocalizationMgr.GetText(campData.constructionArea.PhotoSwitch);
|
||||
}
|
||||
else
|
||||
{
|
||||
string mapname = LocalizationMgr.GetText(data.Name_l10n_key);
|
||||
text_map.text = $"{data.ID % 100}.{mapname}";
|
||||
}
|
||||
|
||||
btn_next.onClick.AddListener(OnNextClick);
|
||||
btn_share.onClick.AddListener(OnClickInviteLink);
|
||||
OnCaptureFishPhoto();
|
||||
}
|
||||
async void OnCaptureFishPhoto()
|
||||
{
|
||||
Rect rect = icon_photo.rectTransform.rect;
|
||||
var _rt = new RenderTexture((int)rect.width, (int)rect.height, 24);
|
||||
photo_camera.targetTexture = _rt;
|
||||
await Awaiters.NextFrame;
|
||||
photo_camera.transform.position = Camera.main.transform.position;
|
||||
photo_camera.transform.rotation = Camera.main.transform.rotation;
|
||||
await Awaiters.NextFrame;
|
||||
photo_camera.Render();
|
||||
photo_camera.targetTexture = null;
|
||||
//Capture By Camera
|
||||
Texture2D texture2D = new Texture2D(_rt.width, _rt.height, TextureFormat.RGB24, false);
|
||||
var currentRt = RenderTexture.active;
|
||||
RenderTexture.active = _rt;
|
||||
texture2D.ReadPixels(new Rect(0, 0, _rt.width, _rt.height), 0, 0);
|
||||
texture2D.Apply();
|
||||
icon_photo.sprite = Sprite.Create(texture2D, new Rect(0, 0, _rt.width, _rt.height), new Vector2(0.5f, 0.5f));
|
||||
|
||||
bytes = texture2D.EncodeToPNG();
|
||||
//ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_65"));
|
||||
RenderTexture.active = currentRt;
|
||||
_rt.Release();
|
||||
clickMask.SetActive(false);
|
||||
|
||||
}
|
||||
|
||||
void MediaSaveCallback(bool success, string path)
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
savePath = path;
|
||||
Debug.Log("Image saved to: " + path);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("Failed to save image.");
|
||||
}
|
||||
}
|
||||
|
||||
void OnClickInviteLink()
|
||||
{
|
||||
//存图片
|
||||
clickMask.SetActive(true);
|
||||
CaptureImageSaver.SaveImagePersistent(bytes, imageName, MediaSaveCallback);
|
||||
clickMask.SetActive(false);
|
||||
|
||||
if (string.IsNullOrEmpty(savePath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (adapter == null)
|
||||
{
|
||||
adapter = UnityNativeSharing.Create();
|
||||
}
|
||||
string invite = LocalizationMgr.GetText("UI_FishingSocialPanel_44");
|
||||
adapter.ShareScreenshotAndText(invite, savePath);
|
||||
}
|
||||
|
||||
void OnNextClick()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(savePath))
|
||||
{
|
||||
CaptureImageSaver.DeleteImagePersistent(savePath);
|
||||
}
|
||||
if (campData.IsCanSkyscraper)
|
||||
{
|
||||
InfiniteBuildingAct();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (campData.SwitchBuildingData != null)
|
||||
{
|
||||
SwitchBuilding();
|
||||
}
|
||||
else
|
||||
{
|
||||
OnGoto();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
void SwitchBuilding()
|
||||
{
|
||||
GContext.Publish(new SwitchVirtualCameraEvent() { type = 0, isDrag = false });
|
||||
|
||||
GContext.Publish(campData.SwitchBuildingData);
|
||||
campData.SwitchBuildingData = null;
|
||||
UIManager.Instance.DestroyUI(UITypes.TravelMapCampPhotoPanel);
|
||||
}
|
||||
async void OnGoto()
|
||||
{
|
||||
var mapData = tables.TbMapData.DataMap[playerData.lastMapId];
|
||||
|
||||
ILoadResourceService loadResourceService = GContext.container.Resolve<ILoadResourceService>();
|
||||
bool isCanEnter = await loadResourceService.Load(mapData.EnvName);
|
||||
if (isCanEnter)
|
||||
{
|
||||
EnterMap();
|
||||
}
|
||||
else
|
||||
{
|
||||
var panel = await UIManager.Instance.ShowUI(UITypes.CloudTransitionPanel);
|
||||
panel.GetComponent<CloudTransitionPanel>().SetBtn(true, EnterMap, OnCloseClick);
|
||||
}
|
||||
}
|
||||
void EnterMap()
|
||||
{
|
||||
if (campData.NextMapID != -1)
|
||||
{
|
||||
campData.ChangeNextCampID();
|
||||
GContext.Publish(new ConditionTypeEvent(ConditionType.MapUnlocked, campData.Id));
|
||||
}
|
||||
playerData.SetCurrentMapId(playerData.lastMapId);
|
||||
campData.SaveChangeCamp();
|
||||
//打开旅行地图
|
||||
//OnCloseClick();
|
||||
OpenTravelMap();
|
||||
}
|
||||
async Task OpenTravelMap()
|
||||
{
|
||||
TravelMapCtrl travelMapCtrl = new TravelMapCtrl();
|
||||
travelMapCtrl.Init(false);
|
||||
GContext.container.RegisterInstance<TravelMapCtrl>(travelMapCtrl);
|
||||
await UIManager.Instance.ShowUI(UITypes.TravelMapPanel);
|
||||
UIManager.Instance.DestroyUI(UITypes.TravelMapCampPhotoPanel);
|
||||
}
|
||||
public void OnCloseClick()
|
||||
{
|
||||
GContext.Publish(new UnloadActToNextAct());
|
||||
UIManager.Instance.DestroyUI(UITypes.TravelMapCampPhotoPanel);
|
||||
}
|
||||
|
||||
async void InfiniteBuildingAct()
|
||||
{
|
||||
ILoadResourceService loadResourceService = GContext.container.Resolve<ILoadResourceService>();
|
||||
bool isCanEnter = await loadResourceService.Load("InfiniteBuildingAct");
|
||||
if (isCanEnter)
|
||||
{
|
||||
ToCampSkyscraper();
|
||||
}
|
||||
else
|
||||
{
|
||||
var panel = await UIManager.Instance.ShowUI(UITypes.CloudTransitionPanel);
|
||||
panel.GetComponent<CloudTransitionPanel>().SetBtn(true, ToCampSkyscraper, OnCloseClick);
|
||||
}
|
||||
}
|
||||
|
||||
void ToCampSkyscraper()
|
||||
{
|
||||
GContext.Publish(new UnloadActToNextAct("InfiniteBuildingAct"));
|
||||
UIManager.Instance.DestroyUI(UITypes.TravelMapCampPhotoPanel);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/TravelMap/TravelMapPhotoPanel.cs.meta
Normal file
11
Assets/Scripts/TravelMap/TravelMapPhotoPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 05e6e3a98630589459cb4649ac9ed2a6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user