예제 #1
0
    void Update()
    {
        //only perform the behavior if in water
        if (inWater)
        {
            //over ride behaviors if there is food
            if (food && state != State.Happy)
            {
                BehaveFood();
            }
            else
            {
                //Behave based on state
                if (state == State.Happy)
                {
                    BehaveHappy();
                }
                else if (state == State.Hungry)
                {
                    BehaveHungry();
                }
                else if (state == State.Hunting)
                {
                    BehaveHunting();
                }
            }
        }

        //check if w has changed
        if (myHyper.w != curW)
        {
            //dont alert for the first time since the fish starts out not knowing its w
            if (curW != -1)
            {
                fishManager.alertMove(gameObject, myHyper.w);
            }
            curW = myHyper.w;
        }
    }