示例#1
0
 void LoadMap()
 {
     using (var reader = new System.IO.BinaryReader(System.IO.File.OpenRead("test.map"))) {
         var width  = reader.ReadInt32();
         var height = reader.ReadInt32();
         map = new Game.Map(width, height);
         map.ReadData(reader);
         navi = new Game.Navigation(map);
         navi.ReadData(reader);
     }
 }
示例#2
0
    void RegenerateMap()
    {
        var dim = 1024;

        map = new Game.Map(dim, dim);
        for (int i = 0; i < 32; i += 1)
        {
            for (int j = 0; j < dim; j += 1)
            {
                // Walls. Sloped'+' shape in the middle.
                map.SetRawHeight(i + dim / 2 - 32, j, i * 2);
                map.SetRawHeight(j, i + dim / 2 - 32, i * 2);
                map.SetRawHeight(32 - i + dim / 2, j, i * 2);
                map.SetRawHeight(j, 32 - i + dim / 2, i * 2);
            }
        }
        for (int j = 0; j < dim; j += 1)
        {
            // Wall midline.
            map.SetRawHeight(dim / 2, j, 64);
            map.SetRawHeight(j, dim / 2, 64);
        }
        for (int i = 0; i < 64; i += 1)
        {
            for (int j = 0; j < 64; j += 1)
            {
                var dist = Mathf.Sqrt(j * j + i * i);
                if (dist < 64)
                {
                    // Circular pool at the corners.
                    map.SetRawHeight(i, j, -(int)(64 - dist) / 2);
                    map.SetRawHeight(i, -j, -(int)(64 - dist) / 2);
                    map.SetRawHeight(-i, j, -(int)(64 - dist) / 2);
                    map.SetRawHeight(-i, -j, -(int)(64 - dist) / 2);
                }
            }
        }

        navi = new Game.Navigation(map);
        navi.ComputeReachability();

        using (var writer = new System.IO.BinaryWriter(System.IO.File.Create("test.map"))) {
            writer.Write(map.width);
            writer.Write(map.depth);
            map.WriteData(writer);
            navi.WriteData(writer);
        }
    }
示例#3
0
 void Start()
 {
     testshit  = Object.FindObjectOfType <Testshit>();
     navMesh   = Object.FindObjectOfType <Testshit>().navi;
     uiManager = Object.FindObjectOfType <ListController>();
 }