コード例 #1
0
    public void Initialize(string filePath)
    {
        XmlDocument doc = new XmlDocument();

        doc.Load(filePath);
        MemoryStream ms = new MemoryStream();

        doc.Save(ms);

        byte[]       data      = ms.ToArray();
        MemoryStream navmeshMs = new MemoryStream(data);

        XmlSerializer     xmlSerializer     = new XmlSerializer(typeof(NavMeshSerializer));
        NavMeshSerializer navmeshSerializer = ((NavMeshSerializer)xmlSerializer.Deserialize(navmeshMs));

        LunaNav.NavMesh navmesh = navmeshSerializer.Reconstitute();
        InitializeQuery(navmesh);

        Crowd = new Crowd();

        Crowd.Init(50, 0.6f, _navMeshQuery.NavMesh);
        Crowd.Filter = filter;

        initializedCrowd = true;
    }
コード例 #2
0
    public void Initialize()
    {
#if UNITY_WEBPLAYER
        var           asset         = Resources.Load(FilePath, typeof(TextAsset)) as TextAsset;
        MemoryStream  f             = new MemoryStream(asset.bytes);
        XmlSerializer xmlSerializer = new XmlSerializer(typeof(NavMeshSerializer));
        InitializeQuery(((NavMeshSerializer)xmlSerializer.Deserialize(f)).Reconstitute());
#else
        if (Path.GetExtension(FilePath).Equals(""))
        {
            var           asset         = Resources.Load(FilePath, typeof(TextAsset)) as TextAsset;
            MemoryStream  f             = new MemoryStream(asset.bytes);
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(NavMeshSerializer));
            InitializeQuery(((NavMeshSerializer)xmlSerializer.Deserialize(f)).Reconstitute());
        }
        else
        {
            FileStream f = null;
            f = File.OpenRead(FilePath);
            if (FilePath.LastIndexOf(".xml", StringComparison.OrdinalIgnoreCase) >= 0)
            {
                XmlSerializer xmlSerializer = new XmlSerializer(typeof(NavMeshSerializer));
                InitializeQuery(((NavMeshSerializer)xmlSerializer.Deserialize(f)).Reconstitute());
            }
            else if (FilePath.LastIndexOf(".json", StringComparison.OrdinalIgnoreCase) >= 0)
            {
                StreamReader   sr         = new StreamReader(f);
                JsonReader     reader     = new JsonTextReader(sr);
                JsonSerializer serializer = new JsonSerializer();
                InitializeQuery(serializer.Deserialize <NavMeshSerializer>(reader).Reconstitute());
            }
            else if (FilePath.LastIndexOf(".bytes", StringComparison.OrdinalIgnoreCase) >= 0)
            {
                XmlSerializer xmlSerializer = new XmlSerializer(typeof(NavMeshSerializer));
                InitializeQuery(((NavMeshSerializer)xmlSerializer.Deserialize(f)).Reconstitute());
            }
            else
            {
                BsonReader     reader     = new BsonReader(f);
                JsonSerializer serializer = new JsonSerializer();
                InitializeQuery(serializer.Deserialize <NavMeshSerializer>(reader).Reconstitute());
            }
        }
#endif

        Actors = new List <DetourActor>();
        foreach (DetourActor detourActor in GameObject.FindObjectsOfType(typeof(DetourActor)))
        {
            Actors.Add(detourActor);
        }
        Crowd = new Crowd();

        Crowd.Init(Actors.Count, 0.6f, _navMeshQuery.NavMesh);
        Crowd.Filter = filter;
    }
コード例 #3
0
    public void Initialize(string filePath)
    {
        TextAsset    asset = Resources.Load(filePath, typeof(TextAsset)) as TextAsset;
        MemoryStream f     = new MemoryStream(asset.bytes);

        XmlSerializer     xmlSerializer     = new XmlSerializer(typeof(NavMeshSerializer));
        NavMeshSerializer navmeshSerializer = ((NavMeshSerializer)xmlSerializer.Deserialize(f));

        LunaNav.NavMesh navmesh = navmeshSerializer.Reconstitute();
        InitializeQuery(navmesh);


        Crowd = new Crowd();
        Crowd.Init(50, 0.6f, _navMeshQuery.NavMesh);
        Crowd.Filter = filter;

        initializedCrowd = true;
    }
コード例 #4
0
    public void Initialize()
    {
        Actors = new List<DetourActor>();
        foreach (DetourActor detourActor in GameObject.FindObjectsOfType(typeof(DetourActor)))
        {
            Actors.Add(detourActor);
        }
        Crowd = new Crowd();

        Crowd.Init(Actors.Count, 0.6f, _navMeshQuery.NavMesh);
        Crowd.Filter = filter;
    }