private void Start() { grid = new Gridd(width, height, cellsize); grid.minValue = minValue; grid.maxValue = maxValue; grid.SetValue(2, 1, 13); }
public Food(Gridd grid) { int x = Random.Range(0, grid.Width); int y = Random.Range(0, grid.Height); food = Resources.Load <GameObject>("Prefabs/food"); Instantiate(food, grid.GetMiddlePosition(x, y), Quaternion.identity); }
public Snake(GameObject head, GameObject part, Gridd grid) { x = grid.Width / 2; y = grid.Height / 2; Head = head; Part = part; Instantiate(Head, grid.GetMiddlePosition(x, y), Quaternion.identity); body = new List <GameObject>(); }
public Snake(Gridd grid) { x = grid.Width / 2; y = grid.Height / 2; Head = Resources.Load <GameObject>("Prefabs/head"); Part = Resources.Load <GameObject>("Prefabs/part"); Instantiate(Head, grid.GetMiddlePosition(x, y), Quaternion.identity); body = new List <GameObject>(); }
void Awake() { uiHandler = GameObject.Find("Player").GetComponent <UIHandler>(); gridd = GameObject.Find("Gridd").GetComponent <Gridd>(); proceedButton = GameObject.Find("ProceedButton").GetComponent <Button>(); replayButton = GameObject.Find("ReplayButton").GetComponent <Button>(); exitButton = GameObject.Find("ExitButton").GetComponent <Button>(); backButton = GameObject.Find("BackButton").GetComponent <Button>(); }
public void Move(int xsteep, int ysteep, Gridd grid) { x = x + xsteep; y = y + ysteep; pos = Head.transform.position; Head.transform.position = grid.GetPosition(x, y); MoveBody(); wait = true; Debug.Log(xsteep + ysteep); }
void fillGrid(Gridd grid) { for (int x = 0; x < grid.Width; x++) { for (int y = 0; y < grid.Height; y++) { Instantiate(square, grid.GetMiddlePosition(x, y), Quaternion.identity); } } }
void Start() { grid = new Gridd(24, 16, 0.5f, new Vector3(-6, -4)); walls = new Walls(grid); food = new Food(grid); body = new List <GameObject>(); x = grid.Width / 2; y = grid.Height / 2; transform.position = grid.GetMiddlePosition(x, y); InvokeRepeating("Move", 0.2f, 0.2f); }
public Walls(Gridd grid) { float size = grid.CellSize / 2; square = Resources.Load <GameObject>("Prefabs/square"); square.transform.localScale = new Vector3(2, 2) * grid.CellSize; up = new Gridd(2 * grid.Width + 2, 1, size, new Vector3(grid.Origin.x - size, grid.Height * grid.CellSize + grid.Origin.y)); down = new Gridd(2 * grid.Width + 2, 1, size, new Vector3(grid.Origin.x - size, grid.Origin.y - size)); left = new Gridd(1, 2 * grid.Height, size, new Vector3(grid.Origin.x - size, grid.Origin.y)); right = new Gridd(1, 2 * grid.Height, size, new Vector3(grid.Width * grid.CellSize + grid.Origin.x, grid.Origin.y)); fillGrid(up); fillGrid(down); fillGrid(left); fillGrid(right); }
void Awake() { grid = GetComponent <Gridd>(); }