示例#1
0
        static void SyncDataManual()
        {
            LevelDataIndex levelDataIndex = Resources.LoadAssetAtPath <LevelDataIndex>(StreamTools.GetStreamingAssetsPathInEditor() + ConstantData.MissionLevelDataIndexPath);

            if (!levelDataIndex)
            {
                levelDataIndex = ScriptableObject.CreateInstance <LevelDataIndex>();
                AssetDatabase.CreateAsset(levelDataIndex, StreamTools.GetStreamingAssetsPathInEditor() + ConstantData.MissionLevelDataIndexPath);
            }
            else
            {
                levelDataIndex.Clear();
            }

            System.IO.FileInfo[] fileInfos = StreamTools.GetAllFile(StreamTools.GetStreamingAssetsPathInEditor() + ConstantData.MissionLevelDataPath, "*-*");
            foreach (var v in fileInfos)
            {
                LevelData data = Resources.LoadAssetAtPath <LevelData>(StreamTools.GetStreamingAssetsPathInEditor() + ConstantData.MissionLevelDataPath + v.Name);
                data.SpecificPocket =
                    !(data.StartPunishmentPocket == PocketIndexes.None &&
                      data.StartRewardPocket == PocketIndexes.None);
                levelDataIndex.Add(data);
            }
            Debug.Log("Synchronize data finished");
        }
示例#2
0
 private LevelDataIndex GetLevelDataIndex()
 {
     if (m_LevelDataIndex == null)
     {
         m_LevelDataIndex = Resources.LoadAssetAtPath <LevelDataIndex>(StreamTools.GetStreamingAssetsPathInEditor() + ConstantData.MissionLevelDataIndexPath);
         if (!m_LevelDataIndex)
         {
             m_LevelDataIndex = ScriptableObject.CreateInstance <LevelDataIndex>();
             AssetDatabase.CreateAsset(m_LevelDataIndex, StreamTools.GetStreamingAssetsPathInEditor() + ConstantData.MissionLevelDataIndexPath);
         }
     }
     return(m_LevelDataIndex);
 }
示例#3
0
        void SyncData()
        {
            System.IO.FileInfo[] fileInfos = StreamTools.GetAllFile(StreamTools.GetStreamingAssetsPathInEditor() + ConstantData.MissionLevelDataPath, "*-*");

            if (fileInfos.Length != m_LevelDataIndex.Count)
            {
                Debug.Log("Level data indexes need synchronized, now synchronizing");
                m_LevelDataIndex.Clear();
                foreach (var v in fileInfos)
                {
                    LevelData data = Resources.LoadAssetAtPath <LevelData>(StreamTools.GetStreamingAssetsPathInEditor() + ConstantData.MissionLevelDataPath + v.Name);
                    m_LevelDataIndex.Add(data);
                }
            }
        }
示例#4
0
        void DrawOtherGUI()
        {
            GUI.BeginGroup(new Rect(0, AreaHeight + 2 * m_GridSize + m_OutlineRect.height - m_BackgroundRect.height, AreaWidth + 2 * m_GridSize + 100, 350));
            m_CurrentLevelData = EditorGUILayout.ObjectField("关卡数据文件: ", m_CurrentLevelData, typeof(LevelData), false) as LevelData;
            m_ShotCount        = EditorGUILayout.IntField("击杆数:", m_ShotCount);
            m_DescripID        = EditorGUILayout.IntField("描述ID : ", m_DescripID);
            m_LevelName        = EditorGUILayout.TextField("关卡名称:", m_LevelName);
            CheckDataEquals();
            if (GUILayout.Button("保存") && !string.IsNullOrEmpty(m_LevelName))
            #region Save configuration
            {
                LevelData data = ScriptableObject.CreateInstance <LevelData>();
                data.cueBallData = new LevelData.BallData(m_CueBall.id, m_CueBall.transform.position, m_CueBall.rect, BallType.WHITE);
                foreach (KeyValuePair <int, TouchObject> k in m_Balls)
                {
                    LevelData.BallData d = new LevelData.BallData(k.Key, k.Value.transform.position, k.Value.rect, k.Value.type);
                    data.ballDatas.Add(d);
                }
                foreach (var v in m_Pockets)
                {
                    if (v.pocketType == PocketType.Punishment)
                    {
                        data.StartPunishmentPocket |= v.pocketIndexes;
                    }
                    else if (v.pocketType == PocketType.Reward)
                    {
                        data.StartRewardPocket |= v.pocketIndexes;
                    }
                    else if (v.pocketType == PocketType.BlockOff)
                    {
                        data.BlockPockets |= v.pocketIndexes;
                    }
                }
                data.shotCount     = m_ShotCount;
                data.FileName      = m_LevelName;
                data.DescriptionID = m_DescripID;
                AssetDatabase.CreateAsset(data, StreamTools.GetStreamingAssetsPathInEditor() + "LevelDatas/" + m_LevelName + ".asset");
                m_CurrentLevelData = data;
                m_LevelDataIndex.Add(data);
            }
            #endregion //Save configuration
            GUI.skin.label.fontSize = 18;
            GUILayout.Label("说明:右键点击台球桌添加球。 右键点击非白球删除球。右键点击袋口(黑色圆)设置球袋类型(提供色盲模式^-^)");
            GUI.skin.label.fontSize = 12;

            GUI.EndGroup();
        }