Exemplo n.º 1
0
 void calibrate()
 {
     cellSizeY = height / linesNumber;
     cellSizeX = width / columnsNumber;
     //To check - Posibil memorylick. Ce era inainte in grid nu se sterge.
     grid       = new VisualObject[linesNumber, columnsNumber];
     spawnPoint = new gridPos((columnsNumber / 2 - 1), (linesNumber / 2 - 1));
 }
Exemplo n.º 2
0
 // Start is called before the first frame update
 void Start()
 {
     gridArray = new gridPos [xSize, ySize];
     for (int x = 0; x < xSize; x++)
     {
         for (int y = 0; y < ySize; y++)
         {
             GameObject newTile = CreateTile(x, y, -1);
             gridArray[x, y] = new gridPos(newTile, newTile.transform.position); //our 2D array is an array of x that holds an array of y that holds an array of gameobjects.
         }
     }
 }
Exemplo n.º 3
0
        public static List <gridPos> getRange(gridPos A, gridPos B)
        {
            List <gridPos> ans = new List <gridPos>();

            for (int X = A.X; X <= B.X; X++)
            {
                for (int Y = A.Y; Y <= B.Y; Y++)
                {
                    ans.Add(new gridPos(X, Y));
                }
            }

            return(ans);
        }
Exemplo n.º 4
0
 public void move(gridPos from, gridPos to)
 {
     grid[to.X, to.Y]     = grid[from.X, from.Y];
     grid[from.X, from.Y] = null;
 }
Exemplo n.º 5
0
 public void add(VisualObject obj, gridPos pos)
 {
     obj.setSize(cellSizeX, cellSizeY);
     grid[pos.X, pos.Y] = obj;
     print();
 }
Exemplo n.º 6
0
 public void destroy(gridPos pos)
 {
     GameObject.Destroy(grid[pos.X, pos.Y].gameObject);
 }
Exemplo n.º 7
0
 public VisualObject getObject(gridPos pos)
 {
     return(grid[pos.X, pos.Y]);
 }
Exemplo n.º 8
0
 public Vector2 gridPosToRealPos(gridPos pos)
 {
     return(new Vector2(pos.X * cellSizeX, -pos.Y * cellSizeY));
 }