Beispiel #1
0
        //Update is called every frame.
        /// <summary>
        /// Waits until the active scene is the game screen.
        /// Updates the AI player's behaviors.
        /// </summary>
        void Update()
        {
            if (SceneManager.GetActiveScene().name == GlobalTags.GAME_SCREEN)
            {
                //Debug.Log("AIManager Update");
                if (GameState.Instance.gameReady)
                {
                    foreach (GameObject player in AiPlayerObjects)
                    {
                        System.Random rnd           = new System.Random();
                        double        turnDirection = rnd.NextDouble();

                        if (turnDirection <= 0.5) // turn left
                        {
                            PlayerBehaviors.turnPlayer(player, InputConstants.INPUT_LEFT);
                            if (turnDirection < AIConstants.BOOST_FREQ)
                            {
                                boostAIPlayer(player);
                            }
                        }
                        else   // turn right
                        {
                            PlayerBehaviors.turnPlayer(player, InputConstants.INPUT_RIGHT);
                            if (turnDirection > 1 - AIConstants.BOOST_FREQ)
                            {
                                boostAIPlayer(player);
                            }
                        }
                    }
                }
            }
        }
        public override void turn()
        {
            GameObject playerObject;

            playerObject = GetGlobalObjects.getControllablePlayer();
            PlayerBehaviors.turnPlayer(playerObject, InputConstants.INPUT_RIGHT);
        }
Beispiel #3
0
        /// <summary>
        /// Interpret user input per update.
        /// </summary>
        void FixedUpdate()
        {
            if (SceneManager.GetActiveScene().name == GlobalTags.GAME_SCREEN)
            {
                if (isLocalPlayer)
                {
                    int input = InputController.Instance.update();

                    if (input == InputConstants.INPUT_BOOST)
                    {
                        StartCoroutine(PlayerBehaviors.activateSpeedBoost(gameObject));
                    }
                    else if (input == InputConstants.INPUT_LEFT)
                    {
                        PlayerBehaviors.turnPlayer(gameObject, InputConstants.INPUT_LEFT);
                    }
                    else if (input == InputConstants.INPUT_RIGHT)
                    {
                        PlayerBehaviors.turnPlayer(gameObject, InputConstants.INPUT_RIGHT);
                    }
                }
            }
        }