Esempio n. 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);
        }
Esempio n. 3
0
        public void boost()
        {
            GameObject playerObject;

            playerObject = GetGlobalObjects.getControllablePlayer();
            StartCoroutine(PlayerBehaviors.activateSpeedBoost(playerObject));
        }
Esempio n. 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);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 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));
                    }
                }
            }
        }
Esempio n. 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>();
     }
 }
Esempio n. 7
0
 private void Start()
 {
     Cursor.lockState = CursorLockMode.Locked;
     playerAnimator   = GetComponent <Animator>();
     playerBehaviors  = GetComponent <PlayerBehaviors>();
     if (GameManager.instance.gameHasStarted)
     {
         inputEnabled = true;
     }
 }
Esempio n. 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);
                    }
                }
            }
        }
Esempio n. 9
0
 void Start()
 {
     pb = gameObject.GetComponent <PlayerBehaviors>();
     q  = GameObject.Find("Player").GetComponent <MainQuestManager>();
     pm = gameObject.GetComponent <PlayerMovement>();
 }
Esempio n. 10
0
 void Start()
 {
     dialogueBox.SetActive(false);
     quest = GameObject.Find("Player").GetComponent <MainQuestManager>();
     pb    = GameObject.Find("Player").GetComponent <PlayerBehaviors>();
 }
Esempio n. 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));
 }
Esempio n. 12
0
 void CmdEjectWall(GameObject gameObject, GameObject walls)
 {
     Debug.Log("Phase 0  : EjectWall called by: " + playerNum);
     StartCoroutine(PlayerBehaviors.ejectWall(gameObject, walls));
 }