コード例 #1
0
ファイル: MPDataCreator.cs プロジェクト: zcvdf/MightyPillar
    public void EditorCreateDataEnd()
    {
        if (mCreateDataJob == null || mCreateDataJob.QuadTrees == null)
        {
            return;
        }
        PillarSetting setting = mCreateDataJob.CreateSetting();

        //finaliz the tree data
        for (int i = 0; i < mCreateDataJob.QuadTrees.Length; ++i)
        {
            QuadTreeNodeSerializable node        = (QuadTreeNodeSerializable)mCreateDataJob.QuadTrees[i];
            QuadTreeBase             replaceLeaf = QuadTreeNode.CombineTree(node, 0.5f * mCreateDataJob.sliceSize[0],
                                                                            0.5f * mCreateDataJob.sliceSize[1], mCreateDataJob.heightPerGrade, mCreateDataJob.slopeErr);
            if (replaceLeaf != null)
            {
                mCreateDataJob.QuadTrees[i] = replaceLeaf;
            }
        }
        //
        string path = string.Format("{0}/MightyPillar/Resources/{1}.bytes", Application.dataPath, DataName);

        MPFileUtil.SaveData(path, setting, mCreateDataJob.QuadTrees);
        MPDataDisplayer displayer = gameObject.GetComponent <MPDataDisplayer>();

        if (displayer != null)
        {
            displayer.OnCreatorRegenData();
        }
    }
コード例 #2
0
ファイル: MPDataDisplayer.cs プロジェクト: zcvdf/MightyPillar
    public void EditorRefreshData()
    {
        MPDataCreator creator = gameObject.GetComponent <MPDataCreator>();

        if (creator == null)
        {
            return;
        }
        string     path = string.Format("{0}/MightyPillar/Resources/{1}.bytes", Application.dataPath, creator.DataName);
        PillarData data = MPFileUtil.LoadData(path, creator.DataName);

        //create display data
        mSlices.Clear();
        mCubes.Clear();
        Handles.color = Color.green;
        List <DisplaySlice> lSlices  = new List <DisplaySlice>();
        Vector3             startPos = new Vector3(data.setting.center[0], data.setting.center[1], data.setting.center[2]);

        startPos.x -= data.setting.maxX * data.setting.sliceSize[0] * 0.5f;
        startPos.y -= (data.setting.heightValRange[1] - data.setting.heightValRange[0]) * 0.5f;
        startPos.z -= data.setting.maxZ * data.setting.sliceSize[1] * 0.5f;
        for (int x = 0; x < data.setting.maxX; ++x)
        {
            for (int z = 0; z < data.setting.maxZ; ++z)
            {
                data.GetDisplaySlice(startPos.x, startPos.z, x, z, lSlices);
            }
        }
        for (int s = 0; s < lSlices.Count; ++s)
        {
            DisplaySlice slice = lSlices[s];
            if (slice.flag > 0 && s + 1 < lSlices.Count)
            {
                MyDisplayCube cube = new MyDisplayCube();
                Vector3       c0   = slice.min[0] * Vector3.right + slice.min[1] * Vector3.forward + slice.height * Vector3.up;
                DisplaySlice  next = lSlices[s + 1];
                Vector3       c1   = next.max[0] * Vector3.right + next.max[1] * Vector3.forward + next.height * Vector3.up;
                cube.center = 0.5f * (c0 + c1);
                cube.size   = c1 - c0;
                mCubes.Add(cube);
            }
            else
            {
                MyDisplaySlice myslice = new MyDisplaySlice();
                myslice.verts = new Vector3[]
                {
                    slice.min[0] * Vector3.right + slice.min[1] * Vector3.forward + slice.height * Vector3.up,
                    slice.min[0] * Vector3.right + slice.max[1] * Vector3.forward + slice.height * Vector3.up,
                    slice.max[0] * Vector3.right + slice.max[1] * Vector3.forward + slice.height * Vector3.up,
                    slice.max[0] * Vector3.right + slice.min[1] * Vector3.forward + slice.height * Vector3.up,
                };
                mSlices.Add(myslice);
            }
        }
    }
コード例 #3
0
ファイル: MPDemo.cs プロジェクト: zcvdf/MightyPillar
    // Start is called before the first frame update
    void Start()
    {
        MPDataCreator creator = gameObject.GetComponent <MPDataCreator>();

        if (creator != null)
        {
            string     path = string.Format("{0}/MightyPillar/Resources/{1}.bytes", Application.dataPath, creator.DataName);
            PillarData data = MPFileUtil.LoadData(path, creator.DataName);
            data.setting.boundHeight    = BoundHeight;
            data.setting.jumpableHeight = JumpableHeight;
            mPathPinder = new MPUnityAStar(data);
        }
    }