void MouseOver_Hex(GameObject ourHitObject) { //whos turn is it? GameObject gameO = GameObject.Find("game"); string whosTurn = gameO.GetComponent <gameController>().turn; if (Input.GetMouseButtonDown(0)) { //If a unit is selected, then move the unit. Otherwise, perform action with tile if (selectedUnit != null) { if (checkClick(ourHitObject)) { // All good } else { return; } if (selectedUnit.energy > 0) { selectedUnit.GetComponent <unit>().moveUnit(ourHitObject); return; } } } }
private void OnTriggerEnter2D(Collider2D collider) { unit unit = collider.GetComponent <unit>(); if (unit && !unit.GetComponent <player>()) { Destroy(gameObject); } }