123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using UnityGameFramework.Runtime;
- using UnityEngine.AI;
- /// <summary>
- /// 场景 传送点
- /// </summary>
- public class SceneEventMapSwitchLogic : MonoBehaviour
- {
- public SceneEventMapSwitch info;
- /// <summary>
- /// 延迟传送时间
- /// </summary>
- public float delayTime;
- Collider player;
- /// <summary>
- /// 传送节点列表
- /// </summary>
- static Dictionary<int, SceneEventMapSwitchLogic> teleportList = new Dictionary<int, SceneEventMapSwitchLogic>();
- /// <summary>
- /// 间隔事件
- /// </summary>
- static float intervalTime = 2f;
- /// <summary>
- /// 如果刚刚传送过来 第一次进入事件忽略
- /// </summary>
- bool isTeleport = true;
- private void Awake()
- {
- SceneCmptManager.Instance.AddMapSwitchCmpt(this.gameObject);
- info = this.gameObject.GetComponent<SceneEventMapSwitch>();
- if (!teleportList.ContainsKey(info.switchIndex))
- {
- teleportList.Add(info.switchIndex, this);
- }
- else
- {
- teleportList[info.switchIndex] = this;
- }
- }
- // Start is called before the first frame update
- void Start()
- {
-
- AddFunctionIcon();
- }
- public void OnTriggerEnter(Collider collider)
- {
- if (collider.gameObject.layer != LayerMask.NameToLayer("Player"))
- {
- return;
- }
- if(!isTeleport)
- {
- return;
- }
- if(info.isDuplicate)
- {
- Invoke("SetInteractiveBtn", delayTime);
- }
- else
- {
- Invoke("TeleportPoint",delayTime);
- }
- }
- public void OnTriggerExit(Collider collider)
- {
- if (collider.gameObject.layer != LayerMask.NameToLayer("Player"))
- {
- return;
- }
- isTeleport = true;
- if (info.isDuplicate)
- {
- UI_BaseMainWindow.Instance().HideInteractive();
- }
- }
- public void SetInteractiveBtn()
- {
- BattleCanvas battlePanel = UI_BaseMainWindow.Instance().battleCanvas;
- GameObject interactiveObj = battlePanel.transform.Find("Main/Interactive").gameObject;
- interactiveObj.SetActive(true);
- GameObject interactiveBtnObj = battlePanel.transform.Find("Main/Interactive/collect").gameObject;
- UI_BaseMainWindow.Instance().ShowInteractiveIcon(UI_BaseMainWindow.InteractiveType.Teleport, (_btn) =>
- {
- OpenDuplicateWindow();
- });
-
- }
- public void SetTeleportClose()
- {
- isTeleport = false;
- }
- public void EnableCollider()
- {
-
- }
- public void OpenDuplicateWindow()
- {
- isTeleport = false;
- UI_DuplicateWindow.gateIdType = info.NextMapId;
- UI_DuplicateWindow.appointFloor = info.appointFloor;
- UI_DuplicateWindow.switchIndex = info.switchIndex;
- switch (info.NextMapId)
- {
- case 200101:
- UI_DuplicateWindow.floorNum = 10;
- UI_DuplicateWindow.duplicateTypeName = "<color=magenta>" + "唤灵师碎片" + "</color>";
- PanelHelper.Instance.ShowPanel("UI_DuplicateFloorWindow");
- break;
- case 200201:
- UI_DuplicateWindow.floorNum = 5;
- UI_DuplicateWindow.duplicateTypeName = "<color=magenta>" + "武器突破石" + "</color>";
- PanelHelper.Instance.ShowPanel("UI_DuplicateFloorWindow");
- break;
- case 200301:
- UI_DuplicateWindow.floorNum = 5;
- UI_DuplicateWindow.duplicateTypeName = "<color=magenta>" + "言灵突破石" + "</color>";
- PanelHelper.Instance.ShowPanel("UI_DuplicateFloorWindow");
- break;
- case 210101:
- case 210102:
- case 210103:
- case 210104:
- case 210105:
- case 210106:
- case 210107:
- case 210108:
- UI_DuplicateWindow.floorNum = 10;
- UI_DuplicateWindow.duplicateTypeName = "<color=magenta>" + "言灵召唤材料" + "</color>";
- PanelHelper.Instance.ShowPanel("UI_DuplicateFloorWindow");
- break;
- case 210201:
- UI_DuplicateWindow.floorNum = 5;
- UI_DuplicateWindow.duplicateTypeName = "<color=magenta>" + "武器强化符" + "</color>";
- PanelHelper.Instance.ShowPanel("UI_DuplicateFloorWindow");
- break;
- case 210301:
- case 210302:
- case 210303:
- UI_DuplicateWindow.floorNum = 5;
- UI_DuplicateWindow.duplicateTypeName = "<color=magenta>" + "武器突破材料" + "</color>";
- PanelHelper.Instance.ShowPanel("UI_DuplicateFloorWindow");
- break;
- case 210401:
- case 210402:
- case 210403:
- case 210404:
- case 210405:
- case 210406:
- case 210407:
- case 210408:
- UI_DuplicateWindow.floorNum = 5;
- UI_DuplicateWindow.duplicateTypeName = "<color=magenta>" + "言灵突破材料" + "</color>";
- PanelHelper.Instance.ShowPanel("UI_DuplicateFloorWindow");
- break;
- case 507001:
- UI_DuplicateWindow.floorNum = 1;
- UI_DuplicateWindow.duplicateTypeName = "<color=magenta>" + "Boss战副本" + "</color>";
- PanelHelper.Instance.ShowPanel("UI_DuplicateFloorWindow");
- break;
- case 507002:
- UI_DuplicateWindow.floorNum = 1;
- UI_DuplicateWindow.duplicateTypeName = "<color=magenta>" + "Boss战副本" + "</color>";
- PanelHelper.Instance.ShowPanel("UI_DuplicateFloorWindow");
- break;
- }
- }
- public void TeleportPoint()
- {
- if(info.switchIndex != 0)
- {
- GameDateManager.Instance.GateID = info.NextMapId;
- GameDateManager.Instance.GateVO = new UIVO_Gate.SelectGateVo((UIVO_Gate.EGateDiffculty)GameDateManager.Instance.GateDifficulty);
- GameDateManager.Instance.GateVO.gateId = info.NextMapId;
- GameDateManager.Instance.isBackTicket = false;
- GameDateManager.Instance.IsBackDoor = false;
- isTeleport = false;
- GameDateManager.Instance.CreateMapSwitchPoint = info.NextSwitchIndex;
- //// 上传本张地图数据同步到服务器
- //var mapdata = new NetData.Info_Map()
- //{
- // mapId = UserProxy.Instance.player.newMap.curMapId,
- //};
- //mapdata.ResetData();
- //MapTcpProxy.Instance.Peer.ReportDataChange(mapdata);
- // 获取下一张地图服务器数据
- MapTcpProxy.Instance.Peer.SwitchNextMap(GameDateManager.Instance.GateID, 0, (mapData) =>
- {
- // 切换关卡
- EventComponent eventCmpt = GameEntry.GetComponent<EventComponent>();
- SceneCmptManager.Instance.Reset();
- if(info.isEntry)
- {
- eventCmpt.FireNow(this, new MainEventGoBattle(GameDateManager.Instance.GateID, GameDateManager.Instance.GateDifficulty, info.NextSwitchIndex));
- }
- else
- {
- eventCmpt.FireNow(this, new MainEventGoBattle(GameDateManager.Instance.GateID, GameDateManager.Instance.GateDifficulty, MapTcpProxy.Instance.Peer.MapData.BirthPoint));
- }
- });
- }
- }
- public void AddFunctionIcon()
- {
- string srcName = "";
- if(info.isEntry)
- {
- srcName = "minimap_entry";
- }
- else
- {
- srcName = "minimap_export";
- }
- ResourceHelper.Instance.LoadAssetBundle(srcName, (ab) =>
- {
- GameObject iconObj = (GameObject)Instantiate(ab.LoadAsset(srcName));
- iconObj.SetActive(true);
- iconObj.SetLayerRecursively(LayerMask.NameToLayer("MiniMap"));
- iconObj.AddComponent<SceneCmptIconByMiniMap>();
- iconObj.transform.parent = this.transform;
- iconObj.transform.position = Vector3.zero;
- iconObj.transform.localPosition = Vector3.zero;
- iconObj.transform.SetLocalPositionY(0.5f);
- });
- }
- }
|