_xiaofang/xiaofang/Assets/Script/hylScripts/NPCController.cs

61 lines
1.6 KiB
C#
Raw Normal View History

2024-12-12 18:51:08 +08:00
using System.Collections;
using System.Collections.Generic;
using System.Xml.Linq;
2024-12-16 10:24:19 +08:00
using Unity.VisualScripting;
2024-12-12 18:51:08 +08:00
using UnityEngine;
using UnityEngine.UIElements;
public class NPCController : MonoBehaviour
{
public static NPCController instance;
2024-12-16 10:24:19 +08:00
public List<Dictionary<RecuseNpc,Vector3>> npcsList = new List<Dictionary<RecuseNpc, Vector3>>();//<2F><><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD>npc<70>Ľű<C4BD>
2024-12-12 18:51:08 +08:00
public GameObject npc;//npc<70><63><EFBFBD><EFBFBD>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD>
2024-12-23 09:55:15 +08:00
public List<Vector3> npcposition = new List<Vector3>();//<2F><><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD>npcλ<63><CEBB>
2024-12-12 18:51:08 +08:00
// Start is called before the first frame update
void Start()
{
instance = this;
}
2024-12-29 16:48:19 +08:00
public void INITNPCMOVE(Vector3 pos)
{
2024-12-29 17:50:20 +08:00
Debug.Log("11111111");
2024-12-29 16:48:19 +08:00
foreach (var npcDict in npcsList)
{
foreach (var kvp in npcDict)
{
RecuseNpc npc = kvp.Key;
npc.SetNpcDes(pos);
}
}
}
2024-12-12 18:51:08 +08:00
public void InitNPC(Vector3 v,NpcData npcData)
{
// ʹ<><CAB9>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD> NPC<50><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> trans λ<><CEBB>
2024-12-29 16:48:19 +08:00
GameObject go = GameObject.Instantiate(npc, v, Quaternion.identity); // ֱ<><D6B1>ָ<EFBFBD><D6B8>λ<EFBFBD>ú<EFBFBD><C3BA><EFBFBD>תc
2024-12-12 18:51:08 +08:00
RecuseNpc recuseNpc = go.GetComponent<RecuseNpc>();
recuseNpc.SetNPCInfo(npcData.UserId);//<2F><>ʼ<EFBFBD><CABC>npcid
2024-12-16 09:42:44 +08:00
Debug.Log(npcData.UserId);
2024-12-16 10:24:19 +08:00
Dictionary<RecuseNpc, Vector3> npcDict = new Dictionary<RecuseNpc, Vector3>
{
{ recuseNpc, v } // <20><> recuseNpc <20><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB> v <20><>Ϊ<EFBFBD><CEAA>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5>ֵ<EFBFBD><D6B5><EFBFBD>
};
// <20><><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>ӵ<EFBFBD> npcsList
npcsList.Add(npcDict);//<2F><><EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD>NPC<50>Ľű<C4BD><C5B1><EFBFBD><EFBFBD><EFBFBD>list<73><74><EFBFBD><EFBFBD>
2024-12-12 18:51:08 +08:00
}
// Update is called once per frame
void Update()
{
}
}