Esempio n. 1
0
    public void updatePlayer()
    {
        //locating the end point in the corner
        TilemapCaveGeneratorQ_6 a = endtilemap.GetComponent <TilemapCaveGeneratorQ_6>();

        int[,] data = a.caveGenerator.GetMap();
        int        max = 0;
        Vector3Int pos = new Vector3Int();

        for (int x = 0; x < a.gridSize; x++)
        {
            for (int y = a.gridSize - 1; y >= 0; y--)
            {
                int b = a.gridSize - y;
                if (data[x, y] != 1)
                {
                    int temp = x + b;
                    if (temp > max)
                    {
                        max = temp;
                        pos = new Vector3Int(x, y, 0);
                    }
                }
            }
        }
        endtilemap.SetTile(pos, tilebase);
        a.EndFlag = false;
    }
Esempio n. 2
0
    public void updatePlayer()
    {
        // locating the player in the corner of the cave
        TilemapCaveGeneratorQ_6 a = tilemap.GetComponent <TilemapCaveGeneratorQ_6>();

        int[,] data = a.caveGenerator.GetMap();
        int        min = 100000000;
        Vector3Int pos = new Vector3Int();

        for (int x = 0; x < a.gridSize; x++)
        {
            for (int y = a.gridSize - 1; y >= 0; y--)
            {
                int b = a.gridSize - y;
                if (data[x, y] != 1)
                {
                    int temp = x + b;
                    if (temp < min)
                    {
                        min = temp;
                        pos = new Vector3Int(x, y, 0);
                    }
                }
            }
        }

        transform.position = tilemap.CellToWorld(pos);
        a.playerFlag       = false;
    }
Esempio n. 3
0
    void locatTheEnemy()
    {
        //locate the enemy in a random position in the cave
        TilemapCaveGeneratorQ_6 a = tilemap.GetComponent <TilemapCaveGeneratorQ_6>();

        int[,] data = a.caveGenerator.GetMap();

        int x = 0, y = 0;

        while (data[x, y] == 1)
        {
            x = Random.Range(0, a.gridSize);
            y = Random.Range(0, a.gridSize);
        }
        transform.position = tilemap.CellToWorld(new Vector3Int(x, y, 0));

        //if its done locating the enemy false the flag for the next level
        if (enemyNumber == 1)
        {
            a.E1flag = false;
        }
        else
        {
            a.E2flag = false;
        }
    }
Esempio n. 4
0
    // Update is called once per frame
    void Update()
    {
        //checking if the map done generating the cave
        TilemapCaveGeneratorQ_6 a = endtilemap.GetComponent <TilemapCaveGeneratorQ_6>();

        if (a != null && a.EndFlag)
        {
            updatePlayer();
        }
    }
Esempio n. 5
0
    // Update is called once per frame
    void Update()
    {
        TilemapCaveGeneratorQ_6 a = tilemap.GetComponent <TilemapCaveGeneratorQ_6>();

        //if its done generating the cave loacte the player
        if (a != null && a.playerFlag)
        {
            updatePlayer();
        }
    }
Esempio n. 6
0
    // Update is called once per frame
    void Update()
    {
        bool e = false;
        TilemapCaveGeneratorQ_6 a = tilemap.GetComponent <TilemapCaveGeneratorQ_6>();

        if (a != null)//checking which enemy is
        {
            if (enemyNumber == 1)
            {
                e = a.E1flag;
            }
            else
            {
                e = a.E2flag;
            }
        }
        // if the map done generating the cave locate the enemy
        if (a != null && e)
        {
            locatTheEnemy();
        }
    }
Esempio n. 7
0
 // Start is called before the first frame update
 void Start()
 {
     //assign to current tilemap size and the cave generator
     a    = tilemap.GetComponent <TilemapCaveGeneratorQ_6>();
     size = a.gridSize;
 }