private void OnTriggerExit2D(Collider2D collision) { if (setted == collision.GetComponent <ChairLogic>()) { setted.free(); setted = null; } }
//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; }
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(); } } }
public static void registerChair(ChairLogic chair) { chairs.Add(chair); //Debug.Log("Chair registered"); }