public NpcModel(string id, string name, NpcRole npcRole, NpcRace npcRace, NpcSize npcSize, RarityType rarityType, CombatantModel combatantModel, string[] alwaysDroppedItemIDs = null) { this.ID = id; this.Name = name; this.NpcRole = npcRole; this.NpcRace = npcRace; this.NpcSize = npcSize; this.RarityType = rarityType; this.CombatantModel = combatantModel; this.AlwaysDroppedItemIDs = alwaysDroppedItemIDs; }
private void Start() { NpcRole npcRole = base.gameObject.AddComponent <NpcRole>(); npcRole.openid = this.openID; npcRole.lDesc = this.desc; npcRole.id = int.Parse(base.gameObject.name); npcRole.name = this.rolename; npcRole.talkOffset = this.offset; npcRole.talkScale = this.scale; npcRole.nav = this.navmesh; UnityEngine.Object.Destroy(this); }
private void dispose() { this.ani = null; bool flag = this.uiactive; if (flag) { InterfaceMgr.getInstance().changeState(InterfaceMgr.STATE_NORMAL); } NpcRole[] componentsInChildren = base.transform.GetComponentsInChildren <NpcRole>(); NpcRole[] array = componentsInChildren; for (int i = 0; i < array.Length; i++) { NpcRole npcRole = array[i]; npcRole.dispose(); } UnityEngine.Object.Destroy(base.transform.gameObject); }
public void FromObjectArray(object[] properties) { int i = 0; ID = properties[i++] as string; Name = properties[i++] as string; NpcRole = (NpcRole)properties[i++]; NpcRace = (NpcRace)properties[i++]; NpcSize = (NpcSize)properties[i++]; RarityType = (RarityType)properties[i++]; CombatantModel = new CombatantModel(); CombatantModel.FromObjectArray(properties[i++] as object[]); object[] alwaysDroppedItemIdObjects = properties[i++] as object[]; AlwaysDroppedItemIDs = new string[alwaysDroppedItemIdObjects.Length]; for (int j = 0; j < AlwaysDroppedItemIDs.Length; j++) { AlwaysDroppedItemIDs[j] = alwaysDroppedItemIdObjects[j] as string; } }
private ServerNpcModel buildRandomNPC(int npcLevel, int npcTeamID, RarityType minRarityType, RarityType maxRarityType) { RarityType npcRarity = RarityConstants.GetRandomRarityRange(minRarityType, maxRarityType); NpcRole npcRole = (NpcRole)RandomGen.GetIntRange(0, NumNpcRoles - 1); NpcRace npcRace = (NpcRace)RandomGen.GetIntRange(0, NumNpcRaces - 1); NpcSize npcSize = (NpcSize)RandomGen.GetIntRange(0, NumNpcSizes - 1); // TODO: determine better naming scheme. For now just join Size+Race+Role; string npcName = npcSize.ToString() + " " + npcRace.ToString() + " " + npcRole.ToString(); // Build combatant model AbilityItemModel[] randomAbilities = getRandomNPCAbilities((int)npcRarity + 1, npcLevel); CombatantModel combatantModel = BuildCombatantSCMD.Execute(npcLevel, npcTeamID, randomAbilities, npcRarity); // TODO: determine behaviour based on role. For now use default CombatBehaviourBase combatBehaviour = new AbilityCycleBehaviour(); ServerNpcModel serverNpcModel = new ServerNpcModel(combatBehaviour, "", npcName, npcRole, npcRace, npcSize, npcRarity, combatantModel); DetermineNPCDropTableSCMD.Execute(serverNpcModel); return(serverNpcModel); }
public static void moveToNPc(int mapid, int npcId, List <string> listTalk = null, Action handle = null, bool taskmove = false) { bool onlyOne = true; Vector3 npcPos = Vector3.zero; NpcRole targetNpc = NpcMgr.instance.getRole(npcId); if (targetNpc != null) { if (fsm.Autofighting) { fsm.Stop(); } Vector3 targetNpcPos = targetNpc.transform.position; float curDis = Vector3.Distance(targetNpcPos, _inst.m_curModel.transform.position); if (curDis > 2 || lastNpcId != npcId || lastNpcId == 0) { npcPos = targetNpcPos; } lastNpcId = npcId; } moveto(mapid, npcPos, () => { InterfaceMgr.getInstance().close(InterfaceMgr.A3_BOSSRANKING); DoAfterMgr.instacne.addAfterRender(() => { if (onlyOne)//修改自动任务寻找npc对话垮地图时会出现对话框提前弹出的bug { onlyOne = false; NpcRole n = NpcMgr.instance.getRole(npcId); if (n == null) { return; } if (Vector3.Distance(n.transform.position, SelfRole._inst.m_curModel.transform.position) > 2) { SelfRole.moveto(n.transform.position, () => { if (InterfaceMgr.getInstance().AnyWinOpen()) { InterfaceMgr.getInstance().afterClose = () => { if (listTalk != null) { n.newDesc = listTalk; } n.handle = handle; n.onClick(); } } ; else { if (listTalk != null) { n.newDesc = listTalk; } n.handle = handle; n.onClick(); } }, false, 1.5f, taskmove: taskmove); } else { if (InterfaceMgr.getInstance().AnyWinOpen()) { InterfaceMgr.getInstance().afterClose = () => { if (listTalk != null) { n.newDesc = listTalk; } n.handle = handle; n.onClick(); } } ; else { if (listTalk != null) { n.newDesc = listTalk; } n.handle = handle; n.onClick(); } } } }); }, stopDis: 2f, taskmove: taskmove); }
public ServerNpcModel(CombatBehaviourBase combatantBehaviour, string id, string name, NpcRole npcRole, NpcRace npcRace, NpcSize npcSize, RarityType rarityType, CombatantModel combatantModel, string[] alwaysDroppedItemIDs = null) : base(id, name, npcRole, npcRace, npcSize, rarityType, combatantModel, alwaysDroppedItemIDs) { this.CombatBehaviour = combatantBehaviour; }