111 lines
2.9 KiB
C#
111 lines
2.9 KiB
C#
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using System.Collections;
|
|||
|
using GCGame;
|
|||
|
using GCGame.Table;
|
|||
|
using System.Collections.Generic;
|
|||
|
using Games.LogicObj;
|
|||
|
using Module.Log;
|
|||
|
using Games.GlobeDefine;
|
|||
|
using UnityEngine.EventSystems;
|
|||
|
using Games.Item;
|
|||
|
|
|||
|
public class TreasureSceneMap : UIControllerBase<TreasureSceneMap>
|
|||
|
{
|
|||
|
#region
|
|||
|
|
|||
|
public static void ShowTreasureMap(GameItem gameItem)
|
|||
|
{
|
|||
|
Hashtable hash = new Hashtable();
|
|||
|
hash.Add("GameItem", gameItem);
|
|||
|
UIManager.ShowUI(UIInfo.TreasureSceneMap, ShowUIOver, hash);
|
|||
|
}
|
|||
|
|
|||
|
static void ShowUIOver(bool bSuccess, object param)
|
|||
|
{
|
|||
|
if (bSuccess)
|
|||
|
{
|
|||
|
Hashtable hash = param as Hashtable;
|
|||
|
GameItem treasureItem = hash["GameItem"] as GameItem;
|
|||
|
|
|||
|
if (TreasureSceneMap.Instance() != null)
|
|||
|
{
|
|||
|
TreasureSceneMap.Instance().ShowTreasure(treasureItem);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region
|
|||
|
|
|||
|
void OnEnable()
|
|||
|
{
|
|||
|
SetInstance(this);
|
|||
|
}
|
|||
|
|
|||
|
void OnDisable()
|
|||
|
{
|
|||
|
SetInstance(null);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
public RawImage _SceneMapImage;
|
|||
|
public Text _SceneName;
|
|||
|
public Button[] _Buttons;
|
|||
|
|
|||
|
private MapInterface _MapInterface = new MapInterface();
|
|||
|
private Tab_TreasureBase _TreasureBase;
|
|||
|
private GameItem _GameItem;
|
|||
|
|
|||
|
void ShowTreasure(GameItem treasureItem)
|
|||
|
{
|
|||
|
_GameItem = treasureItem;
|
|||
|
_TreasureBase = TableManager.GetTreasureBaseByID(treasureItem.DataID, 0);
|
|||
|
if (_TreasureBase == null)
|
|||
|
return;
|
|||
|
|
|||
|
Tab_SceneClass sceneInfo = TableManager.GetSceneClassByID(_TreasureBase.ScneneId, 0);
|
|||
|
if (sceneInfo == null)
|
|||
|
return;
|
|||
|
|
|||
|
_SceneName.text = sceneInfo.Name.ToString();
|
|||
|
_MapInterface.Init(_SceneMapImage.rectTransform, null, null, null, null);
|
|||
|
_MapInterface.SetMapImage(sceneInfo.SceneMapTexture, _SceneMapImage);
|
|||
|
|
|||
|
SetTreasureBtn();
|
|||
|
}
|
|||
|
|
|||
|
void SetTreasureBtn()
|
|||
|
{
|
|||
|
for (int i = 0; i < _TreasureBase.getPosXCount(); ++i)
|
|||
|
{
|
|||
|
Vector3 treasurePos = new Vector3(_TreasureBase.GetPosXbyIndex(i), 0, _TreasureBase.GetPosYbyIndex(i));
|
|||
|
if (treasurePos != Vector3.zero)
|
|||
|
{
|
|||
|
_Buttons[i].gameObject.SetActive(true);
|
|||
|
RectTransform rect = _Buttons[i].GetComponent<RectTransform>();
|
|||
|
if(rect!=null)
|
|||
|
{
|
|||
|
rect.anchoredPosition3D = _MapInterface.ScenePosToMapPosVec3(treasurePos);
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_Buttons[i].gameObject.SetActive(false);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void SelectTreasure(int idx)
|
|||
|
{
|
|||
|
TresureItem.Instance.AutoSearchTreasurePos(_TreasureBase.ScneneId, new Vector3(_TreasureBase.GetPosXbyIndex(idx), 0, _TreasureBase.GetPosYbyIndex(idx)), _GameItem);
|
|||
|
CloseWindow();
|
|||
|
}
|
|||
|
|
|||
|
public void CloseWindow()
|
|||
|
{
|
|||
|
UIManager.CloseUI(UIInfo.TreasureSceneMap);
|
|||
|
}
|
|||
|
}
|