Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (GameStateStatus == ESTATE_STATUS.COMPLETED)
        {
            SetNextGameState();
        }

        GameStateStatus = ProcessGameState();
    }
Exemplo n.º 2
0
    void ProcessAI()
    {
        UpdateTimers();
        CalculateDistanceToPlayer();
        CheckForStateChange();
        StateStatus = ProcessState();


        if (StateStatus == ESTATE_STATUS.COMPLETED)
        {
            SetNextState();
        }
    }
Exemplo n.º 3
0
    ESTATE_STATUS ProcessGameState()
    {
        ESTATE_STATUS StateStatus = ESTATE_STATUS.RUNNING;         //the default state status


        switch (GameState)
        {
        case EGAME_STATE.INTRO:
        {
            StateStatus = ESTATE_STATUS.RUNNING;
            FadeIntoScene();

            //if (HasCameraIntroFinished () == ESTATE_STATUS.COMPLETED) {
            StateStatus = ESTATE_STATUS.COMPLETED;
            PlayerRigidBody.isKinematic = false;
            //}
        }
        break;

        case EGAME_STATE.INITIALISE_PLAY:
        {
            //one time init before the game loop start
            StartAllEnemyAI();
            StateStatus = ESTATE_STATUS.COMPLETED;
        }
        break;

        case EGAME_STATE.PLAYING:
        {
            PlayerHasCollectedAllLetters = HaveAllLettersBeenCollected();
            if (PlayerHasCollectedAllLetters)
            {
                LevelFinished();
                StateStatus = ESTATE_STATUS.COMPLETED;
            }
            ProcessDamage();
        }
        break;

        case EGAME_STATE.OUTRO:
        {
        }
        break;
        }

        return(StateStatus);
    }
Exemplo n.º 4
0
    ESTATE_STATUS FadeIntoScene()
    {
        ESTATE_STATUS FadeStatus = ESTATE_STATUS.RUNNING;

        if (FadeStarted == false)
        {
            WholeScreenColour.color = FadeInColour;
            FadeStarted             = true; //do this once
        }
        else
        {
            WholeScreenColour.color = Color.Lerp(WholeScreenColour.color, Color.clear, FadeSpeed * Time.deltaTime);

            if (HasFadeFinished() == true)
            {
                FadeStatus = ESTATE_STATUS.COMPLETED;
            }
        }

        return(FadeStatus);
    }
Exemplo n.º 5
0
 void SetState(ESTATE NewState)
 {
     OldState    = State;
     State       = NewState;
     StateStatus = ESTATE_STATUS.RUNNING;
 }
Exemplo n.º 6
0
    ESTATE_STATUS ProcessState()
    {
        ESTATE_STATUS CurrStateStatus = ESTATE_STATUS.RUNNING;


        if (OldState != State)
        {
            Debug.Log("State is " + State);
            OldState = State;
        }


        switch (State)
        {
        case ESTATE.BEGIN_THROW_PROJECTILES:
        case ESTATE.BEGIN_CHASE:
        {
            PauseWaypoints();
            NavAgent.SetDestination(PlayerPosition.position);
            NavAgent.Resume();                      //sws pause() will pause the nav agent, so it needs to be resumed
            CurrStateStatus = ESTATE_STATUS.COMPLETED;
            ResetPlayerHiddenTimer();
            ResetTimeBetweenProjectilesTimer();
        }
        break;

        case ESTATE.BEGIN_PATROL:
        {
            ResumeWaypoints();
            CurrStateStatus = ESTATE_STATUS.COMPLETED;
        }
        break;

        case ESTATE.BEGIN_STRIKE:
        {
            NavAgent.Stop();
            StrikePlayer();
            StrikeAnimFinished = false;

            CurrStateStatus = ESTATE_STATUS.COMPLETED;
        }
        break;

        case ESTATE.STRIKING:
        {
            if (StrikeAnimFinished == false)
            {
                if (CallBackFunctionCalledOnce == false)
                {
                    CallBackFunctionCalledOnce = true;

                    CallBackAfterWait(StrikeAnimDuration, () => {                              //theres a delay between the anim is playing and the projectile is thrown
                            StrikeAnimFinished = true;
                        });
                }
            }

            if (StrikeAnimFinished == true)
            {
                NavAgent.SetDestination(PlayerPosition.position);

                if (DistanceToPlayer <= (RangeForStrike + ReachForStrike))                        //check we are still in range for damage
                {
                    GameLogicScript.PlayerDamaged(DamageForStrike);
                }

                CurrStateStatus            = ESTATE_STATUS.COMPLETED;
                CallBackFunctionCalledOnce = false;
                StrikeAnimFinished         = false;
            }
            else
            {
                CurrStateStatus = ESTATE_STATUS.RUNNING;
            }
        }
        break;

        case ESTATE.CHASING:
        {
            NavAgent.SetDestination(PlayerPosition.position);
            CurrStateStatus = ESTATE_STATUS.RUNNING;
        }
        break;

        case ESTATE.PATROLLING:
        {
            //let the waypoint manager do it's thing
            CurrStateStatus = ESTATE_STATUS.RUNNING;
        }
        break;

        case ESTATE.THROWING_PROJECTILES:
        {
            NavAgent.SetDestination(PlayerPosition.position);


            bool PlayerVisable = CanSeePlayer();

            CurrStateStatus = ESTATE_STATUS.RUNNING;
            if (PlayerVisable == true)
            {
                if (MinimumTimeBetweenProjectilesReached())
                {
                    StartCoroutine(PlayOneShotAnimation(ANIM_STATES.THROW_PROJECTILE_ANIM_VALE));
                    CallBackAfterWait(DelayProjectileThrownAnim, () => {                              //theres a delay between the anim is playing and the projectile is thrown
                            FireProjectile();
                        });


                    ResetTimeBetweenProjectilesTimer();
                }

                ResetPlayerHiddenTimer();
            }
            else if (CantSeePlayerSeconds > TimePersuePlayerForProjectileWhenHidden)
            {
                CurrStateStatus = ESTATE_STATUS.COMPLETED;                         //leave this state
            }
        }
        break;
        }

        return(CurrStateStatus);
    }