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 Explosion(GSCharacter character, Vector2 position, int radius, int damage) { int x; int y; grid.WorldToGrid(position, out x, out y); for (int i = x - radius; i <= x + radius; i++) { for (int j = y - radius; j <= y + radius; j++) { int dx = i - x; int dy = j - y; if (dx * dx + dy * dy <= radius * radius) { Damage(character, i, j, damage, grid.TileCenterInWorld(i, j)); } } } }