private void OnMouseDown() { if (this.Selected) { this.SelectMother(false); } else { MotherDot opponentMotherDot = GetSelectedMotherDot(); if (opponentMotherDot != null) { opponentMotherDot.Attack(transform.position); opponentMotherDot.SelectMother(false); } else { this.SelectMother(true); } } }
void SelectDot() // Возвращает позицию на игровом поле от положения мышки на экране { MotherDot returnDot = null; RaycastHit hit; Ray ray = camera.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { returnDot = hit.collider.gameObject.GetComponent <MotherDot>(); } if (motherDot == null) { motherDot = returnDot; } else { if (motherDot != returnDot) { motherDot.Attack(returnDot); } motherDot = null; } }