// Start is called before the first frame update
    void Start()
    {
        Tilemap[] Tilemaps;
        Tilemaps = GameObject.FindObjectsOfType <Tilemap>();
        for (int i = 0; i < Tilemaps.Length; i++)
        {
            if (Tilemaps[i].tag == "tilemap")
            {
                tilemap = Tilemaps[i];
                break;
            }
        }
        load        = tilemap.GetComponent <Load>();
        pathfinding = tilemap.GetComponent <pathfinding>();
        Player      = GameObject.FindGameObjectWithTag("Player").transform;
        Tilemap[] tilemaps;
        tilemaps = GameObject.FindObjectsOfType <Tilemap>();
        for (int i = 0; i < tilemaps.Length; i++)
        {
            if (tilemaps[i].tag == "HighLight")
            {
                HighLight = tilemaps[i];
                break;
            }
        }

        EnemyMapPosition = tilemap.WorldToCell(transform.position);

        transform.position = tilemap.CellToWorld(EnemyMapPosition);
        playerMovement     = GameObject.FindGameObjectWithTag("Player").GetComponent <playerMovement>();
        nextTurn           = GameObject.FindGameObjectWithTag("Canvas").GetComponent <NextTurn>();
    }
Exemplo n.º 2
0
 // Start is called before the first frame update
 void Start()
 {
     MG   = TerrainGenerator.gameObject.GetComponent <MeshGenerator>();
     GD   = GridScript.gameObject.GetComponent <grid>();
     PS   = Pathfinding.gameObject.GetComponent <pathfinding>();
     CTTR = Trackchnager.gameObject.GetComponent <ChangeTextureToRoad>();
 }
Exemplo n.º 3
0
    public void InitGrid(cell[,] grid)
    {
        m_gridarr    = grid;
        m_pathfinder = new pathfinding(m_gridarr);
        cell target = m_gridarr[5, 9];

        PathFind(target);
    }
Exemplo n.º 4
0
 // Use this for initialization
 void Start()
 {
     grid     = FindObjectOfType <Grid>();
     unit     = FindObjectOfType <Unit>();
     pathFind = FindObjectOfType <pathfinding>();
     map1.SetActive(true);
     //map2.SetActive(false);
     mapIndex = 1;
     grid.CreateGrid();
 }
Exemplo n.º 5
0
    // Start is called before the first frame update
    private void Start()
    {
        PF = Pathfinder.gameObject.GetComponent <pathfinding>();
        MG = TerrainGenerator.gameObject.GetComponent <MeshGenerator>();



        nodeDiam = VerticiesRadius * 1;

        GridXsize = MG.XSize;
        GridZsize = MG.ZSize;
    }
Exemplo n.º 6
0
 // Start is called before the first frame update
 void Start()
 {
     PS = Pathfinding.gameObject.GetComponent <pathfinding>();
 }
Exemplo n.º 7
0
 void Awake()
 {
     instance = this;
     Pathfinding = GetComponent<pathfinding> ();
 }
Exemplo n.º 8
0
 void Awake()
 {
     instance    = this; //not sure if neccessary
     pathfinding = GetComponent <pathfinding>();
 }
Exemplo n.º 9
0
    // Use this for initialization
    void Start()
    {
        for (int i = 0; i < m_gridarr.GetLength(0); i++)
        {
            for (int j = 0; j < m_gridarr.GetLength(1); j++)
            {
                m_gridarr[i, j]     = new cell();
                m_gridarr[i, j].m_x = i;
                m_gridarr[i, j].m_y = j;
            }
        }
        m_pathfinder = new pathfinding(m_gridarr);

        m_floor = GameObject.Find("floor");
        m_test  = GameObject.Find("wall");
        m_creep = GameObject.Find("creep");

        MeshFilter m = m_floor.GetComponent <MeshFilter>();

        m_sizes    = m.mesh.bounds.size;
        m_cellsize = (int)m_sizes.x / m_gridnum;

        int bound0 = m_gridarr.GetUpperBound(0);
        int bound1 = m_gridarr.GetUpperBound(1);

        //test spawn vals
        m_gridarr[0, 2].m_val = (int)cellVal.wall;
        m_gridarr[4, 1].m_val = (int)cellVal.wall;
        m_gridarr[5, 1].m_val = (int)cellVal.wall;
        m_gridarr[6, 1].m_val = (int)cellVal.wall;
        m_gridarr[3, 1].m_val = (int)cellVal.wall;
        m_gridarr[7, 1].m_val = (int)cellVal.wall;
        m_gridarr[8, 1].m_val = (int)cellVal.wall;
        m_gridarr[5, 0].m_val = (int)cellVal.creep;

        cell target = m_gridarr[5, 9];

        for (int i = 0; i < m_gridarr.GetLength(0); i++)
        {
            for (int j = 0; j < m_gridarr.GetLength(1); j++)
            {
                //initialize position and size
                m_gridarr[i, j].m_size.x = m_cellsize;
                m_gridarr[i, j].m_size.z = m_cellsize;

                m_gridarr[i, j].m_pos.x = i * m_cellsize + (m_cellsize / 2);
                m_gridarr[i, j].m_pos.z = j * m_cellsize + (m_cellsize / 2);
                m_gridarr[i, j].m_pos.y = 0.5f;

                //initialize cell value and instantiate objects
                InitGridVal(i, j);
            }
        }

        /*m_path = m_pathfinder.FindPath(m_gridarr[5, 0], target);
         * foreach(var cell in m_path)
         * {
         *  Instantiate(GameObject.Find("creep"), m_gridarr[cell.m_x, cell.m_y].m_pos, Quaternion.identity);
         * }*/
        //var testnew = Instantiate(m_test, m_gridarr[0, 2].m_pos, Quaternion.identity);
        //var spawncreep = Instantiate(m_creep, m_gridarr[m_gridnum/2, 0].m_pos, Quaternion.identity);
    }