Beispiel #1
0
        public GameObject CreateEntityModel(Ientity entity, UInt64 sGUID, Vector3 dir, Vector3 pos)
        {
            if (entity != null)
            {
                int id = (int)entity.ObjTypeID;
                this.SetCommonProperty(entity, id);
                if (entity.ModelName == null || entity.ModelName == "")
                {
                    return(null);
                }
                string path = GameDefine.GameConstDefine.LoadMonsterModels;


                //创建GameObject
                string resPath = path + entity.ModelName;
                entity.realObject = GameObjectPool.Instance.GetGO(resPath);
                if (entity.realObject == null)
                {
                    Debug.LogError("entity realObject is null");
                }

                //填充Entity信息
                entity.resPath      = resPath;
                entity.objTransform = entity.realObject.transform;

                entity.realObject.transform.localPosition = pos;
                entity.realObject.transform.localRotation = Quaternion.LookRotation(dir);


                if (entity is Iplayer)
                {
                    entity.entityType = EntityType.Player;

                    if (entity is Iselfplayer)
                    {
                        PlayerManager.Instance.LocalPlayer = (Iselfplayer)entity;
                    }
                }
                else
                {
                    entity.entityType = (EntityType)ConfigReader.GetNpcInfo(id).NpcType;
                    if (entity.entityType == EntityType.Monster && (int)entity.EntityCamp >= (int)EntityCampType.CampTypeA)
                    {
                        entity.entityType = EntityType.AltarSoldier;
                    }
                    entity.ColliderRadius = ConfigReader.GetNpcInfo(id).NpcCollideRadius / 100f;
                }

                if (entity.NPCCateChild != ENPCCateChild.eNPCChild_BUILD_Shop)
                {
                    entity.CreateXueTiao();
                }

                AddEntityComponent(entity);
                return(entity.realObject);
            }
            return(null);
        }
Beispiel #2
0
 public void DeltLockTargetXuetiao(Ientity target)
 {
     if (this.SyncLockTarget != null && this.SyncLockTarget.entityType == EntityType.Building)
     {
         this.SyncLockTarget.DestroyXueTiao();
     }
     if (target != null && target.entityType == EntityType.Building)
     {
         target.CreateXueTiao();
     }
 }