Exemplo n.º 1
0
 private void OnTriggerExit2D(Collider2D collision)
 {
     if (setted == collision.GetComponent <ChairLogic>())
     {
         setted.free();
         setted = null;
     }
 }
Exemplo n.º 2
0
    //private void OnTriggerStay2D(Collider2D collision)
    //{
    //    if (state == ViusitorState.SITTING) return;
    //    Debug.Log("Trigger stay: " + this.name + " => " + collision.name + " " + collision.GetComponent<ChairLogic>().isFree());
    //    var chair = collision.GetComponent<ChairLogic>();
    //    if (chair == target)
    //    {
    //        if (chair.isFree())
    //        {
    //            chair.takeThePlace();
    //        }
    //        else
    //        {
    //            chooseAndMove();
    //        }
    //    }
    //}

    private void chooseAndMove()
    {
        if (target != null && state == ViusitorState.SITTING)
        {
            target.free();
        }
        target = chooseChair();
        state  = ViusitorState.MOVING;
    }
Exemplo n.º 3
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Debug.Log("Triggered: " + this.name + " => " + collision.name + " " + collision.GetComponent <ChairLogic>().isFree());
        var chair = collision.GetComponent <ChairLogic>();

        if (chair == target)
        {
            if (chair.isFree())
            {
                chair.takeThePlace();
                setted = target;
            }
            else
            {
                chooseAndMove();
            }
        }
    }
Exemplo n.º 4
0
 public static void registerChair(ChairLogic chair)
 {
     chairs.Add(chair);
     //Debug.Log("Chair registered");
 }