Example #1
0
 private void OnTriggerExit2D(Collider2D collision)
 {
     if (setted == collision.GetComponent <ChairLogic>())
     {
         setted.free();
         setted = null;
     }
 }
Example #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;
    }