Пример #1
0
 public static PathConfigManager GetInstance()
 {
     if (mInstance == null)
     {
         mInstance = new PathConfigManager();
     }
     return(mInstance);
 }
Пример #2
0
    void Initialize()
    {
        TimeManager.GetInstance().Initialize();
        EventManager.GetInstance().Initialize();
        PathConfigManager.GetInstance().Initialize();
        SeasonConfigManager.GetInstance().Initialize();
        GameTableManager.GetInstance().Initialize();
        UIManager.GetInstance().Initialize();
        UICommandSystem.GetInstance().Initialize();


        UIManager.GetInstance().Show("IslandSelect");
    }
Пример #3
0
    public void CreateFish(int fishid, Vector3 position, Vector3 eulerangle, int pathid, float speed, float unactiveTime)
    {
        Record_Fish record = mFishTable.GetRecord(fishid) as Record_Fish;
        GameObject  fish   = GetUnActiveFishFromCache(fishid);

        if (fish == null)
        {
            return;
        }
        fish.transform.parent        = mFishRoot;
        fish.layer                   = 8;
        fish.transform.localPosition = position;
        fish.transform.eulerAngles   = eulerangle;
        fish.SetActive(true);
        Fish fishcom = fish.AddComponent <Fish>();

        fishcom.FishKindId   = fishid;
        fishcom.Speed        = speed;
        fishcom.FishPathData = PathConfigManager.GetInstance().GetPath(pathid);
        fishcom.UnActiveTime = unactiveTime;
        fishcom.FishRecord   = record;
    }
Пример #4
0
    public void CreateFish()
    {
        float hBound  = 120;
        float yBottom = -70;
        float yUp     = 70;

        int[] temp = new int[2] {
            -1, 1
        };
        int flag = temp[Random.Range(0, 2)];

        Record_Fish record = mFishTable.GetRecord(Random.Range(0, 2)) as Record_Fish;
        GameObject  fish   = GameObject.Instantiate(ResourcesManager.GetInstance().LoadLocalAsset("FishPrefabs/" + record.prefabName) as GameObject);

        fish.transform.parent        = mFishRoot;
        fish.layer                   = 8;
        fish.transform.localPosition = new Vector3(hBound * flag, Random.Range(yBottom + 20, yUp - 20), Random.Range(96, 96 + 20));
        fish.transform.eulerAngles   = new Vector3(0, -90 * flag, 0);
        Fish fishcom = fish.AddComponent <Fish>();

        fishcom.Speed                   = 30.0f * Random.Range(1, 2);
        fishcom.FishPathData            = PathConfigManager.GetInstance().GetPath(Random.Range(0, 5));
        fishcom.FishPathData.renderPath = false;
    }
