Beispiel #1
0
        // Update is called once per frame
        /// <summary>
        /// Checks to see if the game is over.
        /// Tells players to eject walls. ** TODO This should not be here **
        /// </summary>
        void Update()
        {
            // Do we need this if statement?  It looks like it's handled in the gameStateStart coroutine
            if (spawnPositions.Length == 0)
            {
                spawnPositions = GameObject.FindGameObjectsWithTag(GlobalTags.SPAWN_POSITION);
            }


            gameOver = checkIfAllPlayersDead();
            if (gameOver)
            {
                // end the game after so many seconds.
            }

            if (isServer && gameReady)
            {
                //let's spawn walls for all players
                for (int i = 0; i < players.Count; i++)
                {
                    if (players[i].GetComponent <Rigidbody>().velocity.magnitude > 0 && players[i].GetComponent <Controllers.PlayerController>().isAlive)    // TODO only a temporary check.  we need better sync method for after vehicles are ready.
                    {
                        StartCoroutine(PlayerBehaviors.ejectWall(players[i], walls));
                    }
                }
            }
        }
        public override void turn()
        {
            GameObject playerObject;

            playerObject = GetGlobalObjects.getControllablePlayer();
            PlayerBehaviors.turnPlayer(playerObject, InputConstants.INPUT_RIGHT);
        }
        public void boost()
        {
            GameObject playerObject;

            playerObject = GetGlobalObjects.getControllablePlayer();
            StartCoroutine(PlayerBehaviors.activateSpeedBoost(playerObject));
        }
Beispiel #4
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);
                            }
                        }
                    }
                }
            }
        }
Beispiel #5
0
        // Update is called once per frame
        void Update()
        {
            //Debug.Log("UPdating Player Controller for player " + playerNum);
            if (SceneManager.GetActiveScene().name == GlobalTags.GAME_SCREEN)
            {
                /* if(isLocalPlayer)
                 * {
                 *   if (checkWallTimer)
                 *   {
                 *       checkWallTimer = false;
                 *       StartCoroutine(wallTimerReset());
                 *       //Debug.Log("Is Wall ready for client player? " + Cooldowns.Instance.IsWallReady[playerNum]);
                 *       Debug.Log("Phase -1: EjectWall called by: " + playerNum);
                 *       CmdEjectWall(gameObject, walls); // walls are server-controlled and spawned, so we must use a Cmd
                 *   }
                 * }*/

                if (isServer)
                {
                    if (isAI)
                    {
                        StartCoroutine(PlayerBehaviors.ejectWall(gameObject, walls));
                    }
                }
            }
        }
Beispiel #6
0
 // Start is called before the first frame update
 void Start()
 {
     pb = GameObject.Find("Player").GetComponent <PlayerBehaviors>();
     if (sideQuestObj)
     {
         villager = GameObject.Find(villagerName).GetComponent <VillagerController>();
         score    = GameObject.Find("Score").GetComponent <ScoreManager>();
     }
 }
Beispiel #7
0
 private void Start()
 {
     Cursor.lockState = CursorLockMode.Locked;
     playerAnimator   = GetComponent <Animator>();
     playerBehaviors  = GetComponent <PlayerBehaviors>();
     if (GameManager.instance.gameHasStarted)
     {
         inputEnabled = true;
     }
 }
Beispiel #8
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);
                    }
                }
            }
        }
Beispiel #9
0
 void Start()
 {
     pb = gameObject.GetComponent <PlayerBehaviors>();
     q  = GameObject.Find("Player").GetComponent <MainQuestManager>();
     pm = gameObject.GetComponent <PlayerMovement>();
 }
Beispiel #10
0
 void Start()
 {
     dialogueBox.SetActive(false);
     quest = GameObject.Find("Player").GetComponent <MainQuestManager>();
     pb    = GameObject.Find("Player").GetComponent <PlayerBehaviors>();
 }
Beispiel #11
0
 /// <summary>
 /// Starts a coroutine to speed boost an AI player.
 /// </summary>
 /// <param name="player">The player to be boosted</param>
 public void boostAIPlayer(GameObject player)
 {
     StartCoroutine(PlayerBehaviors.activateSpeedBoost(player));
 }
Beispiel #12
0
 void CmdEjectWall(GameObject gameObject, GameObject walls)
 {
     Debug.Log("Phase 0  : EjectWall called by: " + playerNum);
     StartCoroutine(PlayerBehaviors.ejectWall(gameObject, walls));
 }