Exemple #1
0
    public override void Tick()
    {
        GameManager.PlayerStates nextState = GameManager.instance.getGoingState();
        switch (nextState)
        {
        case GameManager.PlayerStates.NoBadState:
            //Debug.Log("Ningún estado a aplicar");
            break;

        case GameManager.PlayerStates.GravityInvState:
            Debug.Log("Gravedad invertida");
            GameManager.instance.setGoingState(GameManager.PlayerStates.NoBadState);
            player.SetState(new GravityInvState(player));
            break;

        case GameManager.PlayerStates.ControlInvState:
            Debug.Log("Controles invertidos");
            GameManager.instance.setGoingState(GameManager.PlayerStates.NoBadState);
            player.SetState(new ControlInvState(player));
            break;

        case GameManager.PlayerStates.SlowedState:
            Debug.Log("Personaje ralentizado");
            GameManager.instance.setGoingState(GameManager.PlayerStates.NoBadState);
            player.SetState(new SlowedState(player));
            break;
        }
    }
        public IEnumerator CheckPlayerState(System.Type type, GameManager.PlayerStates state)
        {
            GameManager gameManager = new GameObject().AddComponent <GameManager>();
            GameObject  player      = GameObject.Instantiate(Resources.Load("Zombie")) as GameObject;

            PlayerState playerState = player.GetComponent <PlayerState>();

            //SE ESPERA 1 SEGUNDO
            timeCounter = 0f;
            while (timeCounter < 1)
            {
                timeCounter += Time.deltaTime; yield return(null);
            }

            //COMPROBAR QUE EL ESTADO INICIAL DEL JUGADOR SEA EL ESTADO NEUTRO.
            Assert.IsInstanceOf(typeof(NoBadState), playerState.getState());

            //CAMBIAR SU ESTADO A GRAVITYINVSTATE
            gameManager.setGoingState(state);

            //SE ESPERA 1 SEGUNDO
            timeCounter = 0f;
            while (timeCounter < 1)
            {
                timeCounter += Time.deltaTime; yield return(null);
            }

            //COMPROBAR QUE EL ESTADO DEL JUGADOR SEA EL ESTADO GRAVITYINVSTATE.
            Assert.IsInstanceOf(type, playerState.getState());

            //SE ESPERA 3 SEGUNDOS MAS
            timeCounter = 0f;
            while (timeCounter < 3)
            {
                timeCounter += Time.deltaTime; yield return(null);
            }

            //COMPROBAR QUE PASADOS UNOS SEGUNDOS EL ESTADO VUELVE A SER EL ESTADO NEUTRO
            Assert.IsInstanceOf(typeof(NoBadState), playerState.getState());


            GameObject.Destroy(gameManager);
            GameObject.Destroy(player);
        }