添加
This commit is contained in:
@@ -3,7 +3,10 @@ using HxGame.Data;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public partial class MapManager : MonoBehaviour
|
||||
@@ -83,12 +86,6 @@ public partial class MapManager : MonoBehaviour
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -148,6 +145,7 @@ public partial class MapManager : MonoBehaviour
|
||||
_curPathNodePointIdx = idx;
|
||||
}
|
||||
|
||||
|
||||
//<2F><>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>
|
||||
public void SetCurAudioTriggerCenterPoint(int idx, int radius)
|
||||
{
|
||||
@@ -401,13 +399,14 @@ public partial class MapManager : MonoBehaviour
|
||||
|
||||
return cellName;
|
||||
}
|
||||
|
||||
|
||||
public void ShowSpecialPoint(EditCellType cellType)
|
||||
{
|
||||
int size = 0;
|
||||
string cellName = GetSpecialName(cellType, out size);
|
||||
|
||||
if(cellType == EditCellType.MonsterArea)
|
||||
//TODO tb <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
SetEditCellType(cellType);
|
||||
if (cellType == EditCellType.MonsterArea)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -471,15 +470,11 @@ public partial class MapManager : MonoBehaviour
|
||||
DestroyImmediate(mapAreaParent.Find(cellName).gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void CreateSpecialPoint(int x, int y, EditCellType cellType)
|
||||
{
|
||||
if (_curOpenMapId <= 0)
|
||||
return;
|
||||
UnityEngine.Object obj = null;
|
||||
|
||||
|
||||
if (cellType < EditCellType.AudioTrigger)
|
||||
obj = null;
|
||||
else if (cellType == EditCellType.AudioTrigger)
|
||||
@@ -500,66 +495,57 @@ public partial class MapManager : MonoBehaviour
|
||||
UIWindow.Instance.ShowMessage("<22><><EFBFBD><EFBFBD>cell.prefabʧ<62><CAA7>");
|
||||
return;
|
||||
}
|
||||
|
||||
string cellName = string.Empty;
|
||||
Material mat = null;
|
||||
Vector3 localScale = Vector3.zero;
|
||||
|
||||
int Idx = 0;
|
||||
switch (cellType)
|
||||
{
|
||||
case EditCellType.ReturnCell:
|
||||
cellName = "<22>سǵ<D8B3>";
|
||||
mat = _cellReturnMat;
|
||||
break;
|
||||
case EditCellType.TeleportCell:
|
||||
cellName = $"<22><><EFBFBD>͵<EFBFBD>{_curTeleportPointIdx}";
|
||||
mat = _cellTeleportMat;
|
||||
Idx = _curTeleportPointIdx;
|
||||
break;
|
||||
case EditCellType.NpcCell:
|
||||
cellName = $"Npc{_curNpcPointIdx}";
|
||||
mat = _cellNpcMat;
|
||||
Idx = _curNpcPointIdx;
|
||||
break;
|
||||
case EditCellType.PathNodeCell:
|
||||
cellName = $"PathNode{_curPathNodePointIdx}";
|
||||
mat = _cellPathNodeMat;
|
||||
Idx = _curPathNodePointIdx;
|
||||
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);
|
||||
Idx = _curAudioTriggerCenterPoint.areaIdx;
|
||||
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);
|
||||
Idx = _curTriggerCenterPoint.areaIdx;
|
||||
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);
|
||||
Idx = _curReliveCenterPoint.areaIdx;
|
||||
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);
|
||||
Idx = _curMonsterPoint.areaIdx;
|
||||
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);
|
||||
Idx = _curMonsterPoint.areaIdx;
|
||||
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);
|
||||
Idx = _curJuBaoPoint.areaIdx;
|
||||
break;
|
||||
case EditCellType.NpcPath:
|
||||
cellName = $"NpcPath{_curNpcPointIdx}{GetCurNpcPathIdx()}";
|
||||
mat = _cellPathNodeMat;
|
||||
Idx = _curNpcPointIdx;
|
||||
break;
|
||||
case EditCellType.MonsterPath:
|
||||
cellName = $"MonsterPath{_curMonsterPoint.areaIdx}{GetCurMonsterPathIdx()}";
|
||||
mat = _cellPathNodeMat;
|
||||
Idx = _curMonsterPoint.areaIdx;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -572,42 +558,34 @@ public partial class MapManager : MonoBehaviour
|
||||
{
|
||||
go = Instantiate(obj) as GameObject;
|
||||
go.transform.SetParent(mapAreaParent, false);
|
||||
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);
|
||||
var sceneArea = go.GetComponent<SceneArea>();
|
||||
sceneArea.SetSceneAreaData(cellType, Idx);
|
||||
sceneArea.SetAreaPos(new Vector2Int(x, 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();
|
||||
go.transform.Find("Name").GetComponent<TextMeshPro>().text = $"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>{_curMonsterPoint.areaIdx}";
|
||||
go.transform.Find("ID").GetComponent<TextMeshPro>().text = "ID:" + _curMonsterPoint.id.ToString();
|
||||
go.transform.Find("Num").GetComponent<TextMeshPro>().text = "Num:" + _curMonsterPoint.num.ToString();
|
||||
float scaleX = MapManager.Instance.map.sideWidth * _curMonsterPoint.radius * 2;
|
||||
float scaleY = MapManager.Instance.map.sideHeight * _curMonsterPoint.radius * 2;
|
||||
go.transform.localScale = new Vector3(scaleX,scaleY,1);
|
||||
}
|
||||
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();
|
||||
go.transform.Find("Order").GetComponent<TextMeshPro>().text = _curFuBenPoint.areaIdx.ToString();
|
||||
go.transform.Find("ID").GetComponent<TextMeshPro>().text = "ID:" + _curFuBenPoint.id.ToString();
|
||||
go.transform.Find("Num").GetComponent<TextMeshPro>().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();
|
||||
go.transform.Find("ID").GetComponent<TextMeshPro>().text = "ID:" + _curJuBaoPoint.id.ToString();
|
||||
}
|
||||
else if(cellType == EditCellType.TriggerCell)
|
||||
{
|
||||
go.transform.GetChild(0).GetComponent<Text>().text = _curTriggerCenterPoint.text;
|
||||
go.transform.GetChild(0).GetComponent<TextMeshPro>().text = _curTriggerCenterPoint.text;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int GetLayCellCount(CellType lay)
|
||||
@@ -991,4 +969,51 @@ public partial class MapManager : MonoBehaviour
|
||||
|
||||
cells.Clear();
|
||||
}
|
||||
public bool isDragging = false;
|
||||
public Vector3 downPos;
|
||||
public SceneArea currentComponent;
|
||||
private void UpdateCellPos()
|
||||
{
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
if (EventSystem.current.IsPointerOverGameObject())
|
||||
return;
|
||||
int hitLayer = (1 << LayerMask.NameToLayer("MapCell"));
|
||||
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||||
Vector2 rayOrigin = ray.origin;
|
||||
Vector2 rayDirection = ray.direction;
|
||||
|
||||
RaycastHit2D hit = Physics2D.Raycast(rayOrigin, rayDirection, Mathf.Infinity, hitLayer);
|
||||
if (hit.collider != null)
|
||||
{
|
||||
var mouseComponent = hit.collider.transform.GetComponent<SceneArea>();
|
||||
if (mouseComponent != null)
|
||||
{
|
||||
if (mouseComponent.editCellType != _curEditCellType)
|
||||
return;
|
||||
mouseComponent.OnPointerClick();
|
||||
currentComponent = mouseComponent;
|
||||
}
|
||||
downPos = Input.mousePosition;
|
||||
}
|
||||
}
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ק
|
||||
if (Input.GetMouseButton(0))
|
||||
{
|
||||
if (Input.mousePosition != downPos || isDragging)
|
||||
{
|
||||
isDragging = true;
|
||||
// <20><><EFBFBD><EFBFBD> AreaComponent <20><><EFBFBD><EFBFBD>ק<EFBFBD><D7A7><EFBFBD><EFBFBD>
|
||||
currentComponent?.OnPointerDrag(Input.mousePosition);
|
||||
}
|
||||
|
||||
}
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>
|
||||
if (Input.GetMouseButtonUp(0))
|
||||
{
|
||||
currentComponent?.OnPointerUp();
|
||||
isDragging = false;
|
||||
currentComponent = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user