Example #1
0
    void moveBallToClosest()
    {
        Vector3 position = ball.transform.position;

        o1Closest = getClosest(o1List);
        o2Closest = getClosest(o2List);
        var distance1 = (o1Closest.transform.position - position).magnitude;
        var distance2 = (o2Closest.transform.position - position).magnitude;

        if (ballCont.getVel().magnitude > 3)
        {
            return;
        }
        if (distance1 < distance2 && distance1 < 2.1f)
        {
            ball.transform.position = new Vector3(o1Closest.transform.position.x - 1.3f, o1Closest.transform.position.y, -0.1f);
            whoHasTheBall           = Takım.RED;
            o1Closest.GetComponent <Rigidbody2D>().velocity = new Vector3(0, 0, 0);
        }
        else if (distance2 < 2.1f)
        {
            ball.transform.position = new Vector3(o2Closest.transform.position.x + 1.3f, o2Closest.transform.position.y, -0.1f);
            whoHasTheBall           = Takım.BLUE;
            o2Closest.GetComponent <Rigidbody2D>().velocity = new Vector3(0, 0, 0);
        }
        else
        {
            //whoHasTheBall=Takım.NONE;
        }
    }
Example #2
0
    void moveTakım(Takım t, Durum d)
    {
        var list_to_use = t == Takım.RED ? o1List : o2List;
        var originList  = t == Takım.RED ? orginList1 : orginList2;
        var defList     = t == Takım.RED ? defList1 : defList2;
        var adefList    = t == Takım.RED ? adefList1 : adefList2;
        var attackList  = t == Takım.RED ? attackList1 : attackList2;
        var aattackList = t == Takım.RED ? aattackList1 : aattackList2;

        switch (d)
        {
        case Durum.ACIL_ATAK:
            for (int i = 0; i < list_to_use.Count; i++)
            {
                moveOneTo(list_to_use[i], aattackList[i]);
            }
            break;

        case Durum.ACIL_DEFANS:
            Debug.Log("ACIL DEFANS");
            for (int i = 0; i < list_to_use.Count; i++)
            {
                moveOneTo(list_to_use[i], ball.transform.position);
            }
            break;

        case Durum.SAKIN:
            Debug.Log("SAKİN");
            for (int i = 0; i < list_to_use.Count; i++)
            {
                moveOneTo(list_to_use[i], originList[i]);
            }
            break;

        case Durum.DEFANS:
            Debug.Log("DEFANS");
            for (int i = 0; i < list_to_use.Count; i++)
            {
                moveOneTo(list_to_use[i], defList[i]);
            }
            break;

        case Durum.ATAK:
            for (int i = 0; i < list_to_use.Count; i++)
            {
                moveOneTo(list_to_use[i], attackList[i]);
            }
            break;
        }
    }