Esempio n. 1
0
 public void OnEnter()
 {
     //_animator.SetBool("isScared", true);
     speed = 10;
     System.Console.WriteLine("Scared Entered");
     _gatherer.GetComponent <Renderer>().material.color = Color.magenta;
     dino      = GameObject.FindObjectOfType <OrangeDinoBoo>();
     timeStuck = 0;
 }
    private void Awake()
    {
        //For scared condition
        orangeDino = GameObject.FindObjectOfType <OrangeDinoBoo>();

        //For angry condition
        greenDino = GameObject.FindObjectOfType <CubeDinoCollect>();

        //For sad condition
        calCounter = GameObject.FindObjectOfType <CubeCaloryCounter>();

        //friend bot not written yet


        _stateMachine = new StateMachine();


        //here the Emotion States are declared and instantiated:
        var scared = new Scared(this /*,  animator*/);
        var happy  = new Happy(this);
        var sad    = new Sad(this);
        var angry  = new Angry(this);

        //var depressed = new Depressed(this);

        //here ALL the transitions are added(declared) to _transition
        At(happy, sad, calCounter.calories > hungerCal);
        At(sad, happy, calCounter.calories < hungerCal);



        At(angry, happy, orangeDino.booNear1);
        At(happy, angry, angry.timeStuck > 1f);

        _stateMachine.AddAnyTransition(scared, orangeDino.booNear1);
        At(happy, scared, scared.timeStuck > 3f);



        //Set the starting ( happy) state
        _stateMachine.SetState(happy);


        void At(IState to, IState from, bool condition) => _stateMachine.AddTransition(to, from, condition);
    }