Esempio n. 1
0
    void Update()
    {
        //These are for testing--------------------------------------
        //if (Input.GetKey(KeyCode.AltGr))
        //{
        //    if (Input.GetKeyDown(KeyCode.Alpha2))
        //    {
        //        currentState = States.Sleep;
        //        EventManager.instance.targetObj = monster.bedObj;
        //        EventManager.instance.OnPointing();
        //        OnPointing();
        //    }
        //    else if (Input.GetKeyDown(KeyCode.Alpha3))
        //    {
        //        currentState = States.Search;
        //    }
        //    else if (Input.GetKeyDown(KeyCode.Alpha5))
        //    {
        //        boxing.GetHit(false);
        //        stats.IncreaseStat("agility", 2);
        //    }
        //    else if (Input.GetKeyDown(KeyCode.Alpha6))
        //    {
        //        stats.UpdateStats();
        //    }
        //    else if (Input.GetKeyDown(KeyCode.Alpha7))
        //    {
        //        SetAnimationState(animStates.Dead);
        //        SetState(States.Dead);
        //        //currentState = States.Dead;
        //        anim.SetBool("Dead", true);
        //    }
        //    else if (Input.GetKeyDown(KeyCode.Alpha8))
        //    {
        //        stats.IncreaseStat("agility", 10);
        //        stats.IncreaseStat("speed", 10);
        //    }
        //    else if (Input.GetKeyDown(KeyCode.R))
        //    {
        //        ToggleRagdoll();
        //    }
        //    else if (Input.GetKeyDown(KeyCode.Alpha9))
        //    {
        //        boxing.DodgeTeleport();
        //    }
        //}
        //---------------------------------------------------------



        switch (currentState)
        {
        case States.Hatching:


            break;

        case States.Follow:
            monster.FollowPlayer(followDistance);
            break;

        case States.Fetch:
            fetch.FetchObject(fetchObj);
            break;

        case States.Sleep:
            monster.GoSleep();
            break;

        case States.Search:
            search.Search(trustPlayer);
            break;

        case States.Pooping:
            if (!monster.WaitStarted)
            {
                stats.Invoke("SpawnPoop", 3.75f);
            }
            monster.WaitFor(5.75f);
            break;

        case States.Whine:
            monster.WaitFor(2);
            break;

        case States.EatHand:
            monster.WaitFor(5);
            break;

        case States.EatGround:
            if (monster.EatObject(foodObj))
            {
                SetState(stateInQueue);
            }
            break;

        case States.Petting:
            monster.WaitFor(2.5f);
            break;

        case States.Evolve:
            monster.WaitFor(9);
            stateInQueue = States.Exit;
            break;

        case States.Ragdoll:

            break;

        case States.Exit:
            if (Vector3.Distance(transform.position, smashableObject.transform.position) < 1.5f && !isSmashed)
            {
                isSmashed = true;
                SetState(States.Smash);
                SetAnimationState(animStates.Smash);
                Invoke("SmashStone", 1.6f);
                Invoke("ExitCave", 3);
            }
            else if (!isSmashed)
            {
                monster.MoveTo(smashableObject.transform.position);
            }
            break;

        case States.GoOutside:
            monster.MoveTo(exitPoint);
            break;

        case States.Dead:
            if (!ragdolling)
            {
                Invoke("ToggleRagdoll", 2.5f);
                ragdolling = true;
            }
            break;
        }

        //Timer for walking sounds
        soundTimer += Time.deltaTime;
        if ((animationState == animStates.Walking || animationState == animStates.AdultWalk) && soundTimer > stepTimer)
        {
            StepSound();
            soundTimer = 0;
        }


        //Timer for hunger and fatigue
        statTimer += Time.deltaTime;
        if (statTimer > gameSpeed)
        {
            stats.UpdateStats();
            statTimer = 0;
        }
    }