Пример #1
0
        public override object ExportData()
        {
            UpdateRect();

            AreaModel areaModel = new AreaModel();

            areaModel.pos        = transform.localPosition;
            areaModel.rect       = areaRect;
            areaModel.areaPrefab = AreaEnv.name;

            //演员
            ED_ActorCom[] actorComs = ActorRoot.GetComponentsInChildren <ED_ActorCom>(true);
            if (actorComs != null)
            {
                for (int i = 0; i < actorComs.Length; i++)
                {
                    ED_ActorCom tActorCom = actorComs[i];
                    areaModel.actors.Add((ActorModel)tActorCom.ExportData());
                }
            }

            //地图默认演员
            List <ActorModel> mapActors = CollectMapDefaultActors(tmpAreaEnv);

            if (mapActors != null && mapActors.Count > 0)
            {
                foreach (ActorModel actorData in mapActors)
                {
                    areaModel.actors.Add(actorData);
                }
            }

            //触发区域
            ED_MapTriggerCom[] triggerComs = TriggerRoot.GetComponentsInChildren <ED_MapTriggerCom>(true);
            if (triggerComs != null)
            {
                for (int i = 0; i < triggerComs.Length; i++)
                {
                    ED_MapTriggerCom tTriggerCom = triggerComs[i];
                    areaModel.triggers.Add(i + 1, (MapTriggerModel)tTriggerCom.ExportData());
                }
            }

            return(areaModel);
        }
Пример #2
0
        public MapModel ExportData()
        {
            MapModel mapData = new MapModel();

            mapData.mapId = mapId;

            for (int i = 0; i < AreaRoot.transform.childCount; i++)
            {
                ED_MapAreaCom areaCom = AreaRoot.transform.GetChild(i).GetComponent <ED_MapAreaCom>();
                if (areaCom != null)
                {
                    AreaModel areaModel = (AreaModel)areaCom.ExportData();
                    areaModel.areaId = i;
                    mapData.areas.Add(areaModel);
                }
            }

            //主角
            mapData.mainActor = null;
            for (int i = 0; i < mapData.areas.Count; i++)
            {
                for (int j = 0; j < mapData.areas[i].actors.Count; j++)
                {
                    if (mapData.areas[i].actors[j].isMainActor)
                    {
                        if (mapData.mainActor != null)
                        {
                            Debug.LogWarning($"具有多个主角>>>>>{mapData.areas[i].areaId}");
                        }
                        mapData.mainActor = mapData.areas[i].actors[j];
                        mapData.areas[i].actors.RemoveAt(j);
                    }
                }
            }

            return(mapData);
        }
Пример #3
0
 public MapArea(AreaModel model)
 {
     this.Id    = model.areaId;
     this.Model = model;
     this.Rect  = model.rect;
 }