/// <summary> /// 创建npc /// </summary> public static void CreateNpc() { string[] npcArray = AnalyXml.AnalySceneOfNpc(Game.CurrentSceneName); for (int i = 0; i < npcArray.Length; i++) { if (npcArray[i] != "") { GameObject go = Resources.Load <GameObject>(Consts.PrefabDir + npcArray[i]); GameObject clone = GameObject.Instantiate(go); clone.transform.parent = BgTrans; //clone.transform.localScale = new Vector3(1, 1, 1); clone.name = npcArray[i]; clone.GetComponent <NpcAnimation>().GetAnimTexture(); if (npcDic.ContainsKey(npcArray[i])) {//如果已经创建,直接填充 npcDic[npcArray[i]].Go = clone; } else {//添加到字典中 npcDic.Add(npcArray[i], InitNpcData(clone)); } } } }
// Use this for initialization void Start() { _instance = this; playerGo = GameObject.FindGameObjectWithTag("Player"); AnalyXml.AnalyCameraPos(Game.CurrentSceneName); }
/// <summary> /// 进入场景前检验是否有剧情 /// </summary> public static void CheckStoryBeforeScene() { StoryStep step = PlayerPropertyManager.playerData.DoingStep; if (step == StoryStep.Step0) {//触发第一阶段剧情 AnalyXml.AnalyNpcBehavior("Player", step); } }
/// <summary> /// 检测玩家是否能与npc聊天,返回true表示可以聊天 /// </summary> public bool TryWithNpcDialogue() { if (GetNpcGoByRay()) {//如果射线接触到NPC,开始获取这个npc的Xml指令 //指定npc朝向 npcGo.GetComponent <AIAttribute>().PlayerTouchYou(dir); StoryStep step = npcGo.GetComponent <AIAttribute>().GetAIData().DoingStep; AnalyXml.AnalyNpcBehavior(npcGo.name, step); return(true); } return(false); }