protected void collisionWalk(Collision collision) { GameObject gameObject = collision.gameObject; if (gameObject.tag == "NPC") { NPCCtrl ctrl = gameObject.GetComponent <NPCCtrl>(); if (ctrl.canChat()) { this.__npcFriend = gameObject; } } if (gameObject.tag == "Bar") { this.__barFound = gameObject; } else { this.__direction = this.__direction * -1; this.__direction.x = Random.Range(0.0f, 1.0f) * Mathf.Sign(this.__direction.x); this.__direction.y = 0.0f; this.__direction.z = Random.Range(0.0f, 1.0f) * Mathf.Sign(this.__direction.z); this.__direction = this.__direction.normalized; } }
/// <summary> /// 初始化NPC /// </summary> /// <returns></returns> private IEnumerator InitNPC() { yield return(null); List <WorldMapNpcData> npcList = WorldMapDBModel.Instance.Get(SceneMgr.Instance.CurWorldMapSceneId).NPCDataList; if (npcList != null && npcList.Count > 0) { for (int i = 0; i < npcList.Count; i++) { NPCEntity entity = NPCDBModel.Instance.Get(npcList[i].NPCId); GameObject go = RoleMgr.Instance.LoadNpc(entity.PrefabName); go.transform.position = npcList[i].NpcBornPoint; go.transform.eulerAngles = new Vector3(0, npcList[i].NpCBornRotateY, 0); NPCCtrl npc = go.GetComponent <NPCCtrl>(); npc.Init(npcList[i]); } } }