当前位置: 首页>>代码示例>>C#>>正文


C# EntityInfo.GetUnitId方法代码示例

本文整理汇总了C#中GameFramework.EntityInfo.GetUnitId方法的典型用法代码示例。如果您正苦于以下问题:C# EntityInfo.GetUnitId方法的具体用法?C# EntityInfo.GetUnitId怎么用?C# EntityInfo.GetUnitId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GameFramework.EntityInfo的用法示例。


在下文中一共展示了EntityInfo.GetUnitId方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
        }
开发者ID:dreamanlan,项目名称:CSharpGameFramework,代码行数:27,代码来源:DataSyncUtility.cs

示例2: OnCreateEntity

 private void OnCreateEntity(EntityInfo entity)
 {
     if (null != entity) {
     StorySystem.SendMessage("obj_created", entity.GetId());
     StorySystem.SendMessage(string.Format("npc_created:{0}", entity.GetUnitId()), entity.GetId());
     }
 }
开发者ID:dreamanlan,项目名称:CSharpGameFramework,代码行数:7,代码来源:Scene_EventHandler.cs

示例3: DoSkillCommandState

 internal static void DoSkillCommandState(EntityInfo entity, long deltaTime, AbstractAiStateLogic logic, int skillId)
 {
     if (entity.GetMovementStateInfo().IsMoving) {
         logic.NotifyAiStopPursue(entity);
     }
     if (skillId > 0) {
         AiStateInfo aiInfo = entity.GetAiStateInfo();
         SkillInfo skillInfo = entity.GetSkillStateInfo().GetSkillInfoById(skillId);
         if (null != skillInfo) {
             if (aiInfo.Target <= 0) {
                 EntityInfo info;
                 if (skillInfo.ConfigData.targetType == (int)SkillTargetType.Enemy || skillInfo.ConfigData.targetType == (int)SkillTargetType.RandEnemy) {
                     info = GetNearstTargetHelper(entity, CharacterRelation.RELATION_ENEMY);
                 } else {
                     info = GetNearstTargetHelper(entity, CharacterRelation.RELATION_FRIEND);
                 }
                 if (null != info) {
                     aiInfo.Target = info.GetId();
                 }
             }
             if (aiInfo.Target > 0) {
                 logic.NotifyAiSkill(entity, skillId);
             }
         }
     } else if(!entity.GetSkillStateInfo().IsSkillActivated()) {
         logic.AiSendStoryMessage(entity, "npc_skill_finish:" + entity.GetUnitId(), entity.GetId());
         logic.AiSendStoryMessage(entity, "obj_skill_finish", entity.GetId());
         logic.ChangeToState(entity, (int)AiStateId.Idle);
     }
 }
开发者ID:dreamanlan,项目名称:CSharpGameFramework,代码行数:30,代码来源:AiLogicUtility.cs

示例4: DoPursuitCommandState

 internal static void DoPursuitCommandState(EntityInfo entity, long deltaTime, AbstractAiStateLogic logic)
 {
     AiStateInfo info = entity.GetAiStateInfo();
     info.Time += deltaTime;
     if (info.Time > 200) {
         EntityInfo target = AiLogicUtility.GetLivingCharacterInfoHelper(entity, info.Target);
         if (null != target) {
             float minDist = entity.GetRadius() + target.GetRadius();
             float dist = (float)entity.GetActualProperty().AttackRange + minDist;
             float distGoHome = entity.GohomeRange;
             Vector3 targetPos = target.GetMovementStateInfo().GetPosition3D();
             ScriptRuntime.Vector3 srcPos = entity.GetMovementStateInfo().GetPosition3D();
             float dir = Geometry.GetYRadian(new Vector2(targetPos.X, targetPos.Z), new Vector2(srcPos.X, srcPos.Z));
             targetPos.X += (float)(minDist * Math.Sin(dir));
             targetPos.Z += (float)(minDist * Math.Cos(dir));
             float powDist = Geometry.DistanceSquare(srcPos, targetPos);
             if (powDist < dist * dist) {
                 logic.AiSendStoryMessage(entity, "npc_pursuit_finish:" + entity.GetUnitId(), entity.GetId());
                 logic.AiSendStoryMessage(entity, "obj_pursuit_finish", entity.GetId());
                 logic.NotifyAiStopPursue(entity);
                 logic.ChangeToState(entity, (int)AiStateId.Idle);
             } else {
                 logic.NotifyAiPursue(entity, targetPos);
             }
         } else {
             logic.AiSendStoryMessage(entity, "npc_pursuit_exit:" + entity.GetUnitId(), entity.GetId());
             logic.AiSendStoryMessage(entity, "obj_pursuit_exit", entity.GetId());
             logic.NotifyAiStopPursue(entity);
             logic.ChangeToState(entity, (int)AiStateId.Idle);
         }
     }
 }
开发者ID:dreamanlan,项目名称:CSharpGameFramework,代码行数:32,代码来源:AiLogicUtility.cs

