Пример #1
0
 public void UpdateNavMesh()
 {
     foreach (GameObject go in GameObject.FindGameObjectsWithTag("Navable"))
     {
         NavigationBaker navigationBaker = go.GetComponent <NavigationBaker>();
         if (navigationBaker != null)
         {
             navigationBaker.Bake();
             Debug.Log("Telling " + go.name + " to re-bake navmesh");
         }
     }
 }
Пример #2
0
    public void SpawnLayout(GridSpace[,] gridSpaces, int numberOfSecureRooms)
    {
        col = gridSpaces.GetLength(0);
        row = gridSpaces.GetLength(1);

        roomLayout = new Room[col, row];

        // Order: Spawn Colliding Objects; Create NavMesh; Spawn Trigger Objects; Spawn Guards
        navMeshBaker = new NavigationBaker();
        SpawnRooms(gridSpaces, col, row);
        SpawnSideObjectives();
        navMeshBaker.CreateNavMesh();
        SpawnGuards(numberOfSecureRooms);
    }
Пример #3
0
    void Start()
    {
        agent        = GetComponent <NavMeshAgent>();
        target       = GameObject.Find("Character");
        baker        = FindObjectOfType <NavigationBaker>();
        gen          = FindObjectOfType <RoomGeneration>();
        playerScript = FindObjectOfType <Player>();
        //patrolBase.Find("Map");

        alive = true;

        state = State.PATROL;

        StartCoroutine("FSM");
    }
Пример #4
0
    private void GenerateMap()
    {
        if (UseRandomSeed)
        {
            Seed = DateTime.Now.ToString();
        }

        DateTime start = DateTime.Now;

        RandomFillMap(Seed, FillPercent);
        SmoothMap();
        ProcessMap();

        MeshGenerator meshGenerator = GetComponent <MeshGenerator>();

        meshGenerator.GenerateMesh(map, 1f);

        navMeshBaker = GetComponent <NavigationBaker>();
        navMeshBaker.Bake();

        Debug.Log(string.Format("Map generation total time: {0} ms",
                                (DateTime.Now - start).Milliseconds));
    }
Пример #5
0
    void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }

        if (levelGenerator)
        {
            Instantiate(levelGenerator);
        }
        if (player)
        {
            Instantiate(player, new Vector3(30, 0, 30), player.transform.rotation);
        }

        baker = GetComponent <NavigationBaker>();

        GameObject timer = Instantiate(gameTimerObject);

        gameTimerScript      = timer.GetComponent <GameTimer>();
        gameTimerScript.Time = gameTime;

        enemyText       = GameObject.FindGameObjectWithTag("EnemyText").GetComponent <Text>();
        startEnemyCount = GameObject.FindGameObjectsWithTag("Enemy").Length;
        enemyStartText  = enemyText.text;
        enemyText.text  = enemyStartText + startEnemyCount.ToString();

        candyText      = GameObject.FindGameObjectWithTag("Candy").GetComponent <Text>();
        candyStartText = candyText.text;
        candyText.text = candyStartText + startCandyCount.ToString();

        gameWin.SetActive(false);

        StartCoroutine(Fog());
    }
Пример #6
0
    private IEnumerator BakeNavMeshDelayedCoroutine()
    {
        yield return(new WaitForSeconds(0.5f));

        NavigationBaker.BakeNavMesh(navMeshSurface);
    }
 private void OnDisable()
 {
     baker.Dispose();
     baker = null;
 }
 private void OnEnable()
 {
     baker = new NavigationBaker();
 }