添加
This commit is contained in:
@@ -6,6 +6,7 @@ using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
using static MapManager;
|
||||
|
||||
public class UIMonsterItem : MonoBehaviour
|
||||
{
|
||||
@@ -44,6 +45,19 @@ public class UIMonsterItem : MonoBehaviour
|
||||
btnClickSelf.onClick.AddListener(OnClickSelf);
|
||||
btnCopy.onClick.AddListener(OnCopySelf);
|
||||
btnHide.onClick.AddListener(OnHideSelf);
|
||||
txtPos.onEndEdit.AddListener(OnEndEditPos);
|
||||
}
|
||||
|
||||
private void OnEndEditPos(string arg0)
|
||||
{
|
||||
if (!UtilityClass.IsPosValidFormat(arg0))
|
||||
{
|
||||
UIWindow.Instance.ShowMessage("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7>ʽ x,y");
|
||||
txtPos.text = $"{monster.pos.x},{monster.pos.y}";
|
||||
return;
|
||||
}
|
||||
monster.pos = UtilityClass.GetVector2Pos(arg0);
|
||||
MapManager.Instance.CreateSpecialPoint(monster.pos.x, monster.pos.y, MapManager.EditCellType.MonsterArea);
|
||||
}
|
||||
|
||||
//public void SetItem(int idx, MonstersConfig.MonsterConfig m)
|
||||
@@ -70,6 +84,10 @@ public class UIMonsterItem : MonoBehaviour
|
||||
txtMonsterID.text = monster.id.ToString();
|
||||
txtName.text = monster.id.ToString();
|
||||
paths = monster.paths;
|
||||
txtPos.text = monster.pos.ToString();
|
||||
//ˢ<>³<EFBFBD><C2B3><EFBFBD><EFBFBD>еĶ<D0B5><C4B6><EFBFBD>
|
||||
MapManager.Instance.SetMonsterPoint(monster.itemIdx, monster.radius, monster.id, monster.num);
|
||||
MapManager.Instance.CreateSpecialPoint(monster.pos.x, monster.pos.y, EditCellType.MonsterArea);
|
||||
}
|
||||
|
||||
public void SetGroup(int group)
|
||||
@@ -118,6 +136,7 @@ public class UIMonsterItem : MonoBehaviour
|
||||
MapManager.Instance.SetEditCellType(MapManager.EditCellType.MonsterArea);
|
||||
}
|
||||
|
||||
|
||||
private void OnPathInputFieldClicked(BaseEventData data)
|
||||
{
|
||||
UIWindow.Instance.uiMonstersPanel.curActiveInput = data.selectedObject.GetComponent<InputField>();
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
|
||||
/*
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
||||
@@ -51,6 +52,50 @@ public class UIMonsterPanel : MonoBehaviour
|
||||
btnClose.onClick.AddListener(OnClickClose);
|
||||
btnAddGroup.onClick.AddListener(OnAddGroup);
|
||||
btnDeleteGroup.onClick.AddListener(OnDeleteGroup);
|
||||
txtMonsterID.onEndEdit.AddListener(OnEditorMonsterId);
|
||||
txtName.onEndEdit.AddListener(OnEditorMonsterName);
|
||||
txtRadius.onEndEdit.AddListener(OnEditorMonsterRadius);
|
||||
txtCount.onEndEdit.AddListener(OnEditorMonsterCount);
|
||||
}
|
||||
|
||||
private void OnEditorMonsterCount(string arg0)
|
||||
{
|
||||
if (!int.TryParse(arg0, out var intValue))
|
||||
{
|
||||
UIWindow.Instance.ShowMessage("<22><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>ȷ");
|
||||
return;
|
||||
}
|
||||
_curMonsterItem.monster.id = intValue;
|
||||
_curMonsterItem.RefreshItem();
|
||||
}
|
||||
|
||||
private void OnEditorMonsterRadius(string arg0)
|
||||
{
|
||||
if (!int.TryParse(arg0, out var intValue))
|
||||
{
|
||||
UIWindow.Instance.ShowMessage("<22><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>ȷ");
|
||||
return;
|
||||
}
|
||||
_curMonsterItem.monster.radius = intValue;
|
||||
_curMonsterItem.RefreshItem();
|
||||
}
|
||||
|
||||
private void OnEditorMonsterName(string arg0)
|
||||
{
|
||||
if (_curMonsterItem == null) return;
|
||||
_curMonsterItem.RefreshItem();
|
||||
}
|
||||
|
||||
private void OnEditorMonsterId(string arg0)
|
||||
{
|
||||
if (_curMonsterItem == null) return;
|
||||
if (!int.TryParse(arg0, out var intValue))
|
||||
{
|
||||
UIWindow.Instance.ShowMessage("<22><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>ȷ");
|
||||
return;
|
||||
}
|
||||
_curMonsterItem.monster.id = intValue;
|
||||
_curMonsterItem.RefreshItem();
|
||||
}
|
||||
|
||||
private void OnClickClose()
|
||||
@@ -159,6 +204,10 @@ public class UIMonsterPanel : MonoBehaviour
|
||||
|
||||
MonstersConfig.MonsterConfig monster = new MonstersConfig.MonsterConfig();
|
||||
monster.itemIdx = ++itemIdx;
|
||||
monster.radius = 1;
|
||||
monster.id = 0;
|
||||
monster.num = 0;
|
||||
monster.pos = MapManager.Instance.map.selector.getMapGrid(Camera.main.transform.position);
|
||||
item.SetItem(monster);
|
||||
item.OnClick = OnClickItem;
|
||||
item.OnCopyItem = OnCopyItem;
|
||||
|
||||
@@ -1,142 +0,0 @@
|
||||
using HxGame.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class UIMonstersPanel_old : MonoBehaviour
|
||||
{
|
||||
[HideInInspector]
|
||||
public InputField curActiveInput;
|
||||
|
||||
[HideInInspector]
|
||||
public List<string> curActiveList;
|
||||
|
||||
public Transform itemParent;
|
||||
public Button btnAdd;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
btnAdd.onClick.AddListener(AddItem);
|
||||
}
|
||||
|
||||
void AddItem()
|
||||
{
|
||||
UnityEngine.Object obj = Resources.Load("Prefabs/monsterItem");
|
||||
if (obj == null)
|
||||
{
|
||||
UIWindow.Instance.ShowMessage("monsterItem.prefabʧ<62><CAA7>");
|
||||
return;
|
||||
}
|
||||
|
||||
GameObject go = Instantiate(obj) as GameObject; ;
|
||||
go.transform.SetParent(itemParent, false);
|
||||
UIMonsterItem_old item = go.GetComponent<UIMonsterItem_old>();
|
||||
item.itemIdx = itemParent.childCount;
|
||||
}
|
||||
|
||||
public void AddItem(HxGame.Data.MonstersConfig.MonsterConfig monster)
|
||||
{
|
||||
UnityEngine.Object obj = Resources.Load("Prefabs/monsterItem");
|
||||
if (obj == null)
|
||||
{
|
||||
UIWindow.Instance.ShowMessage("monsterItem.prefabʧ<62><CAA7>");
|
||||
return;
|
||||
}
|
||||
|
||||
GameObject go = Instantiate(obj) as GameObject; ;
|
||||
go.transform.SetParent(itemParent, false);
|
||||
UIMonsterItem_old item = go.GetComponent<UIMonsterItem_old>();
|
||||
item.itemIdx = itemParent.childCount;
|
||||
item.txtID.text = monster.id.ToString();
|
||||
item.dropType.value = (int)monster.createMode;
|
||||
item.dropPatrol.value = (int)monster.patrolMode;
|
||||
item.txtPos.text = $"{monster.pos.x},{monster.pos.y}";
|
||||
item.txtRadius.text = monster.radius.ToString();
|
||||
item.txtNum.text = monster.num.ToString();
|
||||
|
||||
if(monster.createMode == CreateMonsterMode.Death)
|
||||
item.txtTime.text = monster.delayTime.ToString();
|
||||
else
|
||||
item.txtTime.text = monster.strTime;
|
||||
item.paths = monster.paths;
|
||||
|
||||
MapManager.Instance.SetMonsterPoint(item.itemIdx,monster.radius, monster.id, monster.num);
|
||||
MapManager.Instance.CreateSpecialPoint(monster.pos.x, monster.pos.y, MapManager.EditCellType.MonsterArea);
|
||||
|
||||
MapManager.Instance.SetCurMonsterPathIdx(item.pathIdx);
|
||||
for (int i = 0; i < item.paths.Count; i++)
|
||||
{
|
||||
string[] pos = item.paths[i].Split('_');
|
||||
int x = Convert.ToInt32(pos[0]);
|
||||
int y = Convert.ToInt32(pos[1]);
|
||||
item.txtPath.text += $"[{item.paths[i].Replace('_', ',')}]";
|
||||
MapManager.Instance.AddMonsterPathSize();
|
||||
MapManager.Instance.CreateSpecialPoint(x, y, MapManager.EditCellType.MonsterPath);
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveMonsterConfig()
|
||||
{
|
||||
//ˢ<><CBA2>
|
||||
int x, y;
|
||||
MonstersConfig mc = new MonstersConfig();
|
||||
|
||||
for (int i = 0; i < itemParent.childCount; i++)
|
||||
{
|
||||
UIMonsterItem_old item = itemParent.GetChild(i).GetComponent<UIMonsterItem_old>();
|
||||
if (!item.CheckValid())
|
||||
return;
|
||||
|
||||
MonstersConfig.MonsterConfig monster = new HxGame.Data.MonstersConfig.MonsterConfig();
|
||||
monster.id = Convert.ToInt32(item.txtID.text);
|
||||
monster.createMode = (CreateMonsterMode)item.dropType.value;
|
||||
monster.patrolMode = (PatrolMode)item.dropPatrol.value;
|
||||
|
||||
string[] tmp = item.txtPos.text.Split(',');
|
||||
if (tmp.Length != 2)
|
||||
return;
|
||||
|
||||
x = Convert.ToInt32(tmp[0]);
|
||||
y = Convert.ToInt32(tmp[1]);
|
||||
monster.pos = new Vector2Int(x, y);
|
||||
monster.radius = Convert.ToInt32(item.txtRadius.text);
|
||||
monster.num = Convert.ToInt32(item.txtNum.text);
|
||||
|
||||
if(monster.createMode == CreateMonsterMode.Death)
|
||||
monster.delayTime = Convert.ToInt32(item.txtTime.text);
|
||||
else
|
||||
monster.strTime = item.txtTime.text;
|
||||
|
||||
monster.paths = item.paths;
|
||||
mc.monsterConfigs.Add(monster);
|
||||
}
|
||||
|
||||
int mapId = MapManager.Instance._curOpenMapId;
|
||||
mc.SaveXML(mapId);
|
||||
}
|
||||
|
||||
public void LoadMonsterConfig(int mapId)
|
||||
{
|
||||
MonstersConfig mc = new MonstersConfig();
|
||||
if (!mc.LoadXML(mapId))
|
||||
return;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>
|
||||
for (int i = 0; i < mc.monsterConfigs.Count; i++)
|
||||
{
|
||||
MonstersConfig.MonsterConfig monster = mc.monsterConfigs[i];
|
||||
AddItem(monster);
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveAll()
|
||||
{
|
||||
int count = itemParent.childCount;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
DestroyImmediate(itemParent.GetChild(0).gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 16fab2e09ef3ffa4582b982dc9775080
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user