void OnCollisionEnter2D(Collision2D collision) { if (radius == 0) { GameObject go = TransformUtility.GetTopParent(collision.gameObject); Gridlike.Grid grid = go.GetComponent <Gridlike.Grid> (); if (grid != null) { int x; int y; Gridlike.GridUtility.GetClosestNonEmptyTile(grid, transform.position, out x, out y); if (grid != null) { GSGrid gsGrid = grid.GetComponent <GSGrid> (); gsGrid.Damage(character, x, y, damage, transform.position); } } } else { GridUtility.ExplodeInAllGrid(character, transform.position, radius, damage); } StartCoroutine(DestroyAnimation()); }
void TryPickaxe(Vector2 position) { if (Time.time - lastPickaxe > cooldown && Vector2.Distance((Vector2)transform.position, position) < radius) { Gridlike.Grid grid; int x; int y; Gridlike.GridUtility.GetAnyNonEmptyTile(position, out grid, out x, out y); if (grid != null) { lastPickaxe = Time.time; GSGrid gsGrid = grid.GetComponent <GSGrid> (); gsGrid.Damage(character, x, y, damage, position); } } }