Пример #1
0
        private void OnTrackingFound()
        {
            Renderer[] rendererComponents = GetComponentsInChildren <Renderer>(true);
            Collider[] colliderComponents = GetComponentsInChildren <Collider>(true);

            // Enable rendering:
            foreach (Renderer component in rendererComponents)
            {
                component.enabled = true;
            }

            // Enable colliders:
            foreach (Collider component in colliderComponents)
            {
                component.enabled = true;
            }


            Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found");


            if (!objectFound)// se ha trovato l'oggetto deve aspettare la transizione nello stato successivo
            {
                Debug.Log("Sto ricercando il pezzo dello stato " + State_Machine.getSubStateNumber());
                switch (State_Machine.getSubStateNumber())
                {
                case 0:   //Ricerca dell'obiettivo corrente
                    if (mTrackableBehaviour.name.Equals(State_Machine.getPhaseList()[State_Machine.getPhaseNumber()].getCurrTarget().name))
                    {     //controllo se ho trovato il target corrente della fase
                        State_Machine.setCurrentTargetFlag(true);
                        objectFound = true;
                        State_Machine.nextState();
                    }

                    break;

                case 1:                                                                                                                     //Ricerca dell'obiettivo finale
                    if (mTrackableBehaviour.name.Equals(State_Machine.getPhaseList()[State_Machine.getPhaseNumber()].getNextTarget().name)) //controllo se lo ho trovato il target finale della fase
                    {
                        State_Machine.setNextTargetFlag(true);
                        objectFound = true;
                        State_Machine.nextState();
                    }
                    if (mTrackableBehaviour.name.Equals(State_Machine.getPhaseList()[State_Machine.getPhaseNumber()].getSingleObject().name))     //controllo se lo ho trovato l'oggetto singolo della fase
                    {
                        State_Machine.setSingleObjectFlag(true);
                    }
                    break;

                default:     //default
                    break;
                }
            }
        }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        if (playAnim)
        {
            //gli oggetti sono stati inseriti in ordine inverso
            switch (State_Machine.getPhaseNumber())
            {
            case 0:    //Cone and metal ring animations

                if (!gameobjs[4].activeSelf)
                {
                    gameobjs[4].SetActive(true);
                    gameobjs[3].SetActive(true);
                }
                anim.Play("pezzo4-5", -1, 0f);

                break;

            case 1:    //Grinding tool animation
                if (!gameobjs[2].activeSelf)
                {
                    gameobjs[2].SetActive(true);
                }
                anim.Play("pezzo3", -1, 0f);

                break;

            case 3:    //Flange and screw animations
                if (!gameobjs[1].activeSelf)
                {
                    gameobjs[1].SetActive(true);
                    gameobjs[0].SetActive(true);
                }
                anim.Play("pezzo1-2", -1, 0f);
                // Debug.Log(gameobjs[1].name);
                //.Play("pezzo1", -1, 0f);
                // Debug.Log(gameobjs[0].name);
                break;
            }
            playAnim = false;
        }
        else
        {
            //anim.Play("idle", -1, 0f);
        }
    }
Пример #3
0
        static void Main(string[] args)
        {
            var phoneCall = new State_Machine <State, Trigger>(State.OffHook);

            phoneCall.Configure(State.OffHook).Go_To_State(Trigger.CallDialed, State.Ringing);
            phoneCall.Configure(State.Ringing).Go_To_State(Trigger.CallConnected, State.Connected)
            .On_Entry(() => Console.WriteLine("start ringing"))
            .On_Exit(() => Console.WriteLine("stop ringing"));
            phoneCall.Configure(State.Connected).
            On_Entry(() => StartCallTimer()).
            On_Exit(() => StopCallTimer());

            phoneCall.Fire(Trigger.CallDialed);
            phoneCall.Fire(Trigger.CallConnected);
            Thread.Sleep(2000);
            phoneCall.Fire(Trigger.close);
            Console.ReadKey();
        }
    //--------------------------------------------------------------------
    // ● 初期化
    //--------------------------------------------------------------------
    protected virtual void Start()
    {
        eye       = transform.FindChild("Eye");
        center    = transform.FindChild("Center");
        rigidbody = GetComponent <Rigidbody>();
        animator  = GetComponent <Animator>();
        status    = GetComponent <AI_Status>();

        game_manager = GameObject.FindWithTag("Scene_Manager")
                       .GetComponent <Game_Manager>();

        ses = new Dictionary <string, AudioSource>();
        foreach (var a in GetComponentsInChildren <AudioSource>())
        {
            ses[a.name] = a;
        }

        fsm = new State_Machine(this, new State_Base_AI());
        fsm.change(new State_Base_AI());
    }
Пример #5
0
 static void Print(State_Machine <State, Trigger> phoneCall)
 {
     Console.WriteLine("[Status:] {0}", phoneCall);
 }
Пример #6
0
 static void SetVolume(State_Machine <State, Trigger> phoneCall, Trigger trigger, int volume)
 {
     phoneCall.Fire(trigger, volume);
 }
Пример #7
0
 static void Fire(State_Machine <State, Trigger> phoneCall, Trigger trigger)
 {
     Console.WriteLine("[Firing:] {0}", trigger);
     phoneCall.Fire(trigger);
 }