Пример #1
0
    private void Start()
    {
        NodeNavMesh navMesh = FindObjectOfType <NodeNavMesh>();
        Node        mNode   = navMesh.NodeFromWorldPoint(transform.position);

        nodes = navMesh.GetNodesArraund(mNode, ((int)RadiusSpawnArea / 2));
        StartCoroutine(Spawning());
    }
Пример #2
0
    public static NodeNavMesh CreateNavMesh(GameObject where, Tilemap worldTerrain)
    {
        where.SetActive(false);
        NodeNavMesh myC = where.AddComponent <NodeNavMesh>();

        myC.worldTerrain = worldTerrain;
        where.SetActive(true);

        return(myC);
    }
Пример #3
0
    private void Awake()
    {
        pixelShader   = Resources.Load <Material>("Materials/PixelSnapMat");
        ground        = Resources.Load <Tile>("Tiles/Ground_Tile");
        backGround    = Resources.Load <Tile>("Tiles/BackGround_Tile");
        SpawnerPrefab = Resources.Load <GameObject>("Prefabs/Spawner");
        chunkSize     = GameManager.Instance.Settings.chunkSize;

        width  = worldInfo.worldSizeInChunks.x;
        heigth = worldInfo.worldSizeInChunks.y;

        if (worldInfo.chunks == null)
        {
            worldInfo.chunks = new ChunkInfo[width][];
            for (int i = 0; i < width; i++)
            {
                worldInfo.chunks[i] = new ChunkInfo[heigth];
            }
        }


        SetWorldColor(worldInfo.color);

        Physics2D.gravity = new Vector2(0, worldInfo.gravity);

        int layers = 2;

        for (int i = 0; i < layers; i++)
        {
            tileMaps.Add(SetupTilemap());
        }
        SetDungeons();
        SetUpWorld();
        navMesh = NodeNavMesh.CreateNavMesh(gameObject, tileMaps[0]);
        tileMaps[0].GetComponent <TilemapRenderer>().material = Resources.Load <Material>("Materials/GoundMat");
        tileMaps[0].GetComponent <TilemapRenderer>().material.SetColor("_Color1", worldInfo.color);

        SetSpawners();
        SetWorldLimits();
        FindObjectOfType <Player>().OnDiggingToDir += CheckDestruction;
        worldInfo.Save();
        TransformUtility.ChangeLayersRecursively(transform, gameObject.layer);
    }
Пример #4
0
 private void Awake()
 {
     owner     = GetComponent <AICharacter>();
     nodeMesh  = FindObjectOfType <NodeNavMesh>();//Get a reference to the game manager
     isStopped = true;
 }
Пример #5
0
 private void Awake()
 {
     world = FindObjectOfType <NodeNavMesh>();
 }