public void AddRole <T>(RoleEntityData data)
            where T : RoleEntityBase
        {
            if (data == null || data.ActorType == ActorType.Unknown || data.CampType == BattleCampType.None)
            {
                return;
            }

            data.Position = GlobalTools.NavSamplePosition(data.Position);

            GameEntry.Entity.ShowRole <T>(data);
            m_AllRoles.Add(data.Id);
            m_CampActors[data.CampType].Add(data.Id);
        }
        private void InitNpc()
        {
            for (int i = 0; i < Config.Npcs.Count; i++)
            {
                MapNpc mapdata = Config.Npcs[i];

                int            entityId = GameEntry.Entity.GenerateSerialId();
                RoleEntityData data     = new RoleEntityData(entityId, mapdata.Id, ActorType.Npc, BattleCampType.Neutral)
                {
                    Position = mapdata.Position,
                    Rotation = Quaternion.Euler(mapdata.Euler),
                    Scale    = mapdata.Scale
                };
                GameEntry.Entity.ShowRole <NpcRole>(data);
            }
        }
Beispiel #3
0
        protected override void OnShow(object userData)
        {
            base.OnShow(userData);

            m_EnemyEntityData = userData as RoleEntityData;
            if (m_EnemyEntityData == null)
            {
                Log.Error("playerEntityData is null");
                return;
            }

            ActorType      actorType = m_EnemyEntityData.ActorType;
            BattleCampType campType  = m_EnemyEntityData.CampType;

            Actor = new ActorEnemy(this, actorType, campType, m_CharacterController,
                                   m_Animator);
            Actor.Init();
        }
        public int CreateEnemy(int typeId, TransformParam param)
        {
            if (typeId <= 0 || param == null)
            {
                return(0);
            }

            int            entityId = GameEntry.Entity.GenerateSerialId();
            RoleEntityData data     = new RoleEntityData(entityId, typeId, ActorType.Monster, BattleCampType.Enemy)
            {
                Position = param.Position,
                Rotation = Quaternion.Euler(param.EulerAngles),
                Scale    = param.Scale
            };

            AddRole <EnemyRole>(data);
            return(entityId);
        }
 //-----------------简化使用函数----------------
 public static void ShowRole <T>(this EntityComponent entityComponent, RoleEntityData data) where  T : RoleEntityBase
 {
     entityComponent.ShowActorEntity(typeof(T), data);
 }