Пример #1
0
//------------------------------------
        public IEnumerator init()
        {
            isDispatcherActive = true;

            yield return(new WaitForSeconds(1f));

            while (true && _owner != null)
            {
                if (_owner.iEstado == GajoCitizen.GajoState.VIVO)
                {
                                #if debug_interactions
                    if (owner.getId() == Global.whoIsBeingTracked)
                    {
                        print("***************************antes" + owner.interactionState + " " + owner.dispatcherSpeed + " " + Time.time);
                    }
                                #endif
                    //--
                    switch (_owner.behavior.Interacao.interactionState)
                    {
                    case InteractionHandler.InteractionState.NEPIA:             //estado normal
                                                #if debug_interactions
                        if (owner.getId() == Global.whoIsBeingTracked)
                        {
                            print("***0 LIVRE " + Time.time);
                        }
                                                #endif
                        //the scheduler will suspend the execution until the yielded coroutine Dispatch has finished.
                        yield return(StartCoroutine(dispatch()));

                        break;

                    case InteractionHandler.InteractionState.WANTS_TO_GET_LINK:            //estado comecou animacao Interacao
                                        #if debug_interactions
                        if (owner.getId() == Global.whoIsBeingTracked)
                        {
                            print("***1 ANIMA " + Time.time);
                        }
                                        #endif
                        yield return(new WaitForSeconds(_owner.behavior.dispatcherSpeed));

                        _owner.behavior.Interacao.interactionState = InteractionHandler.InteractionState.IN_LINK;
                        break;

                    case InteractionHandler.InteractionState.IN_LINK:            //estado quer terminar Interacao
                                        #if debug_interactions
                        if (owner.getId() == Global.whoIsBeingTracked)
                        {
                            print("***2 PROCURA FECHO " + owner.interactionPartner + Time.time);
                        }
                                        #endif
                        _owner.behavior.Interacao.interactionState = InteractionHandler.InteractionState.NEPIA;
                        if (_owner.behavior.Interacao.isInteracting)
                        {
                            // _owner.behavior.Interacao.stop();
                            //RFA-delegate-inicio
                            if (_owner.behavior.Interacao.interactingPartner != null)
                            {
                                _owner.behavior.Interacao.interactingPartner.stopInteraction();
                            }
                        }
                        _owner.stopInteraction();
                                        #if debug_interactions
                        if (owner.getId() == Global.whoIsBeingTracked)
                        {
                            print("***(pos a 0) FECHOU " + Time.time + " " + owner.interactionPartner);
                        }
                                        #endif
                        yield return(new WaitForSeconds(1.0f));

                        break;
                    }
                                #if  debug_interactions
                    if (owner.getId() == Global.whoIsBeingTracked)
                    {
                        print("*********************************************depois" + Time.time);
                    }
                                #endif
                    yield return(null);
                }
            }
        }