Compare commits
No commits in common. "be71fcb864506e1c1147813326c88a5218beeb9c" and "61643f2e488449e767c9e55f601a132b15610f26" have entirely different histories.
be71fcb864
...
61643f2e48
@ -13,6 +13,8 @@ public class test : MonoBehaviour
|
|||||||
{
|
{
|
||||||
public string token;
|
public string token;
|
||||||
public WEBScriptListener wEBScriptListener;
|
public WEBScriptListener wEBScriptListener;
|
||||||
|
public GameObject npc;
|
||||||
|
public Transform trans;
|
||||||
|
|
||||||
public class auth_login
|
public class auth_login
|
||||||
{
|
{
|
||||||
@ -513,20 +515,16 @@ public class test : MonoBehaviour
|
|||||||
float z = float.Parse(npcData.Z.ToString());
|
float z = float.Parse(npcData.Z.ToString());
|
||||||
Vector3 position = new Vector3(x, y, z);
|
Vector3 position = new Vector3(x, y, z);
|
||||||
|
|
||||||
NPCController.instance.InitNPC(position, npcData);
|
// 使用指定的世界坐标位置来实例化 NPC,而不是依赖 trans 位置
|
||||||
|
GameObject.Instantiate(npc, position, Quaternion.identity); // 直接指定位置和旋转
|
||||||
|
// Npc生成后调用选择路线,=================这里也会删掉,在等UI逻辑那边处理完
|
||||||
|
|
||||||
}
|
}
|
||||||
if(npcData.Type == 2)//npcÒÆ¶¯
|
if(npcData.Type == 2)//npcÒÆ¶¯
|
||||||
{
|
{
|
||||||
Vector3 v = new Vector3(-float.Parse(npcData.X.ToString()), float.Parse(npcData.Y.ToString()), float.Parse(npcData.Z.ToString()));
|
Vector3 v = new Vector3(-float.Parse(npcData.X.ToString()), float.Parse(npcData.Y.ToString()), float.Parse(npcData.Z.ToString()));
|
||||||
foreach(var item in NPCController.instance.npcsList)
|
RecuseNpc.instance.SetNpcDes(v);
|
||||||
{
|
|
||||||
if(npcData.UserId == item.npcId)
|
|
||||||
{
|
|
||||||
item.SetNpcDes(v);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//npc.transform.name = npcData.UserId;
|
//npc.transform.name = npcData.UserId;
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UIElements;
|
|
||||||
|
|
||||||
public class NPCController : MonoBehaviour
|
|
||||||
{
|
|
||||||
public static NPCController instance;
|
|
||||||
|
|
||||||
public List<RecuseNpc> npcsList = new List<RecuseNpc>();//存放每个生成的npc的脚本
|
|
||||||
public GameObject npc;//npc人物预制体
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Start is called before the first frame update
|
|
||||||
void Start()
|
|
||||||
{
|
|
||||||
instance = this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void InitNPC(Vector3 v,NpcData npcData)
|
|
||||||
{
|
|
||||||
// 使用指定的世界坐标位置来实例化 NPC,而不是依赖 trans 位置
|
|
||||||
GameObject go = GameObject.Instantiate(npc, v, Quaternion.identity); // 直接指定位置和旋转
|
|
||||||
RecuseNpc recuseNpc = go.GetComponent<RecuseNpc>();
|
|
||||||
recuseNpc.SetNPCInfo(npcData.UserId);//初始化npcid
|
|
||||||
npcsList.Add(recuseNpc);//将生成的NPC的脚本加入list存放
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Update is called once per frame
|
|
||||||
void Update()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 1a829b8d12d88e14487451b9c601ab85
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -12,8 +12,6 @@ public enum Npcstate
|
|||||||
|
|
||||||
public class RecuseNpc : MonoBehaviour
|
public class RecuseNpc : MonoBehaviour
|
||||||
{
|
{
|
||||||
public string npcId;
|
|
||||||
|
|
||||||
public static RecuseNpc instance;
|
public static RecuseNpc instance;
|
||||||
|
|
||||||
private Button recusebtn;
|
private Button recusebtn;
|
||||||
@ -53,11 +51,6 @@ public class RecuseNpc : MonoBehaviour
|
|||||||
recusebtn.gameObject.SetActive(false);
|
recusebtn.gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetNPCInfo(string id)
|
|
||||||
{
|
|
||||||
npcId = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
//设置NPC的状态
|
//设置NPC的状态
|
||||||
public void Setnpcstate()//点击救援按钮执行完动作后对按钮进行隐藏
|
public void Setnpcstate()//点击救援按钮执行完动作后对按钮进行隐藏
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user