public CharacterView GetCharacterViewById(int objId) { CharacterView view = GetUserViewById(objId); if (null == view) { view = GetNpcViewById(objId); } return(view); }
private void OnNpcMeetEnemy(NpcInfo npc, Animation_Type animType) { CharacterView view = EntityManager.Instance.GetCharacterViewById(npc.GetId()); if (null != view) { GfxSystem.SendMessage(view.Actor, "OnMeetEnemy", null); } view.PlayAnimation(animType); view.PlayQueuedAnimation(Animation_Type.AT_Stand); }
public bool IsVisible(int objId) { bool ret = false; CharacterView view = GetCharacterViewById(objId); if (null != view) { ret = view.Visible; } return(ret); }
private void NpcSkill(NpcInfo npc, int skillId, CharacterInfo target) { if (null != npc) { CharacterView view = EntityManager.Instance.GetCharacterViewById(npc.GetId()); if (null != view) { SkillParam param = new SkillParam(); param.SkillId = skillId; param.TargetId = target.GetId(); GfxSystem.SendMessage(view.Actor, "MonsterStartSkill", param); } } }
private void FindPath(UserInfo playerself, Vector3 targetpos, float towards) { CharacterView view = EntityManager.Instance.GetUserViewById(playerself.GetId()); if (view != null && view.ObjectInfo.IsGfxMoveControl && Vector3.Zero != targetpos) { return; } playerself.GetMovementStateInfo().SetFaceDir(towards); PlayerMovement.Motion m = Vector3.Zero == targetpos ? PlayerMovement.Motion.Stop : PlayerMovement.Motion.Moving; pm_.MotionChanged = pm_.MotionStatus != m || m_lastDir != towards; m_lastDir = towards; pm_.MotionStatus = m; pm_.MoveDir = towards; if (Vector3.Zero == targetpos) { pm_.MotionStatus = PlayerMovement.Motion.Stop; } /* * UserAiStateInfo aiInfo = playerself.GetAiStateInfo(); * if(null == aiInfo) * return; * if (Vector3.Zero == targetpos) { * StopFindPath(playerself, aiInfo); * return; * } * bool ret = (m_lastDir > towards) ? ((m_lastDir - towards) > Math.PI / 4.0f) : ((towards - m_lastDir) > Math.PI / 4.0f); * if (ret) { * StopFindPath(playerself, aiInfo); * m_lastDir = towards; * } * aiInfo.TargetPos = targetpos; * aiInfo.ChangeToState((int)AiStateId.Move); */ }
private void TickNpcs() { List <NpcInfo> deletes = new List <NpcInfo>(); for (LinkedListNode <NpcInfo> linkNode = m_NpcMgr.Npcs.FirstValue; null != linkNode; linkNode = linkNode.Next) { NpcInfo info = linkNode.Value; if (info.LevelChanged || info.GetShootStateInfo().WeaponChanged || info.GetSkillStateInfo().BuffChanged || info.GetEquipmentStateInfo().EquipmentChanged) { NpcAttrCalculator.Calc(info); info.LevelChanged = false; info.GetShootStateInfo().WeaponChanged = false; info.GetSkillStateInfo().BuffChanged = false; info.GetEquipmentStateInfo().EquipmentChanged = false; } // 约定npc的高度低于140时,直接判定npc死亡。 if (140.0f > info.GetMovementStateInfo().GetPosition3D().Y) { info.SetHp(Operate_Type.OT_Absolute, 0); } if (info.NeedDelete) { deletes.Add(info); } else if (info.Hp <= 0) { if (!info.LogicDead) { GfxSystem.PublishGfxEvent("ge_on_npc_dead", "story", info.GetUnitId()); info.LogicDead = true; } if (info.DeadTime <= 0) { } else if (TimeUtility.GetServerMilliseconds() - info.DeadTime > info.ReleaseTime) { deletes.Add(info); } } if (info.IsBorning && IsNpcBornOver(info)) { info.IsBorning = false; info.SetAIEnable(true); info.SetStateFlag(Operate_Type.OT_RemoveBit, CharacterState_Type.CST_Invincible); } } if (deletes.Count > 0) { foreach (NpcInfo ni in deletes) { CharacterView view = EntityManager.Instance.GetCharacterViewById(ni.GetId()); if (null != view) { GfxSystem.SendMessage(view.Actor, "OnDead", null); } EntityManager.Instance.DestroyNpcView(ni.GetId()); WorldSystem.Instance.DestroyCharacterById(ni.GetId()); return; } } }