本文整理汇总了C#中GameFramework.EntityInfo.GetAiStateInfo方法的典型用法代码示例。如果您正苦于以下问题:C# EntityInfo.GetAiStateInfo方法的具体用法?C# EntityInfo.GetAiStateInfo怎么用?C# EntityInfo.GetAiStateInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameFramework.EntityInfo
的用法示例。
在下文中一共展示了EntityInfo.GetAiStateInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildCreateNpcMessage
internal static Msg_RC_CreateNpc BuildCreateNpcMessage(EntityInfo npc, int rate = -1)
{
Msg_RC_CreateNpc bder = new Msg_RC_CreateNpc();
bder.npc_id = npc.GetId();
bder.unit_id = npc.GetUnitId();
ScriptRuntime.Vector3 pos = npc.GetMovementStateInfo().GetPosition3D();
GameFrameworkMessage.Position pos_bd = new GameFrameworkMessage.Position();
pos_bd.x = (float)pos.X;
pos_bd.z = (float)pos.Z;
bder.cur_pos = pos_bd;
bder.face_direction = (float)npc.GetMovementStateInfo().GetFaceDir();
bder.link_id = npc.GetLinkId();
bder.camp_id = npc.GetCampId();
if (npc.OwnerId > 0) {
bder.owner_id = npc.OwnerId;
}
if (npc.GetAiStateInfo().LeaderID > 0) {
bder.leader_id = npc.GetAiStateInfo().LeaderID;
}
User user = npc.CustomData as User;
if (null != user) {
bder.key = user.GetKey();
}
bder.level = npc.GetLevel();
return bder;
}
示例2: GetAiData
private AiData_General GetAiData(EntityInfo entity)
{
AiData_General data = entity.GetAiStateInfo().AiDatas.GetData<AiData_General>();
if (null == data) {
data = new AiData_General();
entity.GetAiStateInfo().AiDatas.AddData(data);
}
return data;
}
示例3: OnStateLogicInit
protected override void OnStateLogicInit(EntityInfo entity, long deltaTime)
{
AiStateInfo info = entity.GetAiStateInfo();
info.Time = 0;
info.HomePos = entity.GetMovementStateInfo().GetPosition3D();
info.Target = 0;
}
示例4: TickNpc
private void TickNpc(EntityInfo entity, long delta)
{
IAiStateLogic logic = AiLogicManager.Instance.GetNpcStateLogic(entity.GetAiStateInfo().AiLogic);
if (null != logic) {
logic.Execute(entity, delta);
}
}
示例5: DslLogicHandler
private void DslLogicHandler(EntityInfo entity, long deltaTime)
{
AiStateInfo info = entity.GetAiStateInfo();
if (null != info.AiStoryInstanceInfo) {
long curTime = TimeUtility.GetLocalMilliseconds();
info.AiStoryInstanceInfo.m_StoryInstance.Tick(curTime);
}
}
示例6: IdleHandler
private void IdleHandler(EntityInfo entity, long deltaTime)
{
AiStateInfo info = entity.GetAiStateInfo();
info.Time += deltaTime;
if (info.Time > 100) {
info.Time = 0;
ChangeToState(entity, (int)AiStateId.DslLogic);
}
}
示例7: CombatHandler
private void CombatHandler(EntityInfo npc, long deltaTime)
{
if (npc.GetSkillStateInfo().IsSkillActivated()) {
return;
}
AiStateInfo info = npc.GetAiStateInfo();
Vector3 targetPos = info.HomePos;
ScriptRuntime.Vector3 srcPos = npc.GetMovementStateInfo().GetPosition3D();
float distSqrToHome = Geometry.DistanceSquare(srcPos, info.HomePos);
if (distSqrToHome > npc.GohomeRange * npc.GohomeRange) {
NotifyAiStopPursue(npc);
ChangeToState(npc, (int)AiStateId.GoHome);
return;
}
///
EntityInfo attackTarget = null;
SkillStateInfo currSkInfo = npc.GetSkillStateInfo();
///找到可以使用的技能
SkillInfo skInfo = AiLogicUtility.NpcFindCanUseSkill(npc, this.GetAiData(npc), true);
NotifyAiSelectSkill(npc, skInfo);
if (skInfo == null) {
//没有可以使用的技能就切换到Idle状态
ChangeToState(npc, (int)AiStateId.Idle);
return;
}
CharacterRelation relation =
(skInfo.TargetType == SkillTargetType.Friend ||
skInfo.TargetType == SkillTargetType.RandFriend) ?
CharacterRelation.RELATION_FRIEND :
CharacterRelation.RELATION_ENEMY;
attackTarget = AiLogicUtility.GetNearstTargetHelper(
npc, skInfo.Distance, relation);
if (attackTarget != null && null != skInfo) //攻击范围内找到可攻击目标
{
info.Target = attackTarget.GetId();
NotifyAiStopPursue(npc);
NotifyAiSkill(npc, skInfo.SkillId); //攻击目标
return;
}
attackTarget = AiLogicUtility.GetNearstTargetHelper(
npc, npc.ViewRange, relation);
if (attackTarget != null) //视野范围内找到可攻击目标
{
NotifyAiPursue(npc, attackTarget.GetMovementStateInfo().GetPosition3D()); // 追赶目标
return;
}
currSkInfo.SetCurSkillInfo(0);
NotifyAiStopPursue(npc);
ChangeToState(npc, (int)AiStateId.GoHome);
}
示例8: CombatHandler
private void CombatHandler(EntityInfo npc, long deltaTime)
{
AiStateInfo aiInfo = npc.GetAiStateInfo();
AiData_Leader aiData = GetAiData(npc);
if (npc.GetSkillStateInfo().IsSkillActivated()) {
return;
}
///
SkillStateInfo currSkInfo = npc.GetSkillStateInfo();
///找到可以使用的技能
SkillInfo skInfo = AiLogicUtility.NpcFindCanUseSkill(npc, this.GetAiData(npc), aiData.IsAutoOperate);
NotifyAiSelectSkill(npc, skInfo);
if (skInfo == null) {
//没有可以使用的技能就切换到Idle状态
ChangeToState(npc, (int)AiStateId.Idle);
return;
}
CharacterRelation relation =
(skInfo.TargetType == SkillTargetType.Friend ||
skInfo.TargetType == SkillTargetType.RandFriend) ?
CharacterRelation.RELATION_FRIEND :
CharacterRelation.RELATION_ENEMY;
EntityInfo attackTarget = AiLogicUtility.GetNearstAttackerHelper(npc, relation, aiData);
if (null != attackTarget) {
NotifyAiTarget(npc, attackTarget);
if (Geometry.DistanceSquare(npc.GetMovementStateInfo().GetPosition3D(), attackTarget.GetMovementStateInfo().GetPosition3D()) < skInfo.Distance * skInfo.Distance) {
aiInfo.Target = attackTarget.GetId();
NotifyAiStopPursue(npc);
NotifyAiSkill(npc, skInfo.SkillId);
return;
}
}
attackTarget = AiLogicUtility.GetNearstTargetHelper(npc, skInfo.Distance, relation);
if (attackTarget != null && null != skInfo) { //攻击范围内找到可攻击目标
NotifyAiTarget(npc, attackTarget);
aiInfo.Target = attackTarget.GetId();
NotifyAiStopPursue(npc);
NotifyAiSkill(npc, skInfo.SkillId); //攻击目标
return;
}
if (aiData.IsAutoOperate) {
attackTarget = AiLogicUtility.GetNearstTargetHelper(npc, npc.ViewRange, relation);
if (attackTarget != null && null != skInfo) { //视野内找到可攻击目标
NotifyAiPursue(npc, attackTarget.GetMovementStateInfo().GetPosition3D());
return;
}
}
///退出战斗模式清理一下手动技能
currSkInfo.SetCurSkillInfo(0);
aiData.ManualSkillId = 0;
NotifyAiStopPursue(npc);
ChangeToState(npc, (int)AiStateId.Idle);
}
示例9: OnStateLogicCheck
protected override bool OnStateLogicCheck(EntityInfo entity, long deltaTime)
{
if (entity.IsDead()) {
if (entity.GetAiStateInfo().CurState != (int)AiStateId.Idle) {
NotifyAiStopPursue(entity);
ChangeToState(entity, (int)AiStateId.Idle);
}
return false;
}
return true;
}
示例10: BuildNpcSkillMessage
internal static Msg_RC_NpcSkill BuildNpcSkillMessage(EntityInfo obj, int skillId)
{
MovementStateInfo msi = obj.GetMovementStateInfo();
ScriptRuntime.Vector3 pos = msi.GetPosition3D();
Msg_RC_NpcSkill msg = new Msg_RC_NpcSkill();
msg.npc_id = obj.GetId();
msg.skill_id = skillId;
msg.stand_pos = ProtoHelper.EncodePosition2D(pos.X, pos.Z);
msg.face_direction = ProtoHelper.EncodeFloat(msi.GetFaceDir());
msg.target_id = obj.GetAiStateInfo().Target;
return msg;
}
示例11: OnAiInitDslLogic
private void OnAiInitDslLogic(EntityInfo entity)
{
AiStateInfo aiInfo = entity.GetAiStateInfo();
if (aiInfo.AiParam.Length >= 2) {
string storyId = aiInfo.AiParam[0];
string storyFile = aiInfo.AiParam[1];
if (!string.IsNullOrEmpty(storyId) && !string.IsNullOrEmpty(storyFile)) {
aiInfo.AiStoryInstanceInfo = GfxStorySystem.Instance.NewAiStoryInstance(storyId, string.Empty, storyFile);
if (null != aiInfo.AiStoryInstanceInfo) {
aiInfo.AiStoryInstanceInfo.m_StoryInstance.SetVariable("@objid", entity.GetId());
aiInfo.AiStoryInstanceInfo.m_StoryInstance.Start();
}
}
}
}
示例12: OnStateLogicCheck
protected override bool OnStateLogicCheck(EntityInfo entity, long deltaTime)
{
if (entity.IsDead()) {
if (entity.GetAiStateInfo().CurState != (int)AiStateId.Idle) {
NotifyAiStopPursue(entity);
ChangeToState(entity, (int)AiStateId.Idle);
}
return false;
}
if (IsLeaderDead(entity)) {
entity.SetHp(Operate_Type.OT_Absolute, 0);
return false;
}
return true;
}
示例13: PushState
public void PushState(EntityInfo entity, int state)
{
entity.GetAiStateInfo().PushState(state);
}
示例14: GetAiData
private AiData_Leader GetAiData(EntityInfo entity)
{
AiData_Leader data = entity.GetAiStateInfo().AiDatas.GetData<AiData_Leader>();
if (null == data) {
data = new AiData_Leader();
entity.GetAiStateInfo().AiDatas.AddData(data);
}
return data;
}
示例15: IsAutoOperate
private bool IsAutoOperate(EntityInfo leader)
{
bool ret = false;
if (null != leader) {
AiData_Leader data = leader.GetAiStateInfo().AiDatas.GetData<AiData_Leader>();
if (null != data) {
ret = data.IsAutoOperate;
}
}
return ret;
}