private void OnCollisionEnter2D(Collision2D other) { ChildrenDot otherDot = other.gameObject.GetComponent <ChildrenDot>(); MotherDot otherMother = other.gameObject.GetComponent <MotherDot>(); if (otherDot != null) { if (this.side != otherDot.side) { otherDot.Kill(); this.Kill(); } return; } if (otherMother != null) { if (otherMother.side != this.side) { this.Kill(); otherMother.Hit(); } } }
public void Attack(MotherDot motherDot) { for (int i = 0; i < childDots.Count; i++) { childDots[i].targetDot = motherDot; } }
public void Init(MotherDot mother) { if (spr == null) { spr = GetComponent <SpriteRenderer>(); } if (rb == null) { rb = GetComponent <Rigidbody2D>(); } motherDot = mother; isAttack = false; isSelected = false; _centre = motherDot.transform.position; UpdateColor(false); }
void OnCollisionEnter2D(Collision2D collision) { if (!isAttack) { return; } string _tag = collision.gameObject.tag; if (_tag == motherDot.gameObject.tag) { return; // наша материнка } if (_tag == gameObject.tag) { return; // наш братан } ActorBase abstractDot = MotherDot.CastToObj <ActorBase>(collision.gameObject); abstractDot.Hit(); Release(); // обьект в кого то попал нужно его удалять }
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; } }
public void Init(MotherDot motherDot) { Selected = motherDot.Selected; this.side = motherDot.side; this.mother = motherDot; }