public UnitID CreateNPC(Neptune.NPC npcInfo, Actor parent = null) { if (npcInfo == null) { GameDebug.LogError("Error in create npc, npc info is null!!!"); return(null); } Vector3 bornPos = npcInfo.Position; NpcDefine npcDefine = NpcHelper.MakeNpcDefine((uint)npcInfo.ExcelId); if (npcDefine == null) { GameDebug.LogError("Error in create npc, npc define is null!!!"); return(null); } // 护送任务NPC可以创建多个 if (GetNpcByNpcId((uint)npcInfo.Id) != null && npcDefine.Function != NpcDefine.EFunction.ESCORT) { return(null); } uint uuid = GetAvailableUUId(npcInfo, npcDefine); DBActor dbActor = DBManager.GetInstance().GetDB <DBActor>(); DBActor.ActorData actorData = dbActor.GetData((uint)npcDefine.ActorId); bornPos = RoleHelp.GetPositionInScene((uint)npcDefine.ActorId, npcInfo.Position.x, npcInfo.Position.z); if (npcInfo.Id >= 300) { GameDebug.LogError("npcInfo.Id is too large! " + npcInfo.Id); } xc.UnitCacheInfo initData = new xc.UnitCacheInfo(EUnitType.UNITTYPE_NPC, uuid); initData.ClientNpc = npcInfo; initData.ClientNpcDefine = NpcHelper.MakeNpcDefine((uint)(npcInfo.ExcelId)); initData.CacheType = xc.UnitCacheInfo.EType.ET_Create; initData.PosBorn = bornPos; initData.ParentActor = parent; // 如果有父角色,则出生在父角色附近的一个随机位置 if (parent != null) { Vector3 pos = AIHelper.GetActorRangeRandomPosition(parent, 1f, 2f); bool result = false; initData.PosBorn = InstanceHelper.ClampInWalkableRange(pos, pos, out result); } mCreatings.Add(initData.UnitID.obj_idx); ActorManager.Instance.PushUnitCacheData(initData); return(initData.UnitID); }
/// <summary> /// 执行触碰结婚npc,是结婚npc则返回true /// </summary> public static bool ProcessTouchMarryNpc(NpcPlayer npcPlayer) { if (NpcHelper.NpcCanOpenMarryWin((uint)npcPlayer.NpcData.Id) == true) { ui.ugui.UIManager.Instance.ShowSysWindow("UIMarryNPCWindow"); return(true); } return(false); }
/// <summary> /// 获取第index个的跟随NPC的名字 /// </summary> /// <param name="index"></param> /// <returns></returns> public string GetFollowNpcName(int index) { if (FollowNpcs != null && FollowNpcs.Count > index) { NpcScenePosition npc = FollowNpcs[index]; uint instanceId = npc.SceneId; uint npcId = npc.NpcId; return(NpcHelper.GetNpcName(instanceId, npcId)); } return(string.Empty); }
public static string GetNpcName(uint instanceId, uint npcJsonId) { if (instanceId == 0) { instanceId = SceneHelp.Instance.CurSceneID; } Neptune.Data levelData = xc.Dungeon.LevelManager.Instance.LoadLevelFileTemporary(SceneHelp.GetFirstStageId(instanceId)); if (levelData != null) { Neptune.NPC npcInfo = levelData.GetNode <Neptune.NPC>((int)npcJsonId); if (npcInfo != null) { return(RoleHelp.GetActorName(NpcHelper.MakeNpcDefine(npcInfo.ExcelId).ActorId)); } } return(string.Empty); }
public string GetStepFixedDescription(int stepIndex) { var step = GetStep(stepIndex); if (step == null || step.Description == null) { return(string.Empty); } string result = DBConstText.GetText(step.Description); // 对目标名字进行替换 if (step.Goal == GameConst.GOAL_TALK) { result = string.Format(result, NpcHelper.GetNpcName(step.InstanceId, step.NpcId)); } else if (step.Goal == GameConst.GOAL_KILL_MON) { result = string.Format(result, RoleHelp.GetActorName(step.MonsterId)); } else if (step.Goal == GameConst.GOAL_INTERACT) { result = string.Format(result, RoleHelp.GetActorName(NpcHelper.MakeNpcDefine(step.NpcId).ActorId)); } else if (step.Goal == GameConst.GOAL_KILL_COLLECT) { result = string.Format(result, GoodsHelper.GetGoodsOriginalNameByTypeId(step.GoodsId)); } else if (step.Goal == GameConst.GOAL_COLLECT_GOODS) { if (step.MinWorldBossSpecialMonId > 0 && step.MaxWorldBossSpecialMonId > 0) { DBSpecialMon dbSpecialMon = DBManager.Instance.GetDB <DBSpecialMon>(); uint minLevel = dbSpecialMon.GetSpecialMonLevel(step.MinWorldBossSpecialMonId); uint maxLevel = dbSpecialMon.GetSpecialMonLevel(step.MaxWorldBossSpecialMonId); result = string.Format(result, minLevel, maxLevel, GoodsHelper.GetGoodsOriginalNameByTypeId(step.GoodsId)); } else { result = string.Format(result, GoodsHelper.GetGoodsOriginalNameByTypeId(step.GoodsId)); } } else if (step.Goal == GameConst.GOAL_WAR_WIN || step.Goal == GameConst.GOAL_WAR_ENTER || step.Goal == GameConst.GOAL_WAR_GRADE) { result = string.Format(result, InstanceHelper.GetInstanceName(step.InstanceId2)); } else if (step.Goal == GameConst.GOAL_EQUIP_SUBMIT) { result = string.Format(result, GoodsHelper.GetGoodsColorName(step.EquipColor) + xc.Equip.EquipHelper.GetEquipLvStepName(step.EquipLvStep)); } else if (step.Goal == GameConst.GOAL_SECRET_AREA) { result = string.Format(result, InstanceHelper.GetKungfuGodInstanceName(step.SecretAreaId)); } else if (step.Goal == GameConst.GOAL_TRIGRAM) { result = string.Format(result, TaskHelper.GetTrigramName(step.TrigramId)); } else if (step.Goal == GameConst.GOAL_EQUIP_WEAR) { result = string.Format(result, GoodsHelper.GetGoodsColorName(step.EquipColor) + xc.Equip.EquipHelper.GetEquipLvStepName(step.EquipLvStep)); } else if (step.Goal == GameConst.GOAL_EQUIP_STRENGTH) { result = string.Format(result, step.EquipStrenghtLv); } else if (step.Goal == GameConst.GOAL_EQUIP_GEM) { } else if (step.Goal == GameConst.GOAL_PET_LV) { result = string.Format(result, step.PetLv); } else if (step.Goal == GameConst.GOAL_GROW_LV) { } else if (step.Goal == GameConst.GOAL_STIGMA_LV) { DBStigma dbStigma = DBManager.Instance.GetDB <DBStigma>(); DBStigma.DBStigmaInfo stigmaInfo = dbStigma.GetOneDBStigmaInfo(step.StigmaId); if (stigmaInfo != null) { string name = stigmaInfo.Name; result = string.Format(result, name); } else { GameDebug.LogError("GetStepFixedDescription error, can not find stigma info by id " + step.StigmaId); } } else if (step.Goal == GameConst.GOAL_DRAGON_SOUL) { result = string.Format(result, step.ExpectResult); } else if (step.Goal == GameConst.GOAL_EQUIP_STRENGTH_TLV) { result = string.Format(result, step.EquipStrenghtLv); } else if (step.Goal == GameConst.GOAL_KILL_BOSS) { if (step.MonsterLevel > 0) { result = string.Format(result, step.ExpectResult, step.MonsterLevel); } else { result = string.Format(result, step.ExpectResult); } } else if (step.Goal == GameConst.GOAL_LIGHT_EQUIP) { List <string> names = DBManager.Instance.QuerySqliteField <string>(GlobalConfig.DBFile, "data_light_equip", "id", step.LightEquipLv.ToString(), "desc"); if (names != null && names.Count > 0) { result = string.Format(result, names[0]); } } else { result = TaskHelper.GetStepFixedDescriptionByLua(step); } return(result); }
void BuildTaskStateIcon(Task task) { string iconPrefabPath = ""; NpcPlayer mNpc = (NpcPlayer)mOwner; if (mNpc != null) { if (NpcHelper.NpcCanAcceptBountyTask((uint)mNpc.NpcData.Id) == true) { iconPrefabPath = TASK_ACCEPT_STATE_ICON_PREFAB; } else if (NpcHelper.NpcCanAcceptGuildTask((uint)mNpc.NpcData.Id) == true) { iconPrefabPath = TASK_ACCEPT_STATE_ICON_PREFAB; } else if (NpcHelper.NpcCanAcceptEscortTask((uint)mNpc.NpcData.Id) == true) { iconPrefabPath = TASK_ACCEPT_STATE_ICON_PREFAB; } } if (string.IsNullOrEmpty(iconPrefabPath) == true && task != null) { if (task.State == GameConst.QUEST_STATE_ACCEPT) { iconPrefabPath = TASK_ACCEPT_STATE_ICON_PREFAB; } else if (task.State == GameConst.QUEST_STATE_DOING) { iconPrefabPath = TASK_DOING_STATE_ICON_PREFAB; } else if (task.State == GameConst.QUEST_STATE_DONE) { iconPrefabPath = TASK_DONE_STATE_ICON_PREFAB; } } if (string.IsNullOrEmpty(iconPrefabPath) == false) { UI3DGameObject component = mOwner.GetModelParent().GetComponent <UI3DGameObject>(); if (component != null) { UnityEngine.Object.DestroyImmediate(component); } component = mOwner.GetModelParent().AddComponent <UI3DGameObject>(); UI3DGameObject.StyleInfo styleInfo = new UI3DGameObject.StyleInfo(); styleInfo.Offset = new Vector3(0f, mOwner.Height, 0f); styleInfo.ScreenOffset = new Vector3(0f, 60f, 0f); styleInfo.Scale = Vector3.one; styleInfo.PrefabPath = iconPrefabPath; component.ResetStyleInfo(styleInfo); } else { UI3DGameObject component = mOwner.GetModelParent().GetComponent <UI3DGameObject>(); if (component != null) { UnityEngine.Object.DestroyImmediate(component); } } }