Esempio n. 1
0
        public ED_ActorCom CreateActor(ActorCnf actorData)
        {
            ED_MapAreaCom areaCom = GetArea();

            if (areaCom == null)
            {
                Debug.LogError("创建地图失败,没有区域!!!!");
                return(null);
            }
            if (startUid > endUid)
            {
                Debug.LogError("此地图Uid已用完!!!!");
                return(null);
            }

            ED_ActorCom actorCom = MapEditorDef.CreateActorGo();

            actorCom.Init(CalcActorUid(), actorData.id, actorData.name, actorData.isPlayer, this);

            //预制体
            if (actorData.prefab != null)
            {
                GameObject actorPrefab = (GameObject)PrefabUtility.InstantiatePrefab(actorData.prefab.GetObj());
                MapEditorHelper.SetParent(actorPrefab.gameObject, actorCom.gameObject);
            }

            areaCom.AddActor(actorCom);

            return(actorCom);
        }
Esempio n. 2
0
        private List <ActorModel> CollectMapDefaultActors(GameObject mapGo)
        {
            defaultActorUid = -100;
            if (mapGo == null)
            {
                Debug.LogError("地图导出失败,没有地图预制体" + name);
                return(null);
            }
            List <ActorModel> actors = new List <ActorModel>();

            Transform actorRoot = mapGo.transform.Find("DefaultActor");

            if (actorRoot != null)
            {
                for (int i = 0; i < actorRoot.childCount; i++)
                {
                    Transform actor      = actorRoot.GetChild(i).transform;
                    ActorCnf  actorModel = ED_MapCom.GetActorCnf(actor.name);
                    if (actorModel != null)
                    {
                        ActorModel actorData = new ActorModel();
                        actorData.uid      = defaultActorUid--;
                        actorData.id       = actorModel.id;
                        actorData.pos      = ED_ActorCom.HandlePos(transform.position);
                        actorData.roate    = ED_ActorCom.HandlePos(transform.localEulerAngles);
                        actorData.scale    = ED_ActorCom.HandlePos(transform.localScale);
                        actorData.isActive = gameObject.activeSelf;

                        actors.Add(actorData);
                    }
                }
            }
            return(actors);
        }
Esempio n. 3
0
        private void CreateMainActor(ActorModel actor)
        {
            ActorCnf actorCnf = Config.ActorCnf[actor.id];

            //预制体
            GameObject assetGo = LoadHelper.LoadPrefab(actorCnf.prefab.ObjName);
            GameObject actorGo = GameObject.Instantiate(assetGo);

            actorGo.transform.SetParent(PlayerRoot.transform);

            //添加组件
            PlayerActor = actorGo.AddComponent <ActorObj>();
            PlayerActor.Init(actor, currArea);

            //跟随
            LCECS.ECSLayerLocate.Info.GetSensor <GlobalSensor>(LCECS.SensorType.Global).FollowActor.Value = PlayerActor;
        }
Esempio n. 4
0
        private void CreateActorObj(ActorModel actor)
        {
            ActorCnf actorCnf = Config.ActorCnf[actor.id];

            //预制体
            GameObject assetGo = LoadHelper.LoadPrefab(actorCnf.prefab.ObjName);
            GameObject actorGo = GameObject.Instantiate(assetGo);

            actorGo.transform.SetParent(ActorRootGo.transform);

            //添加组件
            ActorObj actorObj = actorGo.AddComponent <ActorObj>();

            actorObj.Init(actor, this);

            //保存
            Actors.Add(actor.uid, actorObj);
        }
Esempio n. 5
0
        public IConfig Clone()
        {
            ActorCnf cnf = new ActorCnf();

            return(cnf);
        }