/// <summary> /// 加载子弹型npc /// </summary> /// <returns>The bullet npc.</returns> /// <param name="num">Number.</param> /// <param name="camp">Camp.</param> /// <param name="pos">Position.</param> /// <param name="rot">Rot.</param> public GameObject LoadBulletNpc(int num, CAMP camp, Vector3 pos, Quaternion rot) { if (NpcModel == null) { NpcModel = Core.Data.getIModelConfig <NPCModel>(); } NPCConfigData configData = NpcModel.get(num); #if DEBUG Utils.Assert(configData == null, "Virtual Npc load can't find npc configure. NPC id = " + num); #endif string path = SPath.Combine(ResourceSetting.PACKROOT, NPC); path = SPath.Combine(path, "ServerBulletNpc"); UObj obj = URes.Load(path); GameObject go = GameObject.Instantiate(obj) as GameObject; go.transform.position = pos; go.transform.rotation = rot; ServerNPC npc = go.GetComponent <ServerNPC>(); if (npc != null) { DynamicDataInit(npc, configData, camp); } return(go); }
/// <summary> /// Creates a new instance of <see cref="NPCViewModel"/> /// </summary> public NPCViewModel(NPCModel npcModel) { _npcModel = npcModel; if (!String.IsNullOrWhiteSpace(npcModel.Name)) { _name = npcModel.Name; } else { _name = "Unknown Name"; } if (_npcModel.Tags.Any()) { _tags = String.Join(", ", _npcModel.Tags); } else { _tags = "None"; } _occupation = _stringService.UnknownIfNullOrEmpty(_npcModel.Occupation); _backstory = _stringService.UnknownIfNullOrEmpty(_npcModel.Backstory); _ideal = _stringService.UnknownIfNullOrEmpty(_npcModel.Ideal); _bond = _stringService.UnknownIfNullOrEmpty(_npcModel.Bond); _flaw = _stringService.UnknownIfNullOrEmpty(_npcModel.Flaw); _appearance = _stringService.UnknownIfNullOrEmpty(_npcModel.Appearance); _abilities = _stringService.UnknownIfNullOrEmpty(_npcModel.Abilities); _mannerism = _stringService.UnknownIfNullOrEmpty(_npcModel.Mannerism); _interactions = _stringService.UnknownIfNullOrEmpty(_npcModel.Interactions); _usefulKnowledge = _stringService.UnknownIfNullOrEmpty(_npcModel.UsefulKnowledge); }
protected NPC(NPCModel descriptor) { _scripts = new List <Script>(); this.Name = descriptor.Name; this.Level = descriptor.Level; this.MaxRoam = descriptor.MaxRoam; this.Position = descriptor.Position; this.FrameSize = descriptor.FrameSize; this.UniqueID = descriptor.UniqueID; this.AggresiveRange = descriptor.AggresiveRange; this.Reach = descriptor.Reach; this.Speed = descriptor.Speed; this.TexturePath = descriptor.TexturePath; this.Stats.Defense = descriptor.Stats.Defense; this.Stats.Dexterity = descriptor.Stats.Dexterity; this.Stats.Vitality = descriptor.Stats.Vitality; this.Stats.Vitality = descriptor.Stats.Vitality; this.Stats.Strength = descriptor.Stats.Strength; this.Stats.Intelligence = descriptor.Stats.Intelligence; this.CollisionBounds = descriptor.CollisionBounds; this.DialogueBranch = descriptor.DialogueBranch; this.InitalizeScripts(descriptor.Scripts); if (!string.IsNullOrEmpty(descriptor.Dialogue)) { this.Dialogue = Engine.Services.Get <DialogueManager>().Get(descriptor.Dialogue); this.DialogueBranch = descriptor.DialogueBranch; } }
private void Awake() { nPCView = GetComponent <NPCView>(); nPCModel = GetComponent <NPCModel>(); nPCModel.animationSpeed = 2.0f; }
public WarServerCharactor() { allCharactors = new Dictionary <WarCamp, List <RoomCharactor> >(); allHeros = new Dictionary <WarCamp, List <ServerLifeNpc> >(); Model = Core.Data.getIModelConfig <NPCModel>(); }
// GET: NPC public ActionResult Index() { var model = new NPCListViewModel(); var NPCs = npcRepository.GetAll(); model.NPCs = NPCs.Select(p => NPCModel.FromDatabaseModel(p)).ToList(); return(View(model)); }
/// <summary> /// Adds an npc /// </summary> public void AddNPC(NPCModel npcModel) { if (!_npcs.Any(x => x.Id == npcModel.Id)) { _npcs.Add(npcModel); //UpdateTags(); } }
public ActionResult Create(NPCModel model) { if (ModelState.IsValid) { npcRepository.Add(NPCModel.ToDatabaseModel(model)); return(RedirectToAction("Index")); } return(View(model)); }
/// <summary> /// Updates the npc with id matching the parameter's id /// </summary> public void UpdateNPC(NPCModel model) { NPCModel currentModel = _npcs.FirstOrDefault(x => x.Id == model.Id); if (currentModel != null) { _npcs[_npcs.IndexOf(currentModel)] = model; UpdateTags(); } }
/// <summary> /// Creates a copy of <see cref="NPCModel"/> /// </summary> public NPCModel(NPCModel npcModel) : base(npcModel) { _occupation = npcModel.Occupation; _backstory = npcModel.Backstory; _ideal = npcModel.Ideal; _bond = npcModel.Bond; _flaw = npcModel.Flaw; _appearance = npcModel.Appearance; _abilities = npcModel.Abilities; _mannerism = npcModel.Mannerism; _interactions = npcModel.Interactions; _usefulKnowledge = npcModel.UsefulKnowledge; }
private void LoadNPCS() { Console.WriteLine("Loading NPCs..."); var directoryInfo = new DirectoryInfo(Constants.FILEPATH_NPCS); FileInfo[] files = directoryInfo.GetFiles("*" + EngineConstants.NPC_FILE_EXT); foreach (var file in files) { NPCModel npcDesc = _npcDataManager.Load(new ContentFileDataLoaderArguments(Path.GetFileNameWithoutExtension(file.Name))); if (npcDesc != null) { _npcs.Add(npcDesc.UniqueID, npcDesc); } } Console.WriteLine($"Loaded {_npcs.Count} NPCs."); }
public NPCInstance CreateNPC(Fiber fiber, NPCSpawnModel spawn, MapData mapData) { NPCModel npc = m_npcRepository.GetNPCByID(spawn.NPCID); List <INPCBehaviour> behaviours = new List <INPCBehaviour>(); foreach (NPCBehaviourModel behaviourModel in m_npcRepository.GetNPCBehavioursByNPCID(spawn.NPCID).OrderBy(b => b.ExecutionOrder)) { INPCBehaviour behaviour = (INPCBehaviour)Activator.CreateInstance(m_behaviourTypes[behaviourModel.NPCBehaviourID]); IReadOnlyDictionary <string, string> behaviourVars = m_npcRepository.GetNPCBehaviourVarsByNPCBehaviourID(behaviourModel.NPCBehaviourID); behaviour.Initialise(behaviourVars); behaviours.Add(behaviour); } IReadOnlyDictionary <StatType, float> stats = m_npcRepository.GetNPCStatsByNPCID(spawn.NPCID).ToDictionary(kvp => (StatType)kvp.Key, kvp => kvp.Value); NPCInstance npcInstance = new NPCInstance(fiber, npc, spawn, behaviours, stats, mapData); return(npcInstance); }
/// <summary> /// Creates a new instance of <see cref="NPCEditViewModel"/> /// </summary> public NPCEditViewModel(NPCModel npcModel) { _npcModel = new NPCModel(npcModel); _name = npcModel.Name; if (_npcModel.Tags.Any()) { _tags = String.Join(", ", _npcModel.Tags); } _occupation = _npcModel.Occupation; _backstory = _npcModel.Backstory; _ideal = _npcModel.Ideal; _bond = _npcModel.Bond; _flaw = _npcModel.Flaw; _appearance = _npcModel.Appearance; _abilities = _npcModel.Abilities; _mannerism = _npcModel.Mannerism; _interactions = _npcModel.Interactions; _usefulKnowledge = _npcModel.UsefulKnowledge; }
public NPCInstance(Fiber fiber, NPCModel npc, NPCSpawnModel npcSpawn, List <INPCBehaviour> behaviours, IReadOnlyDictionary <StatType, float> stats, MapData mapData) { NPCModel = npc; NPCSpawnModel = npcSpawn; m_stats = stats; m_fiber = fiber; m_mapData = mapData; m_behavioursByType = m_behaviours.ToDictionary(b => b.GetType()); Position = new Vector2((float)npcSpawn.X, (float)npcSpawn.Y); ID = IDGenerator.GetNextID(); MaxHealth = Formulas.StaminaToHealth(GetStatValue(StatType.Stamina)); Health = MaxHealth; MaxPower = Formulas.LevelToPower(Level); Power = MaxPower; m_introduction = new EntityIntroduction() { ID = ID, Level = (byte)NPCModel.Level, MaxHealth = MaxHealth, MaxPower = MaxPower, Name = Name, ModelID = NPCModel.ModelID }; m_stateUpdate = new EntityStateUpdate() { Rotation = Compression.RotationToByte(npcSpawn.Rotation), ID = ID, Health = Health, Power = 100, }; m_behaviours = behaviours; }
public NPC(NPCModel descriptor, Map map) : this(descriptor) { if (descriptor == null) { Engine.Services.Get <Logger>().LogEvent($"Null npc spawned on map {map.Name}!", LogTypes.ERROR, new Exception($"Null npc spawned on map {map.Name}!")); } this.GameTimers = new GameTimerManager(); this.StateMachine = new ActorStateMachine <NPC>(this); this.CollisionBody = new CollisionBody(this); _map = map; this.Sprite = new SpriteInfo(this.TexturePath); this.Layer = map.Layers.ElementAt(0); _random = new Random(); _targetPath = new Stack <Vector>(); _map.AddActor(this); var npcDataPacket = new Packet(PacketType.NPC_DATA, ChannelType.UNASSIGNED); npcDataPacket.Message.Write(this.Pack()); _map.SendPacket(npcDataPacket, NetDeliveryMethod.ReliableOrdered); try { this.Behavior?.OnCreated(this); } catch (Exception ex) { Engine.Services.Get <Logger>().LogEvent("Error handling OnCreated: " + ex.Message, LogTypes.ERROR, ex); } }
public void Initalize() { _npc = _project.LoadNPC(this.ContentFile.FullName); if (_npc == null) { base.Close(); DarkMessageBox.ShowError("Error loading npc!", "Error!"); return; } this.txtName.Text = _npc.Name; this.txtStr.Text = _npc.Stats.Strength.ToString(); this.txtInt.Text = _npc.Stats.Intelligence.ToString(); this.txtDef.Text = _npc.Stats.Defense.ToString(); this.txtHealth.Text = _npc.Stats.Vitality.ToString(); this.txtDex.Text = _npc.Stats.Dexterity.ToString(); this.txtFrameWidth.Text = _npc.FrameSize.X.ToString(); this.txtFrameHeight.Text = _npc.FrameSize.Y.ToString(); this.txtColLeft.Text = _npc.CollisionBounds.X.ToString(); this.txtColTop.Text = _npc.CollisionBounds.Y.ToString(); this.txtColWidth.Text = _npc.CollisionBounds.Width.ToString(); this.txtColHeight.Text = _npc.CollisionBounds.Height.ToString(); this.txtMaxRoam.Text = _npc.MaxRoam.X.ToString(); this.txtSpeed.Text = _npc.Speed.ToString(); this.txtAggressiveRange.Text = _npc.AggresiveRange.ToString(); this.txtReachX.Text = _npc.Reach.X.ToString(); this.txtReachY.Text = _npc.Reach.Y.ToString(); this.cmbEquipSlot.DataSource = Enum.GetValues(typeof(EquipmentSlots)); this.cmbEquipSlot.SelectedItem = EquipmentSlots.MainArm; this.cmbDialogue.Items.Add("None"); foreach (var dialogue in _project.DialogueFiles) { var comboItem = new DarkComboItem(Path.GetFileNameWithoutExtension(dialogue.Name)) { Tag = dialogue }; this.cmbDialogue.Items.Add(comboItem); } if (!string.IsNullOrEmpty(_npc.Dialogue) && this.cmbDialogue.Items.Contains(_npc.Dialogue)) { this.cmbDialogue.SelectedItem = Path.GetFileNameWithoutExtension(_npc.Dialogue); _selectedDialogue = _project.LoadDialogue((((DarkComboItem)this.cmbDialogue.SelectedItem).Tag as FileInfo).FullName); _npc.Dialogue = _selectedDialogue.Name; this.cmbDialogueBranch.Items.Add("None"); foreach (var branch in _selectedDialogue.Branches) { this.cmbDialogueBranch.Items.Add(branch.Name); } if (this.cmbDialogueBranch.Items.Contains(_npc.DialogueBranch)) { this.cmbDialogueBranch.SelectedItem = _npc.DialogueBranch; } else { this.cmbDialogueBranch.SelectedItem = "None"; } this.cmbDialogueBranch.Enabled = true; this.cmbDialogueBranch.Enabled = true; } else { this.cmbDialogue.SelectedItem = "None"; this.cmbDialogueBranch.Enabled = false; } this.UpdateCustomVariablesView(); if (File.Exists(_project.ClientRootDirectory + "/" + _npc.TexturePath)) { this.picSpriteSheet.Load(_project.ClientRootDirectory + "/" + _npc.TexturePath); this.picCollisionPreview.Load(_project.ClientRootDirectory + "/" + _npc.TexturePath); if (_npc.FrameSize == Vector.Zero) { _npc.FrameSize = new Vector(this.picSpriteSheet.Image.Width, this.picSpriteSheet.Image.Height); } this.txtFrameWidth.Text = _npc.FrameSize.X.ToString(); this.txtFrameHeight.Text = _npc.FrameSize.Y.ToString(); } else if (!string.IsNullOrEmpty(_npc.TexturePath)) { DarkMessageBox.ShowError($"Cannot load sprite sheet image {_npc.TexturePath}, the file does not exist!", "Error!", DarkDialogButton.Ok); } _unsaved = true; }
/// <summary> /// Gets npcs bytes /// </summary> public byte[] GetNPCBytes(NPCModel npcModel) { return(null); }
public void AwakeMgr() { m_model = Utils.MakeObjectWithComponent <NPCModel>("NPCModel", this.gameObject); m_model.Init(); }
/// <summary> /// Creates a npc archive from the npc model /// </summary> public byte[] CreateNPCArchive(NPCModel npcModel) { return(null); }
private void InitializeListItemDetails(ListItemViewModel <NPCModel> listItem, NPCModel npcModel) { listItem.Model = npcModel; if (!String.IsNullOrWhiteSpace(npcModel.Name)) { listItem.Name = npcModel.Name; } else { listItem.Name = "Unknown Name"; } if (!String.IsNullOrWhiteSpace(npcModel.Appearance)) { listItem.Description = new String(npcModel.Appearance.Take(50).ToArray()); } else { listItem.Description = "Unknown description"; } }
public ActionResult Edit(Guid id) { var model = NPCModel.FromDatabaseModel(npcRepository.GetNPC(id)); return(View(model)); }
private void Copy() { if (_selectedNPC != null) { bool copyNPC = true; if (_npcEditViewModel != null) { if (_editHasUnsavedChanges) { string body = String.Format("{0} has unsaved changes.{1}What would you like to do?", _selectedNPC.Name, Environment.NewLine + Environment.NewLine); string accept = "Save and Continue"; string reject = "Discard Changes"; string cancel = "Cancel Navigation"; bool? result = _dialogService.ShowConfirmationDialog("Unsaved Changes", body, accept, reject, cancel); if (result == true) { if (!SaveEditNPC()) { copyNPC = false; } } else if (result == false) { CancelEditNPC(); } else { copyNPC = false; } } else { CancelEditNPC(); } } if (copyNPC) { NPCModel npcModel = new NPCModel(_selectedNPC.NPCModel); npcModel.Name += " (copy)"; npcModel.Id = Guid.NewGuid(); _compendium.AddNPC(npcModel); if (_npcSearchService.SearchInputApplies(_npcSearchInput, npcModel)) { ListItemViewModel <NPCModel> listItem = new ListItemViewModel <NPCModel>(npcModel); InitializeListItemDetails(listItem, npcModel); _npcs.Add(listItem); foreach (ListItemViewModel <NPCModel> item in _npcs) { item.IsSelected = false; } listItem.IsSelected = true; } _selectedNPC = new NPCViewModel(npcModel); SortNPCs(); _compendium.SaveNPCs(); OnPropertyChanged(nameof(SelectedNPC)); } } }
/// <summary> /// Loads the bullet. /// </summary> /// <returns>The bullet.</returns> /// <param name="num">Number.</param> /// <param name="camp">Camp.</param> /// <param name="pos">Position.</param> /// <param name="rot">Rot.</param> public GameObject LoadNpcObj(int num, CAMP camp, Vector3 pos, Quaternion rot) { if (NpcModel == null) { NpcModel = Core.Data.getIModelConfig <NPCModel>(); } NPCConfigData configData = NpcModel.get(num); #if DEBUG Utils.Assert(configData == null, "Virtual Npc load can't find npc configure. NPC id = " + num); #endif string path = SPath.Combine(ResourceSetting.PACKROOT, NPC); if (configData.healthpoint > 0) { path = SPath.Combine(path, "LifeSummonNpc"); } else { path = SPath.Combine(path, "NoneLifeSummonNpc"); } UObj obj = URes.Load(path); GameObject go = GameObject.Instantiate(obj) as GameObject; go.transform.position = pos; go.transform.rotation = rot; if (configData.moveable == Moveable.Movable) { Seeker seek = go.AddComponent <Seeker>(); seek.drawGizmos = false; AIPath pathFinding = go.AddComponent <AIPath>(); pathFinding.speed = configData.speed; pathFinding.slowdownDistance = 0.0f; pathFinding.pickNextWaypointDist = 2; pathFinding.forwardLook = 1f; FunnelModifier modifer = go.AddComponent <FunnelModifier>(); modifer.Priority = 2; CharacterController box = go.AddComponent <CharacterController>(); box.radius = configData.radius; box.height = 2; if (box.radius >= box.height) { box.center = Vector3.up * box.radius; } else { box.center = Vector3.up * box.height / 2; } } else if (configData.radius > 0) { CapsuleCollider cap = go.AddComponent <CapsuleCollider>(); cap.radius = configData.radius; cap.height = 2; if (cap.radius >= cap.height) { cap.center = Vector3.up * cap.radius; } else { cap.center = Vector3.up * cap.height / 2; } NavmeshCut cut = go.AddComponent <NavmeshCut>(); cut.type = NavmeshCut.MeshType.Circle; cut.circleRadius = configData.radius; cut.height = 10; cut.center = Vector3.up * 5; } ServerNPC npc = go.GetComponent <ServerNPC>(); if (npc != null) { DynamicDataInit(npc, configData, camp); } return(go); }
/// <summary> /// 释放技能效果 /// </summary> /// <param name="src">效果发起者</param> /// <param name="skTarget">技能选择的目标, 无意义</param> /// <param name="target">技能先选择目标后,再次Effect选择后的目标</param> /// <param name="skDirectHurt">是否是技能的直接伤害, 这个没有伤害</param> /// <param name="container">所有数据展现的容器,本次Effect施法的效果会依次加入</param> public void Cast(ServerNPC src, IEnumerable <ServerNPC> skTarget, IEnumerable <ServerNPC> target, bool skDirectHurt, List <MsgParam> container) { #if DEBUG Utils.Assert(skCfg == null, "Skill Configure is null in BulletNpcEffect routine."); #endif WarSrcAnimParam SrcParam = new WarSrcAnimParam() { OP = EffectOp.CtorNPC, ShootAction = skCfg.ShootAction, ShootTime = skCfg.ShootTime, ShootEventTime = skCfg.ShootEventTime, }; int CtorNpcId = cfg.Param1; float LifeTime = cfg.Param2 * Consts.OneThousand; CtorNpcPos pos = (CtorNpcPos)Enum.ToObject(typeof(CtorNpcPos), cfg.Param3); //碰撞 bool Collide = cfg.Param4 == 1; int AI_ID = cfg.Param5; int param_1 = cfg.Param8; int param_2 = cfg.Param10; //会有的Buff int[] BuffIDList = cfg.Param11; //数据源 CtorNpcSource datasrc = (CtorNpcSource)Enum.ToObject(typeof(CtorNpcSource), cfg.Param6); //数据源的修正 CtorNpcAttri attr_1 = (CtorNpcAttri)Enum.ToObject(typeof(CtorNpcAttri), cfg.Param7); CtorNpcAttri attr_2 = (CtorNpcAttri)Enum.ToObject(typeof(CtorNpcAttri), cfg.Param9); /// /// 获取数据源 /// NPCData data = new NPCData(); NPCConfigData cfgD = null; NPCRuntimeData rtD = null; if (datasrc == CtorNpcSource.NPC_Table) { NPCModel model = Core.Data.getIModelConfig <NPCModel>(); cfgD = model.get(CtorNpcId); Utils.Assert(cfgD == null, "Can't find NPC configure. NPC ID = " + CtorNpcId); } else if (datasrc == CtorNpcSource.NPC_Castro_Cur) { cfgD = src.data.configData; rtD = src.data.rtData.ShallowCopy(); } else if (datasrc == CtorNpcSource.NPC_Castor_Init) { cfgD = src.data.configData; } rtD = rtD ?? new NPCRuntimeData(cfgD); List <String> changed_1 = attr_1.SwitchTo(); List <String> changed_2 = attr_2.SwitchTo(); int cnt = changed_1.Count; if (cnt > 0) { for (int i = 0; i < cnt; ++i) { rtD.setValue(changed_1[i], (Int32Fog)param_1); } } cnt = changed_2.Count; if (cnt > 0) { for (int i = 0; i < cnt; ++i) { rtD.setValue(changed_2[i], (Int32Fog)param_2); } } data.configData = cfgD; data.rtData = rtD; /// /// 获取目标位置 /// List <UVec3> TargetVec3 = new List <UVec3>(); if (pos == CtorNpcPos.Castor_Forward) { TargetVec3.Add(src.transform.forward); } else if (pos == CtorNpcPos.Target) { foreach (ServerNPC t in target) { TargetVec3.Add(t.transform.position); } } else if (pos == CtorNpcPos.Castor_Surround) { TargetVec3.Add(src.transform.position); } /// /// ------ 获取统计信息 ------ /// SelfDescribed des = new SelfDescribed() { src = src.UniqueID, target = src.UniqueID, act = Verb.Creature, srcEnd = new EndResult { param1 = CtorNpcId, param2 = AI_ID, param8 = LifeTime, }, targetEnd = null, }; des.srcEnd.obj = ctorToShowcase(Collide, data, BuffIDList, TargetVec3, src); SrcParam.SkillId = skCfg.ID; SrcParam.described = des; container.Add(SrcParam); }
/// /// 先尝试从ObjLoader里面取,如果不存在则再去WeakObjLoader取 /// /// 但是如果是自己队伍里NPC则必须使用ObjLoader去创建 /// public ClientNPC Load(int num, int id, CAMP camp, GameObject WarPoint) { if (NpcModel == null) { NpcModel = Core.Data.getIModelConfig <NPCModel>(); } NPCConfigData configData = NpcModel.get(num); if (configData == null) { ConsoleEx.DebugWarning("not find npc config data :: " + num); return(null); } string path = Path.Combine(ResourceSetting.PACKROOT, NPC); path = Path.Combine(path, configData.model.ToString()); //TODO: 是自己队伍里NPC则必须使用ObjLoader去创建 bool cached = ObjLoader.hitCache(path); Object obj = null; if (cached) { obj = ObjLoader.Load(path); } else { obj = WeakObjLoader.Load(path); } if (obj == null) { ConsoleEx.DebugWarning(configData.model + " not find models. Npc Num = " + num); return(null); } GameObject go = GameObject.Instantiate(obj) as GameObject; UnityUtils.AddChild_Reverse(go, WarPoint); /// /// 数据的初始化过程 /// DynamicDataInit(go, num, camp, id); ClientNPC npc = go.GetComponent <ClientNPC> (); if (npc != null) { go.name = "NPC_" + npc.data.configData.ID + "_" + npc.UniqueID; if (!string.IsNullOrEmpty(configData.controlScript)) { ClientNpcAnimState animState = go.AddComponent(configData.controlScript) as ClientNpcAnimState; npc.animState = animState; animState.CachedNpc = npc; animState.AttackCount = configData.normalHit.Length; npc.broadcast = animState.OnNewStateReceived; } cliNpcMgr.CreateNpcUI(npc); } return(npc); }
public NPCModel(NPCModel from) : this(from.HP, from.Armor, from.Speed, from.Damage, from.FireRate, from.SpawnRate) { }
private bool HasSearchText(NPCModel npcModel, string searchText) { return(String.IsNullOrWhiteSpace(searchText) || npcModel.Name.ToLower().Contains(searchText.ToLower())); }
private bool HasTag(NPCModel npcModel, string tag) { return(tag == null || npcModel.Tags.Any(x => x.Equals(tag, StringComparison.CurrentCultureIgnoreCase))); }
/// <summary> /// 释放技能效果 /// </summary> /// <param name="src">效果发起者</param> /// <param name="skTarget">技能选择的目标</param> /// <param name="target">技能先选择目标后,再次Effect选择后的目标</param> /// <param name="skDirectHurt">是否是技能的直接伤害</param> /// <param name="container">所有数据展现的容器,本次Effect施法的效果会依次加入</param> public void Cast(ServerNPC src, IEnumerable <ServerNPC> skTarget, IEnumerable <ServerNPC> target, bool skDirectHurt, List <MsgParam> container) { #if DEBUG Utils.Assert(cfg == null, "Effect Configure is null in SwitchNpcEffect."); #endif int SwitchToId = cfg.Param1; UVec3 Locale = src.transform.position; NPCAIType AI = (NPCAIType)Enum.ToObject(typeof(NPCAIType), cfg.Param2); //数据源 CtorNpcSource datasrc = (CtorNpcSource)Enum.ToObject(typeof(CtorNpcSource), cfg.Param3); int chargeOf = cfg.Param4; float duration = cfg.Param5 * Consts.OneThousand; //参数10,是否继承普通攻击 bool inheritNorAtk = cfg.Param10 == 0; NPCConfigData npcCfg = null; NPCRuntimeData npcRt = null; //获取参数配置 NPCModel model = Core.Data.getIModelConfig <NPCModel>(); switch (datasrc) { case CtorNpcSource.NPC_Castor_Init: npcCfg = src.data.configData.ShallowCopy(); break; case CtorNpcSource.NPC_Castro_Cur: npcCfg = src.data.configData.ShallowCopy(); npcRt = src.data.rtData.ShallowCopy(); break; case CtorNpcSource.NPC_Table: npcCfg = model.get(SwitchToId); Utils.Assert(npcCfg == null, "Can't find NPC configure. NPC ID = " + SwitchToId); break; } if (inheritNorAtk == false) { NPCConfigData swtNpcCfg = model.get(SwitchToId); Utils.Assert(swtNpcCfg == null, "Can't find NPC configure. NPC ID = " + SwitchToId); npcCfg.ID = SwitchToId; npcCfg.normalHit = swtNpcCfg.normalHit; } npcRt = npcRt ?? new NPCRuntimeData(npcCfg); //额外的属性修改 NPCAttributeModel AttModel = Core.Data.getIModelConfig <NPCAttributeModel>(); AttrbuteConfig att1 = AttModel.get(cfg.Param6); AttrbuteConfig att2 = AttModel.get(cfg.Param8); //参数 float param1 = cfg.Param7 * Consts.OneThousand; float param2 = cfg.Param9 * Consts.OneThousand; //修正属性的值 if (att1 != null) { if (att1.type == "int") { npcRt.addIntegerValue(att1.note, param1); } else if (att1.type == "float") { npcRt.addFloatValue(att1.note, param1); } } if (att2 != null) { if (att2.type == "int") { npcRt.addIntegerValue(att2.note, param2); } else if (att2.type == "float") { npcRt.addFloatValue(att2.note, param2); } } //Buff的列表 int[] BuffIds = cfg.Param11; /// /// 统计信息 /// WarSrcAnimParam SrcParam = new WarSrcAnimParam() { OP = EffectOp.SwitchNpc, ShootAction = skCfg.ShootAction, ShootEventTime = skCfg.ShootEventTime, ShootTime = skCfg.ShootTime, described = new SelfDescribed() { src = src.UniqueID, target = src.UniqueID, act = Verb.Creature, srcEnd = new EndResult { param1 = SwitchToId, param2 = (int)AI, param3 = chargeOf, param8 = duration, }, targetEnd = null, }, SkillId = skCfg.ID, OringinOP = EffectOp.SwitchNpc, }; SrcParam.described.srcEnd.obj = ctorToShowcase(npcRt, npcCfg, BuffIds, Locale); container.Add(SrcParam); }
public ServerNPC Load(int num, CAMP camp, GameObject WarPoint) { if (NpcModel == null) { NpcModel = Core.Data.getIModelConfig <NPCModel>(); } NPCConfigData configData = NpcModel.get(num); #if DEBUG Utils.Assert(configData == null, "Virtual Npc load can't find npc configure. NPC id = " + num); #endif if (cached == null) { string path = SPath.Combine(ResourceSetting.PACKROOT, NPC); path = SPath.Combine(path, VIRTUAL); cached = URes.Load(path); } GameObject go = GameObject.Instantiate(cached) as GameObject; UnityUtils.AddChild_Reverse(go, WarPoint); if (configData.type == LifeNPCType.Build) { go.layer = LayerMask.NameToLayer(Consts.LAYER_BUILD); } else { go.layer = LayerMask.NameToLayer(Consts.LAYER_NPC); } ServerNPC npc = null; if (configData.healthpoint > 0) { npc = go.AddComponent <ServerLifeNpc>(); } else { npc = go.AddComponent <ServerNPC>(); } //如果是可以移动的,添加寻路脚本 if (configData.moveable == Moveable.Movable) { Seeker seek = go.AddComponent <Seeker>(); seek.drawGizmos = false; AIPath pathFinding = go.AddComponent <AIPath>(); pathFinding.speed = configData.speed; pathFinding.slowdownDistance = 0.0f; pathFinding.pickNextWaypointDist = 2; pathFinding.forwardLook = 1f; FunnelModifier modifer = go.AddComponent <FunnelModifier>(); modifer.Priority = 2; CharacterController box = go.AddComponent <CharacterController>(); box.radius = configData.radius; box.height = 2; if (box.radius >= box.height) { box.center = Vector3.up * box.radius; } else { box.center = Vector3.up * box.height / 2; } } else if (configData.radius > 0) { CapsuleCollider cap = go.AddComponent <CapsuleCollider>(); cap.radius = configData.radius; cap.height = 2; if (cap.radius >= cap.height) { cap.center = Vector3.up * cap.radius; } else { cap.center = Vector3.up * cap.height / 2; } NavmeshCut cut = go.AddComponent <NavmeshCut>(); cut.type = NavmeshCut.MeshType.Circle; cut.circleRadius = configData.radius; cut.height = 10; cut.center = Vector3.up * 5; } DynamicDataInit(npc, configData, camp); go.name = "NPC_" + configData.ID + "_" + npc.UniqueID; return(npc); }