UpdateSizeFromWidthDepth() 공개 메소드

public UpdateSizeFromWidthDepth ( ) : void
리턴 void
예제 #1
0
    private void initGraph(GridGraph g, Vector3 center, int width, int depth, int nodeSize)
    {
        g.center = center;
        g.width = width;
        g.depth = depth;
        g.nodeSize = nodeSize;
        g.maxSlope = 50;
        g.maxClimb = 0;

        g.autoLinkGrids = true;

        g.collision.collisionCheck = true;
        g.collision.diameter = 1.5f;
        g.collision.height = 3;
        g.collision.collisionOffset = 2;
        int obstacleLayer = LayerMask.NameToLayer("Obstacle");
        int obstacleMask = 1 << obstacleLayer;
        g.collision.mask = obstacleMask;
        g.collision.heightCheck = true;
        int groundLayer = LayerMask.NameToLayer("Ground");
        int groundMask = 1 << groundLayer;

        g.collision.heightMask = groundMask;

        g.UpdateSizeFromWidthDepth ();
        AstarPath.active.astarData.AddGraph(g);
    }
예제 #2
0
    private IEnumerator newMazeGame()
    {
        mainLight = GameObject.FindWithTag("MainLight");

        menuControl.loadingState = "Generating Maze...";
        MazeGenerator mazeGenerator = GameObject.FindWithTag("Maze").GetComponent <MazeGenerator>();

        yield return(new WaitForEndOfFrame());

        mazeGenerator.newMaze(5 * (((int)difficulty) + 1));
        yield return(new WaitForEndOfFrame());

        menuControl.loadingState = "Funerizing Maze...";
        yield return(mazeGenerator.StartCoroutine("removeRandomWalls"));

        menuControl.loadingState = "Generating navmesh...";
        Pathfinding.GridGraph graph = (Pathfinding.GridGraph)AstarPath.active.graphs[0];
        int   graphSize             = 50 * ((((int)difficulty) + 1));
        float pos = graphSize / 2 * graph.nodeSize;

        graph.width  = graphSize;
        graph.depth  = graphSize;
        graph.center = new Vector3(pos, 0, pos);
        graph.UpdateSizeFromWidthDepth();
        AstarPath.active.Scan();
        yield return(new WaitForEndOfFrame());

        menuControl.loadingState = "Generating keys and exit...";
        keysOnMap = (((int)difficulty) + 1) * 2;
        spawnControl.spawnPoints = new List <MazeNode>(mazeGenerator.spawnPoints);
        spawnControl.spawnKeys(keysOnMap);
        spawnControl.spawnDoor();
        yield return(new WaitForEndOfFrame());

        menuControl.loadingState = "Spawning player...";
        player = spawnControl.spawnPlayer();
        yield return(new WaitForEndOfFrame());

        menuControl.loadingState = "Spawning enemy...";
        enemies                  = new List <GameObject>();
        enemiesChasing           = new List <GameObject>();
        spawnControl.spawnPoints = new List <MazeNode>(mazeGenerator.spawnPoints);
        for (int i = 0; i < ((int)difficulty); i++)
        {
            spawnEnemy();
        }
        yield return(new WaitForEndOfFrame());

        menuControl.loadingState = "Initialising game...";
        audioControl.playAsset(ambience);
        StartCoroutine(updateParameterWithList(enemies, true));
        loading = false;
        setGameOver(false);
    }
예제 #3
0
    public void makepath()
    {
        FindAllStones();
        FindAllTrees();
        foreach (GameObject item in GameObject.FindGameObjectsWithTag("Mark"))
        {
            Destroy(item);
        }
        int msize = (int)fireplaceStats.maxDistance.Value;

        gGraph       = AstarPath.active.data.gridGraph;
        gGraph.width = msize;
        gGraph.depth = msize;
        gGraph.UpdateSizeFromWidthDepth();
        markLD.SetActive(true);
        markLU.SetActive(true);
        markRD.SetActive(true);
        markRU.SetActive(true);
        markLD.transform.position = transform.position + new Vector3(-msize / 4 + 0.2f, -msize / 4 + 1.5f);
        markLU.transform.position = transform.position + new Vector3(-msize / 4 + 0.2f, msize / 4 + 1);
        markRD.transform.position = transform.position + new Vector3(msize / 4 - 0.2f, -msize / 4 + 1.5f);
        markRU.transform.position = transform.position + new Vector3(msize / 4 - 0.2f, msize / 4 + 1);
        for (int i = -msize / 4; i < msize / 4; i += 10)
        {
            GameObject mark = GameObject.Instantiate(marker, transform.position + new Vector3(-msize / 4 + 0.2f, i), Quaternion.identity);
            mark.SetActive(true);
            mark.transform.parent = this.transform;
        }
        for (int i = -msize / 4; i < msize / 4; i += 10)
        {
            GameObject mark = GameObject.Instantiate(marker, transform.position + new Vector3(msize / 4 + 0.2f, i), Quaternion.identity);
            mark.SetActive(true);
            mark.transform.parent = this.transform;
        }
        for (int i = -msize / 4; i < msize / 4; i += 10)
        {
            GameObject mark = GameObject.Instantiate(marker, transform.position + new Vector3(i, msize / 4 + 0.2f), Quaternion.identity);
            mark.SetActive(true);
            mark.transform.parent = this.transform;
        }
        for (int i = -msize / 4; i < msize / 4; i += 10)
        {
            GameObject mark = GameObject.Instantiate(marker, transform.position + new Vector3(i, -msize / 4 + 0.2f), Quaternion.identity);
            mark.SetActive(true);
            mark.transform.parent = this.transform;
        }

        gGraph.center = transform.position;
        AstarPath.active.Scan();
    }
예제 #4
0
 void createGrah(GridGraph player, int x, int y, Vector3 center)
 {
     player = data.AddGraph(typeof(GridGraph)) as GridGraph;
     player.width = x;
     player.depth = y;
     player.center = center;
     player.nodeSize = 0.5f;
     player.UpdateSizeFromWidthDepth();
     player.neighbours = NumNeighbours.Four;
     player.collision.type = Pathfinding.ColliderType.Capsule;
     player.collision.diameter = 1f;
     player.collision.height = 1;
     player.collision.mask = LayerMask.GetMask("Ignore Raycast", "Border");
     player.collision.heightCheck = false;
     //player.collision.thickRaycast = true;
     AstarPath.active.Scan();
 }