예제 #1
0
        //创建对象
        public virtual TData Spawn(string tdid, Vector3?spwanPoint = null, Quaternion?quaternion = null, int?team = null, long?rtid = null, string prefab = null)
        {
            if (tdid.IsInv())
            {
                return(null);
            }
            TData data = TDLuaMgr.Get <TData>(tdid).Copy <TData>();

            SpawnAdd(data, tdid, rtid, team);
            Callback_OnSpawn?.Invoke(data);
            return(data);
        }
예제 #2
0
        public virtual T Spawn(string id, params object[] ps)
        {
            if (id.IsInvStr())
            {
                return(null);
            }
            T prefab = GetData(id, ps);

            OnSpawned(id, prefab);
            Data.Add(prefab);
            Callback_OnSpawn?.Invoke(prefab);
            return(prefab);
        }
예제 #3
0
        public virtual TData Spawn(string id, params object[] ps)
        {
            if (id.IsInvStr())
            {
                return(null);
            }
            TData prefab = Table.Find(id).Copy();

            OnSpawned(id, prefab);
            Data.Add(prefab);
            prefab.OnBeAdded(Mono);
            Callback_OnSpawn?.Invoke(prefab);
            return(prefab);
        }
예제 #4
0
        public virtual TUnit Spawn(string id, Vector3 spwanPoint, Quaternion?quaternion = null, int team = 0, params object[] ps)
        {
            if (id.IsInvStr())
            {
                return(null);
            }
            GameObject prefab    = GetPrefab(id, ps);
            GameObject charaGO   = Pool().Spawn(prefab, spwanPoint, quaternion);
            TUnit      unitChara = BaseCoreMono.GetUnityComponet <TUnit>(charaGO);

            OnSpawned(id, unitChara);
            unitChara.OnSpawnInit(id, team);
            Data.Add(unitChara);
            Callback_OnSpawn?.Invoke(unitChara);
            return(unitChara);
        }
예제 #5
0
        public virtual TUnit Spawn(string tdid, Vector3?spwanPoint = null, Quaternion?quaternion = null, int?team = null, long?rtid = null, string prefab = null)
        {
            if (tdid.IsInv())
            {
                return(null);
            }

            //获得配置数据
            TConfig config = TDLuaMgr?.Get <TConfig>(tdid);

            if (config == null)
            {
                CLog.Error("配置错误,没有这个配置TDID:" + tdid);
                return(null);
            }

            //获得prefab
            GameObject goPrefab;

            if (!prefab.IsInv())
            {
                goPrefab = BundleCacher.Get(prefab);
            }
            else
            {
                goPrefab = config?.GetPrefab();
            }
            if (goPrefab == null)
            {
                if (prefab != null)
                {
                    CLog.Error("没有这个CustomPrefab:{0}", prefab);
                }
                return(null);
            }

            GameObject charaGO = SpawnPool.Spawn(goPrefab, spwanPoint, quaternion);

            charaGO.name = tdid;
            TUnit unitChara = BaseCoreMono.GetUnityComponet <TUnit>(charaGO);

            SpawnAdd(unitChara, tdid, rtid, team);
            Callback_OnSpawn?.Invoke(unitChara);
            return(unitChara);
        }