示例5: DoPatrolCommandState

 internal static void DoPatrolCommandState(EntityInfo entity, long deltaTime, AbstractAiStateLogic logic)
 {
     AiStateInfo info = entity.GetAiStateInfo();
     info.Time += deltaTime;
     if (info.Time > 100) {
         info.Time = 0;
         EntityInfo target = null;
         if (info.IsExternalTarget) {
             target = AiLogicUtility.GetSeeingLivingCharacterInfoHelper(entity, info.Target);
             if (null == target) {
                 target = AiLogicUtility.GetNearstTargetHelper(entity, CharacterRelation.RELATION_ENEMY);
                 if (null != target)
                     info.Target = target.GetId();
             }
         } else {
             target = AiLogicUtility.GetNearstTargetHelper(entity, CharacterRelation.RELATION_ENEMY);
             if (null != target)
                 info.Target = target.GetId();
         }
         if (null != target) {
             logic.AiSendStoryMessage(entity, "obj_patrol_exit", entity.GetId());
             logic.AiSendStoryMessage(entity, string.Format("npc_patrol_exit:{0}", entity.GetUnitId()), entity.GetId());
             logic.ChangeToState(entity, (int)AiStateId.Idle);
         } else {
             AiData_ForPatrolCommand data = GetAiDataForPatrolCommand(entity);
             if (null != data) {
                 ScriptRuntime.Vector3 srcPos = entity.GetMovementStateInfo().GetPosition3D();
                 if (data.PatrolPath.HavePathPoint && !data.PatrolPath.IsReached(srcPos)) {
                     logic.NotifyAiPursue(entity, data.PatrolPath.CurPathPoint);
                 } else {
                     data.PatrolPath.UseNextPathPoint();
                     if (data.PatrolPath.HavePathPoint) {
                         logic.NotifyAiPursue(entity, data.PatrolPath.CurPathPoint);
                     } else {
                         if (data.IsLoopPatrol) {
                             logic.AiSendStoryMessage(entity, "obj_patrol_restart", entity.GetId());
                             logic.AiSendStoryMessage(entity, string.Format("npc_patrol_restart:{0}", entity.GetUnitId()), entity.GetId());
                             data.PatrolPath.Restart();
                         } else {
                             logic.AiSendStoryMessage(entity, "obj_patrol_finish", entity.GetId());
                             logic.AiSendStoryMessage(entity, string.Format("npc_patrol_finish:{0}", entity.GetUnitId()), entity.GetId());
                             logic.NotifyAiStopPursue(entity);
                             logic.ChangeToState(entity, (int)AiStateId.Idle);
                         }
                     }
                 }
                 info.HomePos = entity.GetMovementStateInfo().GetPosition3D();
             } else {
                 logic.NotifyAiStopPursue(entity);
                 logic.ChangeToState(entity, (int)AiStateId.Idle);
             }
         }
     }
 }
开发者ID:dreamanlan,项目名称:CSharpGameFramework,代码行数:54,代码来源:AiLogicUtility.cs

示例6: DoMoveCommandState

        internal static void DoMoveCommandState(EntityInfo entity, long deltaTime, AbstractAiStateLogic logic)
        {
            //执行状态处理
            AiData_ForMoveCommand data = GetAiDataForMoveCommand(entity);
            if (null == data) return;

            if (!data.IsFinish) {
                if (WayPointArrived(entity, data)) {
                    Vector3 targetPos = new Vector3();
                    MoveToNext(entity, data, ref targetPos);
                    if (!data.IsFinish) {
                        logic.NotifyAiPursue(entity, targetPos);
                    }
                } else {
                    AiStateInfo info = entity.GetAiStateInfo();
                    info.Time += deltaTime;
                    if (info.Time > 500) {
                        info.Time = 0;
                        Vector3 targetPos = data.WayPoints[data.Index];
                        logic.NotifyAiPursue(entity, targetPos);
                    }
                }
            }

            //判断是否状态结束并执行相应处理
            if (data.IsFinish) {
                logic.AiSendStoryMessage(entity, "npc_arrived:" + entity.GetUnitId(), entity.GetId());
                logic.AiSendStoryMessage(entity, "obj_arrived", entity.GetId());
                logic.NotifyAiStopPursue(entity);
                logic.ChangeToState(entity, (int)AiStateId.Idle);
            }
        }
开发者ID:dreamanlan,项目名称:CSharpGameFramework,代码行数:32,代码来源:AiLogicUtility.cs

示例7: OnEntityKilled

        private void OnEntityKilled(EntityInfo ni)
        {
            int leftEnemyCt = GetBattleNpcCount((int)CampIdEnum.Blue, CharacterRelation.RELATION_ENEMY);
            int leftFriendCt = GetBattleNpcCount((int)CampIdEnum.Blue);

            m_StorySystem.SendMessage("obj_killed", ni.GetId(), leftEnemyCt, leftFriendCt);
            m_StorySystem.SendMessage("npc_killed:" + ni.GetUnitId(), ni.GetId(), leftEnemyCt, leftFriendCt);
        }
开发者ID:dreamanlan,项目名称:CSharpGameFramework,代码行数:8,代码来源:Scene_Npc.cs

示例8: NotifyAiMeetEnemy

 public void NotifyAiMeetEnemy(EntityInfo entity)
 {
     if (null != OnAiMeetEnemy) {
         OnAiMeetEnemy(entity);
     }
     AiSendStoryMessage(entity, "obj_meet_enemy", entity.GetId());
     AiSendStoryMessage(entity, "npc_meet_enemy:" + entity.GetUnitId(), entity.GetId());
 }
开发者ID:dreamanlan,项目名称:CSharpGameFramework,代码行数:8,代码来源:IAiLogic.cs


注:本文中的GameFramework.EntityInfo.GetUnitId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。