Пример #5
0
    public override void OnInspectorGUI()
    {
        Fish fish = (Fish)target;

        //if (fish.FishPathData == null)
        //{
        //    fish.FishPathData = ScriptableObject.CreateInstance<FishPath>();
        //    fish.FishPathData.isNewPath = true;
        //    EditorUtility.SetDirty(fish);
        //}



        if (fish.FishPathData != null)
        {
            EditorGUILayout.BeginHorizontal();
            fish.FishPathData.renderPath = EditorGUILayout.Toggle("Render Path", fish.FishPathData.renderPath);
            EditorGUILayout.EndHorizontal();
            if (fish.FishPathData.renderPath)
            {
                GUILayout.Space(10);
                fish.FishPathData.lineColour = EditorGUILayout.ColorField("Line Color", fish.FishPathData.lineColour);
                GUILayout.Space(5);
            }

            EditorGUILayout.BeginHorizontal();
            fish.Speed = EditorGUILayout.FloatField("Speed", fish.Speed);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            fish.FishPathData.mPathId = EditorGUILayout.IntField("PathId", fish.FishPathData.mPathId);
            EditorGUILayout.EndHorizontal();
        }

        GUILayout.Space(5);
        if (GUILayout.Button("Load"))
        {
            string filepath = EditorUtility.OpenFilePanel("Load", Application.dataPath + "/Resources/Pathes/", "bytes");
            if (filepath.Length > 0)
            {
                fish.FishPathData          = PathConfigManager.GetInstance().Load(filepath);
                fish.FishPathData.FileName = Path.GetFileName(filepath);
                EditorUtility.SetDirty(fish);
            }
        }

        GUILayout.Space(5);
        if (GUILayout.Button("Save"))
        {
            string savepath = EditorUtility.SaveFilePanel("Save", Application.dataPath + "/Resources/Pathes/", fish.FishPathData.FileName, "bytes");
            if (savepath.Length > 0)
            {
                PathConfigManager.GetInstance().Save(savepath, fish.FishPathData);
                AssetDatabase.Refresh();
                fish.FishPathData.FileName = Path.GetFileName(savepath);
            }
        }

        if (fish.FishPathData != null)
        {
            int numberOfControlPoints = fish.FishPathData.numberOfControlPoints;
            if (numberOfControlPoints > 0)
            {
                GUILayout.Space(5);
                if (GUILayout.Button("Reset Path"))
                {
                    if (EditorUtility.DisplayDialog("Resetting path?", "Are you sure you want to delete all control points?", "Delete", "Cancel"))
                    {
                        fish.FishPathData.ResetPath();
                        fish.FishPathData = null;
                        EditorUtility.SetDirty(fish);
                        return;
                    }
                }

                GUILayout.Space(10);
                GUILayout.Box(EditorGUIUtility.whiteTexture, GUILayout.Height(2), GUILayout.Width(Screen.width - 20));
                GUILayout.Space(3);

                //			//scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);
                for (int i = 0; i < numberOfControlPoints; i++)
                {
                    FishPathControlPoint point = fish.FishPathData.controlPoints[i];
                    point.highLight = GUILayout.Toggle(point.highLight, "HighLight");
                    point.color     = EditorGUILayout.ColorField("Line Colour", point.color);

                    point.mTime           = EditorGUILayout.FloatField("Time", point.mTime);
                    point.mSpeedScale     = EditorGUILayout.FloatField("SpeedScale", point.mSpeedScale);
                    point.mRotationChange = EditorGUILayout.FloatField("RotationChange", point.mRotationChange);


                    EditorGUILayout.BeginHorizontal();
                    if (GUILayout.Button("Delete"))
                    {
                        fish.FishPathData.DeletePoint(i);
                        numberOfControlPoints = fish.FishPathData.numberOfControlPoints;
                        if (numberOfControlPoints == 0)
                        {
                            fish.FishPathData = null;
                        }
                        EditorUtility.SetDirty(fish);
                        return;
                    }

                    if (GUILayout.Button("Add New Point After"))
                    {
                        fish.FishPathData.AddPoint(i + 1);
                        EditorUtility.SetDirty(fish);
                    }

                    EditorGUILayout.EndHorizontal();

                    GUILayout.Space(7);
                    GUILayout.Box(EditorGUIUtility.whiteTexture, GUILayout.Height(2), GUILayout.Width(Screen.width - 25));
                    GUILayout.Space(7);
                }
                //			//EditorGUILayout.EndScrollView();
            }
        }
        else
        {
            GUILayout.Space(5);
            if (GUILayout.Button("Add New Path"))
            {
                //Undo.RegisterSceneUndo("Create a new Camera Path point");
                fish.FishPathData = ScriptableObject.CreateInstance <FishPath>();
                fish.FishPathData.AddPoint();
                EditorUtility.SetDirty(fish);
            }
        }

        if (GUI.changed)
        {
            if (fish.FishPathData)
            {
                fish.FishPathData.CaculateFinePoints();
            }
            EditorUtility.SetDirty(fish);
            EditorApplication.MarkSceneDirty();
        }
    }