2025-06-14 13:46:24 +08:00
|
|
|
|
using HxGame;
|
|
|
|
|
|
using HxGame.Data;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
|
|
public partial class MapManager : MonoBehaviour
|
|
|
|
|
|
{
|
|
|
|
|
|
public enum EditCellType
|
|
|
|
|
|
{
|
|
|
|
|
|
None,
|
|
|
|
|
|
ReturnCell, //<2F>سǵ<D8B3>
|
|
|
|
|
|
TeleportCell, //<2F><><EFBFBD>͵<EFBFBD>
|
|
|
|
|
|
NpcCell, //NPC
|
|
|
|
|
|
PathNodeCell, //·<><C2B7>
|
|
|
|
|
|
NpcPath, //npcѲ<63><D1B2>·<EFBFBD><C2B7>
|
|
|
|
|
|
MonsterPath, //<2F><><EFBFBD><EFBFBD>Ѳ<EFBFBD><D1B2>·<EFBFBD><C2B7>
|
|
|
|
|
|
AudioTrigger, //<2F><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>
|
|
|
|
|
|
TriggerCell, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
ReliveCell, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
SellArea, //<2F><>̯<EFBFBD><CCAF>
|
|
|
|
|
|
MonsterArea, //<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
|
FuBenArea, //<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
|
JuBaoArea, //<2F>۱<EFBFBD>
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public struct CenterPoint
|
|
|
|
|
|
{
|
|
|
|
|
|
public int areaIdx;
|
|
|
|
|
|
public int radius; //<2F>뾶
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public struct TriggerPoint
|
|
|
|
|
|
{
|
|
|
|
|
|
public int areaIdx;
|
|
|
|
|
|
public int radius; //<2F>뾶
|
|
|
|
|
|
public string text;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public struct MonsterPoint
|
|
|
|
|
|
{
|
|
|
|
|
|
public int areaIdx;
|
|
|
|
|
|
public int radius; //<2F>뾶
|
|
|
|
|
|
public int id; //ˢ<><CBA2>ID
|
|
|
|
|
|
public int num; //ˢ<><CBA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//<2F><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>ɵĵ<C9B5><C4B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
private List<string> _activeTerrainCells = new List<string>();
|
|
|
|
|
|
private const int IGNORECELLSIZE = 15;
|
|
|
|
|
|
private EditCellType _curEditCellType = EditCellType.None;
|
|
|
|
|
|
|
|
|
|
|
|
private int _teleportPointSize = 0; //<2F><><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
private int _curTeleportPointIdx = 0; //<2F><>ǰ<EFBFBD>༭<EFBFBD><E0BCAD><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
private int _npcPointSize = 0; //npc<70><63><EFBFBD><EFBFBD>
|
|
|
|
|
|
private int _curNpcPointIdx = 0; //<2F><>ǰ<EFBFBD>༭npc<70><63><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
private int _pathNodePointSize = 0; //·<><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
private int _curPathNodePointIdx = 0; //<2F><>ǰ<EFBFBD>༭·<E0BCAD><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
private int _triggerPointSize = 0; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
private int _curTriggerPointIdx = 0; //<2F><>ǰ<EFBFBD>༭<EFBFBD><E0BCAD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
//npc·<63><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>map
|
|
|
|
|
|
private Dictionary<int, int> _dicNpcPathPointSize = new Dictionary<int, int>();
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>map
|
|
|
|
|
|
private Dictionary<int, int> _dicMonsterPathPointSize = new Dictionary<int, int>();
|
|
|
|
|
|
|
|
|
|
|
|
private CenterPoint _curAudioTriggerCenterPoint = new CenterPoint(); //<2F><>ǰ<EFBFBD>༭<EFBFBD><E0BCAD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
private TriggerPoint _curTriggerCenterPoint = new TriggerPoint(); //<2F><>ǰ<EFBFBD>༭<EFBFBD><E0BCAD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
private CenterPoint _curReliveCenterPoint = new CenterPoint(); //<2F><>ǰ<EFBFBD>༭<EFBFBD><E0BCAD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
private CenterPoint _curSellAreaCenterPoint = new CenterPoint(); //<2F><>ǰ<EFBFBD>༭<EFBFBD><E0BCAD>̯<EFBFBD><CCAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
private MonsterPoint _curMonsterPoint = new MonsterPoint(); //ˢ<><CBA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
private MonsterPoint _curFuBenPoint = new MonsterPoint(); //<2F><><EFBFBD><EFBFBD>ˢ<EFBFBD><CBA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
private MonsterPoint _curJuBaoPoint = new MonsterPoint(); //<2F>۱<EFBFBD><DBB1><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
public CellNode[] cellsNode;
|
|
|
|
|
|
|
2025-06-19 01:31:00 +08:00
|
|
|
|
private Dictionary<CellType, List<GameObject>> _layCellsMap = new Dictionary<CellType, List<GameObject>>();
|
2025-06-14 13:46:24 +08:00
|
|
|
|
|
|
|
|
|
|
public void SetEditCellType(EditCellType type)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(cellsNode == null || cellsNode.Length == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
UIWindow.Instance.ShowMessage("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_curEditCellType = type;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD>͵<EFBFBD>
|
|
|
|
|
|
public int AddTeleportPointSize()
|
|
|
|
|
|
{
|
|
|
|
|
|
return ++_teleportPointSize;
|
|
|
|
|
|
}
|
|
|
|
|
|
public void RemoveTeleportPointSize(int idx)
|
|
|
|
|
|
{
|
|
|
|
|
|
_curTeleportPointIdx = idx;
|
|
|
|
|
|
RemoveSpecialPoint(EditCellType.TeleportCell);
|
|
|
|
|
|
}
|
|
|
|
|
|
public void SetCurTeleportPointIdx(int idx)
|
|
|
|
|
|
{
|
|
|
|
|
|
_curTeleportPointIdx = idx;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//NPC
|
|
|
|
|
|
public int AddNpcPointSize()
|
|
|
|
|
|
{
|
|
|
|
|
|
return ++_npcPointSize;
|
|
|
|
|
|
}
|
|
|
|
|
|
public void RemoveNpcPointSize(int idx)
|
|
|
|
|
|
{
|
|
|
|
|
|
_curNpcPointIdx = idx;
|
|
|
|
|
|
RemoveSpecialPoint(EditCellType.NpcCell);
|
|
|
|
|
|
//<2F><>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD>npc·<63><C2B7>
|
|
|
|
|
|
int size = _dicNpcPathPointSize[_curNpcPointIdx];
|
|
|
|
|
|
for (int i = 1; i <= size; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
RemoveSpecialPoint(EditCellType.NpcPath, i);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public void SetCurNpcPointIdx(int idx)
|
|
|
|
|
|
{
|
|
|
|
|
|
_curNpcPointIdx = idx;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//·<><C2B7>
|
|
|
|
|
|
public void ZeroNodePathSize()
|
|
|
|
|
|
{
|
|
|
|
|
|
_pathNodePointSize = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
public int AddPathNodePointSize()
|
|
|
|
|
|
{
|
|
|
|
|
|
return ++_pathNodePointSize;
|
|
|
|
|
|
}
|
|
|
|
|
|
public void RemovePathNodePointSize(int idx)
|
|
|
|
|
|
{
|
|
|
|
|
|
_curPathNodePointIdx = idx;
|
|
|
|
|
|
RemoveSpecialPoint(EditCellType.PathNodeCell);
|
|
|
|
|
|
}
|
|
|
|
|
|
public void SetCurPathNodePointIdx(int idx)
|
|
|
|
|
|
{
|
|
|
|
|
|
_curPathNodePointIdx = idx;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//<2F><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>
|
|
|
|
|
|
public void SetCurAudioTriggerCenterPoint(int idx, int radius)
|
|
|
|
|
|
{
|
|
|
|
|
|
_curAudioTriggerCenterPoint.areaIdx = idx;
|
|
|
|
|
|
_curAudioTriggerCenterPoint.radius = radius;
|
|
|
|
|
|
}
|
|
|
|
|
|
public void RemoveAudioTriggerCenterPoint(int idx)
|
|
|
|
|
|
{
|
|
|
|
|
|
_curAudioTriggerCenterPoint.areaIdx = idx;
|
|
|
|
|
|
RemoveSpecialPoint(EditCellType.AudioTrigger);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
public void SetCurTriggerCenterPoint(int idx, int radius, TriggerMode mode)
|
|
|
|
|
|
{
|
|
|
|
|
|
_curTriggerCenterPoint.areaIdx = idx;
|
|
|
|
|
|
_curTriggerCenterPoint.radius = radius;
|
|
|
|
|
|
|
|
|
|
|
|
switch(mode)
|
|
|
|
|
|
{
|
|
|
|
|
|
case TriggerMode.KillMonster:
|
|
|
|
|
|
_curTriggerCenterPoint.text = "ɱ<>ִ<EFBFBD><D6B4><EFBFBD>";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case TriggerMode.UseItem:
|
|
|
|
|
|
_curTriggerCenterPoint.text = "<22><><EFBFBD>ߴ<EFBFBD><DFB4><EFBFBD>";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case TriggerMode.Task:
|
|
|
|
|
|
_curTriggerCenterPoint.text = "<22><><EFBFBD><EFBFBD>";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case TriggerMode.Npc:
|
|
|
|
|
|
_curTriggerCenterPoint.text = "NPC<50><43><EFBFBD><EFBFBD>";
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public void RemoveTriggerCenterPoint(int idx)
|
|
|
|
|
|
{
|
|
|
|
|
|
_curTriggerCenterPoint.areaIdx = idx;
|
|
|
|
|
|
RemoveSpecialPoint(EditCellType.TriggerCell);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
public void SetReliveCenterPoint(int idx, int radius)
|
|
|
|
|
|
{
|
|
|
|
|
|
_curReliveCenterPoint.areaIdx = idx;
|
|
|
|
|
|
_curReliveCenterPoint.radius = radius;
|
|
|
|
|
|
}
|
|
|
|
|
|
public void RemoveReliveCenterPoint(int idx)
|
|
|
|
|
|
{
|
|
|
|
|
|
_curReliveCenterPoint.areaIdx = idx;
|
|
|
|
|
|
RemoveSpecialPoint(EditCellType.ReliveCell);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//<2F><>̯<EFBFBD><CCAF>
|
|
|
|
|
|
public void SetCurSellCenterPoint(int idx, int radius)
|
|
|
|
|
|
{
|
|
|
|
|
|
_curSellAreaCenterPoint.areaIdx = idx;
|
|
|
|
|
|
_curSellAreaCenterPoint.radius = radius;
|
|
|
|
|
|
}
|
|
|
|
|
|
public void RemoveSellCenterPoint(int idx)
|
|
|
|
|
|
{
|
|
|
|
|
|
_curSellAreaCenterPoint.areaIdx = idx;
|
|
|
|
|
|
RemoveSpecialPoint(EditCellType.SellArea);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
|
public void SetMonsterPoint(int idx, int radius, int id, int num)
|
|
|
|
|
|
{
|
|
|
|
|
|
_curMonsterPoint.areaIdx = idx;
|
|
|
|
|
|
_curMonsterPoint.radius = radius;
|
|
|
|
|
|
_curMonsterPoint.id = id;
|
|
|
|
|
|
_curMonsterPoint.num = num;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void RemoveMonsterPoint(int idx)
|
|
|
|
|
|
{
|
|
|
|
|
|
_curMonsterPoint.areaIdx = idx;
|
|
|
|
|
|
RemoveSpecialPoint(EditCellType.MonsterArea);
|
|
|
|
|
|
//<2F><>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD>npc·<63><C2B7>
|
|
|
|
|
|
if (!_dicMonsterPathPointSize.ContainsKey(_curMonsterPoint.areaIdx))
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
int size = _dicMonsterPathPointSize[_curMonsterPoint.areaIdx];
|
|
|
|
|
|
for (int i = 1; i <= size; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
RemoveSpecialPoint(EditCellType.MonsterPath, i);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void ShowMonsterPoint(int idx)
|
|
|
|
|
|
{
|
|
|
|
|
|
Transform cellsTrans = UIWindow.Instance.mapTrans.Find("CellsNode");
|
|
|
|
|
|
if (cellsTrans == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
UIWindow.Instance.ShowMessage("û<><C3BB><EFBFBD>ҵ<EFBFBD>CellsNode<64>ڵ<EFBFBD>");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string cellName = $"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>{idx}";
|
|
|
|
|
|
|
|
|
|
|
|
var t = cellsTrans.Find(cellName);
|
|
|
|
|
|
if (t == null)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
t.gameObject.SetActive(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void HideMonsterPoint(int idx)
|
|
|
|
|
|
{
|
|
|
|
|
|
Transform cellsTrans = UIWindow.Instance.mapTrans.Find("CellsNode");
|
|
|
|
|
|
if (cellsTrans == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
UIWindow.Instance.ShowMessage("û<><C3BB><EFBFBD>ҵ<EFBFBD>CellsNode<64>ڵ<EFBFBD>");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string cellName = $"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>{idx}";
|
|
|
|
|
|
|
|
|
|
|
|
var t = cellsTrans.Find(cellName);
|
|
|
|
|
|
if (t == null)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
t.gameObject.SetActive(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//npcѲ<63><D1B2>·<EFBFBD><C2B7>
|
|
|
|
|
|
public int AddNpcPathSize()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!_dicNpcPathPointSize.ContainsKey(_curNpcPointIdx))
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
|
|
return _dicNpcPathPointSize[_curNpcPointIdx]++;
|
|
|
|
|
|
}
|
|
|
|
|
|
public void SetCurNpcPathIdx(int idx)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_dicNpcPathPointSize.ContainsKey(_curNpcPointIdx))
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
_dicNpcPathPointSize.Add(_curNpcPointIdx, idx);
|
|
|
|
|
|
}
|
|
|
|
|
|
public int GetCurNpcPathIdx()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!_dicNpcPathPointSize.ContainsKey(_curNpcPointIdx))
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
|
|
return _dicNpcPathPointSize[_curNpcPointIdx];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//monsterѲ<72><D1B2>·<EFBFBD><C2B7>
|
|
|
|
|
|
public int AddMonsterPathSize()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!_dicMonsterPathPointSize.ContainsKey(_curMonsterPoint.areaIdx))
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
|
|
return _dicMonsterPathPointSize[_curMonsterPoint.areaIdx]++;
|
|
|
|
|
|
}
|
|
|
|
|
|
public void SetCurMonsterPathIdx(int idx)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_dicMonsterPathPointSize.ContainsKey(_curMonsterPoint.areaIdx))
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
_dicMonsterPathPointSize.Add(_curMonsterPoint.areaIdx, idx);
|
|
|
|
|
|
}
|
|
|
|
|
|
public int GetCurMonsterPathIdx()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!_dicMonsterPathPointSize.ContainsKey(_curMonsterPoint.areaIdx))
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
|
|
return _dicMonsterPathPointSize[_curMonsterPoint.areaIdx];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ˢ<EFBFBD><CBA2><EFBFBD><EFBFBD>
|
|
|
|
|
|
public void SetCurFuBenCenterPoint(int idx, int radius, int id, int num)
|
|
|
|
|
|
{
|
|
|
|
|
|
_curFuBenPoint.areaIdx = idx;
|
|
|
|
|
|
_curFuBenPoint.radius = radius;
|
|
|
|
|
|
_curFuBenPoint.id = id;
|
|
|
|
|
|
_curFuBenPoint.num = num;
|
|
|
|
|
|
}
|
|
|
|
|
|
public void RemoveFuBenCenterPoint(int idx)
|
|
|
|
|
|
{
|
|
|
|
|
|
_curFuBenPoint.areaIdx = idx;
|
|
|
|
|
|
RemoveSpecialPoint(EditCellType.FuBenArea);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//<2F>۱<EFBFBD><DBB1><EFBFBD>
|
|
|
|
|
|
//public void SetCurJuBaoCenterPoint(int idx, int radius, int id, int num)
|
|
|
|
|
|
public void SetCurJuBaoCenterPoint(int idx, int radius, int id)
|
|
|
|
|
|
{
|
|
|
|
|
|
_curJuBaoPoint.areaIdx = idx;
|
|
|
|
|
|
_curJuBaoPoint.radius = radius;
|
|
|
|
|
|
_curJuBaoPoint.id = id;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void RemoveJuBaoCenterPoint(int idx)
|
|
|
|
|
|
{
|
|
|
|
|
|
_curJuBaoPoint.areaIdx = idx;
|
|
|
|
|
|
RemoveSpecialPoint(EditCellType.JuBaoArea);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private string GetSpecialName(EditCellType cellType, out int size)
|
|
|
|
|
|
{
|
|
|
|
|
|
size = 0;
|
|
|
|
|
|
string cellName = string.Empty;
|
|
|
|
|
|
switch (cellType)
|
|
|
|
|
|
{
|
|
|
|
|
|
case EditCellType.TeleportCell:
|
|
|
|
|
|
cellName = "<22><><EFBFBD>͵<EFBFBD>";
|
|
|
|
|
|
size = _teleportPointSize;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EditCellType.NpcCell:
|
|
|
|
|
|
cellName = "Npc";
|
|
|
|
|
|
size = _npcPointSize;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EditCellType.PathNodeCell:
|
|
|
|
|
|
cellName = "PathNode";
|
|
|
|
|
|
size = _pathNodePointSize;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EditCellType.ReliveCell:
|
|
|
|
|
|
cellName = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
|
|
|
|
|
size = UIWindow.Instance.uiRelivesPanel.itemParent.childCount;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EditCellType.AudioTrigger:
|
|
|
|
|
|
cellName = "<22><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>";
|
|
|
|
|
|
size = UIWindow.Instance.uiAudioTriggerPanel.itemParent.childCount;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EditCellType.TriggerCell:
|
|
|
|
|
|
cellName = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
|
|
|
|
|
size = UIWindow.Instance.uiTriggersPanel.itemParent.childCount;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EditCellType.SellArea:
|
|
|
|
|
|
cellName = "<22><>̯<EFBFBD><CCAF>";
|
|
|
|
|
|
size = UIWindow.Instance.uiSellAreasPanel.itemParent.childCount;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EditCellType.MonsterArea:
|
|
|
|
|
|
cellName = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
|
|
|
|
|
//size = UIWindow.Instance.uiMonstersPanel_old.itemParent.childCount;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EditCellType.FuBenArea:
|
|
|
|
|
|
cellName = "<22><><EFBFBD><EFBFBD>ˢ<EFBFBD><CBA2>";
|
|
|
|
|
|
size = UIWindow.Instance.uiFuBensPanel.itemParent.childCount;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EditCellType.JuBaoArea:
|
|
|
|
|
|
cellName = "<22>۱<EFBFBD><DBB1><EFBFBD>";
|
|
|
|
|
|
size = UIWindow.Instance.uiFuBensPanel.itemParent.childCount;
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return cellName;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void ShowSpecialPoint(EditCellType cellType)
|
|
|
|
|
|
{
|
|
|
|
|
|
int size = 0;
|
|
|
|
|
|
string cellName = GetSpecialName(cellType, out size);
|
|
|
|
|
|
|
|
|
|
|
|
if(cellType == EditCellType.MonsterArea)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public void HideSpecialPoint(EditCellType cellType)
|
|
|
|
|
|
{
|
|
|
|
|
|
int size = 0;
|
|
|
|
|
|
string cellName = GetSpecialName(cellType, out size);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void RemoveSpecialPoint(EditCellType cellType, int idx = 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
string cellName = string.Empty;
|
|
|
|
|
|
switch (cellType)
|
|
|
|
|
|
{
|
|
|
|
|
|
case EditCellType.ReturnCell:
|
|
|
|
|
|
cellName = "<22>سǵ<D8B3>";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EditCellType.TeleportCell:
|
|
|
|
|
|
cellName = $"<22><><EFBFBD>͵<EFBFBD>{_curTeleportPointIdx}";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EditCellType.NpcCell:
|
|
|
|
|
|
cellName = $"Npc{_curNpcPointIdx}";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EditCellType.PathNodeCell:
|
|
|
|
|
|
cellName = $"PathNode{_curPathNodePointIdx}";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EditCellType.ReliveCell:
|
|
|
|
|
|
cellName = $"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>{_curReliveCenterPoint.areaIdx}";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EditCellType.AudioTrigger:
|
|
|
|
|
|
cellName = $"<22><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>{_curAudioTriggerCenterPoint.areaIdx}";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EditCellType.TriggerCell:
|
|
|
|
|
|
cellName = $"Trigger{_curTriggerPointIdx}";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EditCellType.SellArea:
|
|
|
|
|
|
cellName = $"<22><>̯<EFBFBD><CCAF>{_curSellAreaCenterPoint.areaIdx}";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EditCellType.MonsterArea:
|
|
|
|
|
|
cellName = $"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>{_curMonsterPoint.areaIdx}";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EditCellType.FuBenArea:
|
|
|
|
|
|
cellName = $"<22><><EFBFBD><EFBFBD>ˢ<EFBFBD><CBA2>{_curFuBenPoint.areaIdx}";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EditCellType.JuBaoArea:
|
|
|
|
|
|
cellName = $"<22>۱<EFBFBD><DBB1><EFBFBD>{_curJuBaoPoint.areaIdx}";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EditCellType.NpcPath:
|
|
|
|
|
|
cellName = $"NpcPath{_curNpcPointIdx}{idx}";
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EditCellType.MonsterPath:
|
|
|
|
|
|
cellName = $"MonsterPath{_curMonsterPoint .areaIdx}{idx}";
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-21 01:29:18 +08:00
|
|
|
|
if (mapAreaParent.Find(cellName))
|
2025-06-14 13:46:24 +08:00
|
|
|
|
{
|
2025-06-21 01:29:18 +08:00
|
|
|
|
DestroyImmediate(mapAreaParent.Find(cellName).gameObject);
|
2025-06-14 13:46:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void CreateSpecialPoint(int x, int y, EditCellType cellType)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_curOpenMapId <= 0)
|
|
|
|
|
|
return;
|
|
|
|
|
|
UnityEngine.Object obj = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (cellType < EditCellType.AudioTrigger)
|
2025-06-16 00:15:41 +08:00
|
|
|
|
obj = null;
|
2025-06-14 13:46:24 +08:00
|
|
|
|
else if (cellType == EditCellType.AudioTrigger)
|
|
|
|
|
|
obj = Resources.Load("Prefabs/audioTriggerCenterPoint");
|
|
|
|
|
|
else if (cellType == EditCellType.TriggerCell)
|
|
|
|
|
|
obj = Resources.Load("Prefabs/triggerCenterPoint");
|
|
|
|
|
|
else if (cellType == EditCellType.ReliveCell)
|
|
|
|
|
|
obj = Resources.Load("Prefabs/reliveCenterPoint");
|
|
|
|
|
|
else if (cellType == EditCellType.MonsterArea)
|
|
|
|
|
|
obj = Resources.Load("Prefabs/monsterPoint");
|
|
|
|
|
|
else if (cellType == EditCellType.FuBenArea)
|
|
|
|
|
|
obj = Resources.Load("Prefabs/fubenPoint");
|
|
|
|
|
|
else if (cellType == EditCellType.JuBaoArea)
|
|
|
|
|
|
obj = Resources.Load("Prefabs/jubaoPoint");
|
|
|
|
|
|
|
|
|
|
|
|
if (obj == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
UIWindow.Instance.ShowMessage("<22><><EFBFBD><EFBFBD>cell.prefabʧ<62><CAA7>");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string cellName = string.Empty;
|
|
|
|
|
|
Material mat = null;
|
|
|
|
|
|
Vector3 localScale = Vector3.zero;
|
|
|
|
|
|
|
|
|
|
|
|
switch (cellType)
|
|
|
|
|
|
{
|
|
|
|
|
|
case EditCellType.ReturnCell:
|
|
|
|
|
|
cellName = "<22>سǵ<D8B3>";
|
|
|
|
|
|
mat = _cellReturnMat;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EditCellType.TeleportCell:
|
|
|
|
|
|
cellName = $"<22><><EFBFBD>͵<EFBFBD>{_curTeleportPointIdx}";
|
|
|
|
|
|
mat = _cellTeleportMat;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EditCellType.NpcCell:
|
|
|
|
|
|
cellName = $"Npc{_curNpcPointIdx}";
|
|
|
|
|
|
mat = _cellNpcMat;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EditCellType.PathNodeCell:
|
|
|
|
|
|
cellName = $"PathNode{_curPathNodePointIdx}";
|
|
|
|
|
|
mat = _cellPathNodeMat;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EditCellType.AudioTrigger:
|
|
|
|
|
|
cellName = $"<22><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>{_curAudioTriggerCenterPoint.areaIdx}";
|
|
|
|
|
|
localScale = new Vector3(0.9f * _curAudioTriggerCenterPoint.radius * 2, 0.9f * _curAudioTriggerCenterPoint.radius * 2, 1);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EditCellType.TriggerCell:
|
|
|
|
|
|
cellName = $"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>{_curTriggerCenterPoint.areaIdx}";
|
|
|
|
|
|
localScale = new Vector3(0.9f * _curTriggerCenterPoint.radius * 2, 0.9f * _curTriggerCenterPoint.radius * 2, 1);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EditCellType.ReliveCell:
|
|
|
|
|
|
cellName = $"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>{_curReliveCenterPoint.areaIdx}";
|
|
|
|
|
|
localScale = new Vector3(0.9f * _curReliveCenterPoint.radius * 2, 0.9f * _curReliveCenterPoint.radius * 2, 1);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EditCellType.SellArea:
|
|
|
|
|
|
cellName = $"<22><>̯<EFBFBD><CCAF>{_curSellAreaCenterPoint.areaIdx}";
|
|
|
|
|
|
localScale = new Vector3(0.9f * _curSellAreaCenterPoint.radius * 2, 0.9f * _curSellAreaCenterPoint.radius * 2, 1);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EditCellType.MonsterArea:
|
|
|
|
|
|
cellName = $"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>{_curMonsterPoint.areaIdx}";
|
|
|
|
|
|
localScale = new Vector3(0.9f * _curMonsterPoint.radius * 2, 0.9f * _curMonsterPoint.radius * 2, 1);
|
|
|
|
|
|
if (localScale == Vector3.forward)
|
|
|
|
|
|
localScale = new Vector3(0.5f, 0.5f, 1);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EditCellType.FuBenArea:
|
|
|
|
|
|
cellName = $"<22><><EFBFBD><EFBFBD>ˢ<EFBFBD><CBA2>{_curFuBenPoint.areaIdx}";
|
|
|
|
|
|
localScale = new Vector3(0.9f * _curFuBenPoint.radius * 2, 0.9f * _curFuBenPoint.radius * 2, 1);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EditCellType.JuBaoArea:
|
|
|
|
|
|
cellName = $"<22>۱<EFBFBD><DBB1><EFBFBD>{_curJuBaoPoint.areaIdx}";
|
|
|
|
|
|
localScale = new Vector3(0.9f * _curJuBaoPoint.radius * 2, 0.9f * _curJuBaoPoint.radius * 2, 1);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EditCellType.NpcPath:
|
|
|
|
|
|
cellName = $"NpcPath{_curNpcPointIdx}{GetCurNpcPathIdx()}";
|
|
|
|
|
|
mat = _cellPathNodeMat;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case EditCellType.MonsterPath:
|
|
|
|
|
|
cellName = $"MonsterPath{_curMonsterPoint.areaIdx}{GetCurMonsterPathIdx()}";
|
|
|
|
|
|
mat = _cellPathNodeMat;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GameObject go = null;
|
2025-06-21 01:29:18 +08:00
|
|
|
|
if (mapAreaParent.Find(cellName))
|
2025-06-14 13:46:24 +08:00
|
|
|
|
{
|
2025-06-21 01:29:18 +08:00
|
|
|
|
go = mapAreaParent.Find(cellName).gameObject;
|
2025-06-14 13:46:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
go = Instantiate(obj) as GameObject;
|
2025-06-21 01:29:18 +08:00
|
|
|
|
go.transform.SetParent(mapAreaParent, false);
|
2025-06-14 13:46:24 +08:00
|
|
|
|
go.transform.localScale = new Vector3(((float)_cellWidth / CELLSCALE) - 0.1f, ((float)_cellHeight / CELLSCALE) - 0.1f, 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CellNode cell = GetCell(x, y);
|
|
|
|
|
|
|
|
|
|
|
|
Vector3 pos = cell.GetPos((float)_cellWidth / CELLSCALE, (float)_cellHeight / CELLSCALE);
|
|
|
|
|
|
go.transform.localPosition = new Vector3(pos.x, pos.z, pos.y);
|
|
|
|
|
|
go.name = cellName;
|
|
|
|
|
|
|
|
|
|
|
|
if (cellType < EditCellType.AudioTrigger)
|
|
|
|
|
|
go.GetComponent<MeshRenderer>().material = mat;
|
|
|
|
|
|
else
|
|
|
|
|
|
go.transform.localScale = localScale;
|
|
|
|
|
|
|
|
|
|
|
|
if(cellType == EditCellType.MonsterArea)
|
|
|
|
|
|
{
|
|
|
|
|
|
go.transform.Find("Name").GetComponent<Text>().text = $"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>{_curMonsterPoint.areaIdx}";
|
|
|
|
|
|
go.transform.Find("ID").GetComponent<Text>().text = "ID:" + _curMonsterPoint.id.ToString();
|
|
|
|
|
|
go.transform.Find("Num").GetComponent<Text>().text = "Num:" + _curMonsterPoint.num.ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (cellType == EditCellType.FuBenArea)
|
|
|
|
|
|
{
|
|
|
|
|
|
go.transform.Find("Order").GetComponent<Text>().text = _curFuBenPoint.areaIdx.ToString();
|
|
|
|
|
|
go.transform.Find("ID").GetComponent<Text>().text = "ID:" + _curFuBenPoint.id.ToString();
|
|
|
|
|
|
go.transform.Find("Num").GetComponent<Text>().text = "Num:" + _curFuBenPoint.num.ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (cellType == EditCellType.JuBaoArea)
|
|
|
|
|
|
{
|
|
|
|
|
|
go.transform.Find("ID").GetComponent<Text>().text = "ID:" + _curJuBaoPoint.id.ToString();
|
|
|
|
|
|
//go.transform.Find("Num").GetComponent<Text>().text = "Num:" + _curJuBaoPoint.num.ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if(cellType == EditCellType.TriggerCell)
|
|
|
|
|
|
{
|
|
|
|
|
|
go.transform.GetChild(0).GetComponent<Text>().text = _curTriggerCenterPoint.text;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-19 01:31:00 +08:00
|
|
|
|
public int GetLayCellCount(CellType lay)
|
2025-06-14 13:46:24 +08:00
|
|
|
|
{
|
|
|
|
|
|
if(!_layCellsMap.ContainsKey(lay))
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
|
|
return _layCellsMap[lay].Count;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void CreateCells()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var key in _layCellsMap.Keys)
|
|
|
|
|
|
_layCellsMap[key].Clear();
|
|
|
|
|
|
|
|
|
|
|
|
Transform cellsTrans = UIWindow.Instance.mapTrans.Find("CellsNode");
|
|
|
|
|
|
if(cellsTrans == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
UIWindow.Instance.ShowMessage("û<><C3BB><EFBFBD>ҵ<EFBFBD>CellsNode<64>ڵ<EFBFBD>");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//<2F>п<EFBFBD><D0BF>ܴ<EFBFBD><DCB4><EFBFBD><EFBFBD>˻سǵ<D8B3><C7B5><EFBFBD>
|
|
|
|
|
|
if (cellsTrans.childCount > IGNORECELLSIZE)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetGameObjectActiveWithAllChild(cellsTrans, true);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void HideCells()
|
|
|
|
|
|
{
|
|
|
|
|
|
Transform cellsTrans = UIWindow.Instance.mapTrans.Find("CellsNode");
|
|
|
|
|
|
if (cellsTrans == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
UIWindow.Instance.ShowMessage("û<><C3BB><EFBFBD>ҵ<EFBFBD>CellsNode<64>ڵ<EFBFBD>");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SetGameObjectActiveWithAllChild(cellsTrans, false);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void ShowCells()
|
|
|
|
|
|
{
|
|
|
|
|
|
Transform cellsTrans = UIWindow.Instance.mapTrans.Find("CellsNode");
|
|
|
|
|
|
if (cellsTrans == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
UIWindow.Instance.ShowMessage("û<><C3BB><EFBFBD>ҵ<EFBFBD>CellsNode<64>ڵ<EFBFBD>");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SetGameObjectActiveWithAllChild(cellsTrans, true);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SetGameObjectActiveWithAllChild(Transform parentTrans, bool bActive)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < parentTrans.childCount; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
Transform trans = parentTrans.GetChild(i);
|
|
|
|
|
|
if (trans == null)
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
trans.gameObject.SetActive(bActive);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void RemoveAllCells()
|
|
|
|
|
|
{
|
|
|
|
|
|
Transform trans = UIWindow.Instance.mapTrans.Find("CellsNode");
|
|
|
|
|
|
if (trans == null)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
int count = trans.childCount;
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
DestroyImmediate(trans.GetChild(0).gameObject);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Cleanup();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public CellNode GetCell(int x, int y)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (x < 0 || y < 0)
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
|
|
if (y >= _cellRows || x >= _cellCols)
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
|
|
int index = y * _cellCols + x;
|
|
|
|
|
|
return cellsNode[index];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public CellNode GetCell(int index)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (index < 0)
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
|
|
if (index >= cellsNode.Length)
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
|
|
return cellsNode[index];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public CellNode GetCell(Vector3 pos)
|
|
|
|
|
|
{
|
|
|
|
|
|
int x = (int)pos.x / _cellWidth;
|
|
|
|
|
|
int y = (int)pos.z / _cellHeight;
|
|
|
|
|
|
|
|
|
|
|
|
return GetCell(x, y);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private CellType GetCellType(string cellName)
|
|
|
|
|
|
{
|
|
|
|
|
|
string[] tmp = cellName.Split('_');
|
|
|
|
|
|
if (tmp.Length != 2)
|
|
|
|
|
|
return CellType.None;
|
|
|
|
|
|
|
|
|
|
|
|
int x, y;
|
|
|
|
|
|
x = Convert.ToInt32(tmp[0]);
|
|
|
|
|
|
y = Convert.ToInt32(tmp[1]);
|
|
|
|
|
|
|
|
|
|
|
|
int index = y * _cellCols + x;
|
|
|
|
|
|
return cellsNode[index].cellType;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private CellType SetCellType(string cellName, CellType type)
|
|
|
|
|
|
{
|
|
|
|
|
|
string[] tmp = cellName.Split('_');
|
|
|
|
|
|
if (tmp.Length != 2)
|
|
|
|
|
|
return CellType.None;
|
|
|
|
|
|
|
|
|
|
|
|
int indexX, indexY;
|
|
|
|
|
|
indexX = Convert.ToInt32(tmp[0]);
|
|
|
|
|
|
indexY = Convert.ToInt32(tmp[1]);
|
|
|
|
|
|
|
|
|
|
|
|
return SetCellType(indexX, indexY, type);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private CellType SetCellType(int indexX, int indexY, CellType type)
|
|
|
|
|
|
{
|
|
|
|
|
|
CellNode cell = GetCell(indexX, indexY);
|
|
|
|
|
|
if (cell == null)
|
|
|
|
|
|
return CellType.None;
|
|
|
|
|
|
|
|
|
|
|
|
if (type == CellType.Safe)
|
|
|
|
|
|
cell.cellType |= CellType.Safe;
|
|
|
|
|
|
else
|
|
|
|
|
|
cell.cellType = type;
|
|
|
|
|
|
|
|
|
|
|
|
return cell.cellType;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ShowCellType(GameObject go, CellType type)
|
|
|
|
|
|
{
|
|
|
|
|
|
if ((type & CellType.Safe) == CellType.Safe)
|
|
|
|
|
|
{
|
|
|
|
|
|
var materials = new Material[2];
|
|
|
|
|
|
materials[1] = _cellDefaultMat;
|
|
|
|
|
|
go.GetComponent<MeshRenderer>().materials = materials;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ((type & CellType.Move) == CellType.Move)
|
|
|
|
|
|
{
|
|
|
|
|
|
go.GetComponent<MeshRenderer>().material = _cellMoveMat;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ((type & CellType.Obstacle) == CellType.Obstacle)
|
|
|
|
|
|
{
|
|
|
|
|
|
go.GetComponent<MeshRenderer>().material = _cellObsMat;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ((type & CellType.Hide) == CellType.Hide)
|
|
|
|
|
|
{
|
|
|
|
|
|
go.GetComponent<MeshRenderer>().material = _cellHideMat;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//if ((type & CellType.None) == CellType.None)
|
|
|
|
|
|
if (type == CellType.None)
|
|
|
|
|
|
{
|
|
|
|
|
|
go.GetComponent<MeshRenderer>().material = _cellDefaultMat;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void CalculationCells(int cellWidth, int cellHeight, int mapWidth, int mapHeight)
|
|
|
|
|
|
{
|
|
|
|
|
|
//RemoveAllCells();
|
|
|
|
|
|
|
|
|
|
|
|
_cellWidth = cellWidth;
|
|
|
|
|
|
_cellHeight = cellHeight;
|
|
|
|
|
|
this.mapWidth = mapWidth;
|
|
|
|
|
|
this.mapHeight = mapHeight;
|
|
|
|
|
|
|
|
|
|
|
|
_cellRows = mapHeight / _cellHeight; //<2F><> == <20><>
|
|
|
|
|
|
_cellCols = mapWidth / _cellWidth; //<2F><> == <20><>
|
|
|
|
|
|
|
|
|
|
|
|
cellsNode = new CellNode[_cellRows*_cellCols];
|
|
|
|
|
|
int index = 0;
|
|
|
|
|
|
|
|
|
|
|
|
for(int y=0; y < _cellRows; y++)
|
|
|
|
|
|
{
|
|
|
|
|
|
for(int x=0; x < _cellCols; x++)
|
|
|
|
|
|
{
|
|
|
|
|
|
index = y * _cellCols + x;
|
|
|
|
|
|
|
|
|
|
|
|
cellsNode[index] = new CellNode(x, y, index, CellType.Obstacle);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>layer<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2025-06-19 01:31:00 +08:00
|
|
|
|
public void AddLayerCell(GameObject go, CellType layer)
|
2025-06-14 13:46:24 +08:00
|
|
|
|
{
|
|
|
|
|
|
List<GameObject> cells = null;
|
|
|
|
|
|
|
2025-06-19 01:31:00 +08:00
|
|
|
|
if (((CellType)layer & CellType.Move) == CellType.Move)
|
2025-06-14 13:46:24 +08:00
|
|
|
|
{
|
2025-06-19 01:31:00 +08:00
|
|
|
|
cells = _layCellsMap[CellType.Move];
|
2025-06-14 13:46:24 +08:00
|
|
|
|
cells.Add(go);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-19 01:31:00 +08:00
|
|
|
|
if (((CellType)layer & CellType.Obstacle) == CellType.Obstacle)
|
2025-06-14 13:46:24 +08:00
|
|
|
|
{
|
2025-06-19 01:31:00 +08:00
|
|
|
|
cells = _layCellsMap[CellType.Obstacle];
|
2025-06-14 13:46:24 +08:00
|
|
|
|
cells.Add(go);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-19 01:31:00 +08:00
|
|
|
|
if (((CellType)layer & CellType.Hide) == CellType.Hide)
|
2025-06-14 13:46:24 +08:00
|
|
|
|
{
|
2025-06-19 01:31:00 +08:00
|
|
|
|
cells = _layCellsMap[CellType.Hide];
|
2025-06-14 13:46:24 +08:00
|
|
|
|
cells.Add(go);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-19 01:31:00 +08:00
|
|
|
|
if (((CellType)layer & CellType.Safe) == CellType.Safe)
|
2025-06-14 13:46:24 +08:00
|
|
|
|
{
|
2025-06-19 01:31:00 +08:00
|
|
|
|
cells = _layCellsMap[CellType.Safe];
|
2025-06-14 13:46:24 +08:00
|
|
|
|
cells.Add(go);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-19 01:31:00 +08:00
|
|
|
|
if (((CellType)layer & CellType.Stall) == CellType.Stall)
|
2025-06-14 13:46:24 +08:00
|
|
|
|
{
|
2025-06-19 01:31:00 +08:00
|
|
|
|
cells = _layCellsMap[CellType.Stall];
|
2025-06-14 13:46:24 +08:00
|
|
|
|
cells.Add(go);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-19 01:31:00 +08:00
|
|
|
|
if (((CellType)layer & CellType.Audio) == CellType.Audio)
|
2025-06-14 13:46:24 +08:00
|
|
|
|
{
|
2025-06-19 01:31:00 +08:00
|
|
|
|
cells = _layCellsMap[CellType.Audio];
|
2025-06-14 13:46:24 +08:00
|
|
|
|
cells.Add(go);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-19 01:31:00 +08:00
|
|
|
|
if (((CellType)layer & CellType.Trigger) == CellType.Trigger)
|
2025-06-14 13:46:24 +08:00
|
|
|
|
{
|
2025-06-19 01:31:00 +08:00
|
|
|
|
cells = _layCellsMap[CellType.Trigger];
|
2025-06-14 13:46:24 +08:00
|
|
|
|
cells.Add(go);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-19 01:31:00 +08:00
|
|
|
|
if (((CellType)layer & CellType.Monster) == CellType.Monster)
|
2025-06-14 13:46:24 +08:00
|
|
|
|
{
|
2025-06-19 01:31:00 +08:00
|
|
|
|
cells = _layCellsMap[CellType.Monster];
|
2025-06-14 13:46:24 +08:00
|
|
|
|
cells.Add(go);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void HideCellsExcludeLayers(int layers)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (layers == 0)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
2025-06-19 01:31:00 +08:00
|
|
|
|
if(layers < (int)CellType.Stall)
|
2025-06-14 13:46:24 +08:00
|
|
|
|
{
|
2025-06-19 01:31:00 +08:00
|
|
|
|
bool safeNoHide = ((CellType)layers & CellType.Safe) == CellType.Safe;
|
2025-06-14 13:46:24 +08:00
|
|
|
|
|
|
|
|
|
|
foreach (var layerCells in _layCellsMap)
|
|
|
|
|
|
{
|
2025-06-19 01:31:00 +08:00
|
|
|
|
safeNoHide = (layerCells.Key & CellType.Safe) == CellType.Safe;
|
2025-06-14 13:46:24 +08:00
|
|
|
|
if (((int)layerCells.Key & layers) != (int)layerCells.Key)
|
|
|
|
|
|
{
|
|
|
|
|
|
HideCellsWithLayer(layerCells.Key, layers, safeNoHide);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HideSpecialPoint(EditCellType.SellArea);
|
|
|
|
|
|
HideSpecialPoint(EditCellType.AudioTrigger);
|
|
|
|
|
|
HideSpecialPoint(EditCellType.TriggerCell);
|
|
|
|
|
|
HideSpecialPoint(EditCellType.ReliveCell);
|
|
|
|
|
|
HideSpecialPoint(EditCellType.FuBenArea);
|
|
|
|
|
|
HideSpecialPoint(EditCellType.MonsterArea);
|
|
|
|
|
|
HideSpecialPoint(EditCellType.JuBaoArea);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>и<EFBFBD><D0B8><EFBFBD>
|
|
|
|
|
|
HideCells();
|
|
|
|
|
|
|
2025-06-19 01:31:00 +08:00
|
|
|
|
if(((CellType)layers & CellType.Stall) == CellType.Stall)
|
2025-06-14 13:46:24 +08:00
|
|
|
|
{
|
|
|
|
|
|
ShowSpecialPoint(EditCellType.SellArea);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-19 01:31:00 +08:00
|
|
|
|
if (((CellType)layers & CellType.Audio) == CellType.Audio)
|
2025-06-14 13:46:24 +08:00
|
|
|
|
{
|
|
|
|
|
|
ShowSpecialPoint(EditCellType.AudioTrigger);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-19 01:31:00 +08:00
|
|
|
|
if (((CellType)layers & CellType.Trigger) == CellType.Trigger)
|
2025-06-14 13:46:24 +08:00
|
|
|
|
{
|
|
|
|
|
|
ShowSpecialPoint(EditCellType.TriggerCell);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-19 01:31:00 +08:00
|
|
|
|
if (((CellType)layers & CellType.Monster) == CellType.Monster)
|
2025-06-14 13:46:24 +08:00
|
|
|
|
{
|
|
|
|
|
|
ShowSpecialPoint(EditCellType.MonsterArea);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-19 01:31:00 +08:00
|
|
|
|
public void HideCellsWithLayer(CellType hideLayer, int showLayers, bool safeNoHide)
|
2025-06-14 13:46:24 +08:00
|
|
|
|
{
|
|
|
|
|
|
var cells = _layCellsMap[hideLayer];
|
|
|
|
|
|
foreach(var cell in cells)
|
|
|
|
|
|
{
|
|
|
|
|
|
CellType ct = GetCellType(cell.name);
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڰ<EFBFBD>ȫ<EFBFBD><C8AB>
|
|
|
|
|
|
if(safeNoHide)
|
|
|
|
|
|
{
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
if (((int)ct & (int)showLayers) == showLayers)
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD><EFBFBD>ڰ<EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǣ<EFBFBD><C7A3><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD>ȫ<EFBFBD><C8AB>
|
|
|
|
|
|
if (((int)ct & (int)showLayers) == showLayers)
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
//
|
|
|
|
|
|
// continue;
|
|
|
|
|
|
|
|
|
|
|
|
cell.SetActive(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void RemoveLayerCellInLayCellsMap(GameObject go)
|
|
|
|
|
|
{
|
|
|
|
|
|
List<GameObject> removeGos = new List<GameObject>();
|
|
|
|
|
|
foreach(var cells in _layCellsMap.Values)
|
|
|
|
|
|
{
|
|
|
|
|
|
GameObject f = cells.Find(cell => cell.name == go.name);
|
|
|
|
|
|
if (f == null)
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
removeGos.Add(f);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for(int i=0; i<removeGos.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void CleanSafe()
|
|
|
|
|
|
{
|
2025-06-19 01:31:00 +08:00
|
|
|
|
var cells = _layCellsMap[CellType.Safe];
|
2025-06-14 13:46:24 +08:00
|
|
|
|
if (cells == null)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
foreach(var cell in cells)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (cell.GetComponent<MeshRenderer>().materials.Length == 2)
|
|
|
|
|
|
cell.GetComponent<MeshRenderer>().materials = new Material[1];
|
|
|
|
|
|
|
|
|
|
|
|
CellType ct = GetCellType(cell.name);
|
|
|
|
|
|
CellType new_ct = (ct ^= CellType.Safe);
|
|
|
|
|
|
SetCellType(cell.name, new_ct);
|
|
|
|
|
|
ShowCellType(cell, new_ct);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
cells.Clear();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|