示例#1
0
        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();
                }
            }
        }
示例#2
0
 public void Attack(MotherDot motherDot)
 {
     for (int i = 0; i < childDots.Count; i++)
     {
         childDots[i].targetDot = motherDot;
     }
 }
示例#3
0
    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);
    }
示例#4
0
    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(); // обьект в кого то попал нужно его удалять
    }
示例#5
0
    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);
            }
        }
    }
示例#6
0
    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;
        }
    }
示例#7
0
 public void Init(MotherDot motherDot)
 {
     Selected    = motherDot.Selected;
     this.side   = motherDot.side;
     this.mother = motherDot;
 }