void Update() { // The player is grounded if a linecast to the groundcheck position hits anything on the ground layer. RaycastHit2D hit = Physics2D.Linecast(transform.position, groundCheck.position, 1 << LayerMask.NameToLayer("Ground")); grounded = hit; // If the jump button is pressed and the player is grounded then the player should jump. if (Input.GetButtonDown("Jump") && grounded) { jump = true; } Gridlike.Grid grid = Gridlike.Grid.GetFirstGrid(); if (grid != null) { int x; int y; grid.WorldToGrid(Camera.main.ScreenToWorldPoint(Input.mousePosition), out x, out y); if (Input.GetMouseButton(0)) { grid.showOnSet = true; grid.SetId(x, y, 1); } else if (Input.GetMouseButton(1)) { grid.Clear(x, y); } } }
public void Place(int x, int y, int id) { if (CanPlace(x, y, id)) { grid.SetId(x, y, id); grid.SetState(x, y, 0, 0, 0); } }