public DataCenter() { PlayerState = new PlayerState(); KeyConatactData = new KeyContactData(); RuntimeTasks = new RuntimeTasksData(); gameRunnedState = new GameRunnedState(); RuntimeTaskMap = new TaskMap.RunTimeTaskData(); BusinessmanStates = new BusinessmanStates(); GameRunningStaetData = new GameRunningStateData(); ActionInteractiveStateData = new ActionInteractiveStateData(); SceneStateDatas = new SceneStateDatas(); }
/// <summary> /// 加载 /// </summary> /// <param name="isEditor">是否是编辑器</param> public void Load(bool isEditor = false) { if (string.IsNullOrEmpty(actionInteractivePrefabName)) { ActionInteractiveObjPrefab = null; } if (ActionInteractiveObjPrefab == null) { if (!string.IsNullOrEmpty(actionInteractivePrefabName)) { ActionInteractiveObjPrefab = Resources.Load <GameObject>(prefabDirectoryPath + "/" + actionInteractivePrefabName); } } if (ActionInteractiveObj == null && ActionInteractiveObjPrefab != null) { ActionInteractiveObj = GameObject.Instantiate <GameObject>(ActionInteractiveObjPrefab, ActionInteractiveLocation, Quaternion.identity); ActionInteractiveObj.transform.eulerAngles = ActionInteractiveAngle; ActionInteractiveObj.name = ActionInteractiveName; if (isEditor)//如果是编辑器直接返回 { return; } ActionInteractiveDataInfoMono addScript = null; switch (ActionInteractiveType) { case EnumActionInteractiveType.None: //此时的otherValue为null addScript = ActionInteractiveObj.AddComponent <ActionInteractiveDataInfoMono>(); break; case EnumActionInteractiveType.TreasureBox: //此时的otherValue为物品与数量之间的字典 addScript = ActionInteractiveObj.AddComponent <ActionInteractiveDataInfoMono_TreasureBox>(); break; case EnumActionInteractiveType.Other: //此时的otherValue为OtherDataStruct数据 if (OtherValue != null) { OtherDataStruct otherDataStruct = OtherValue as OtherDataStruct; if (otherDataStruct != null && otherDataStruct.ActionInterativeClass != null) { Component component = ActionInteractiveObj.AddComponent(otherDataStruct.ActionInterativeClass); addScript = component as ActionInteractiveDataInfoMono; } } break; default: break; } if (addScript == null) { return; } addScript.ActionInteractiveDataInfo = this; ActionInteractiveStateData actionInteractiveStateData = DataCenter.Instance.GetEntity <ActionInteractiveStateData>(); if (actionInteractiveStateData != null) { if (!actionInteractiveStateData.SceneDic.ContainsKey(SceneName)) { actionInteractiveStateData.SceneDic.Add(SceneName, new ActionInteractiveStateData.SceneData()); } ActionInteractiveStateData.SceneData sceneData = actionInteractiveStateData.SceneDic[SceneName]; if (!sceneData.IDDic.ContainsKey(ActionInteractiveID)) { sceneData.IDDic.Add(ActionInteractiveID, null); } addScript.LoadData(sceneData.IDDic[ActionInteractiveID], temp => sceneData.IDDic[ActionInteractiveID] = temp); } } }