コード例 #1
0
        public override void turn()
        {
            GameObject playerObject;

            playerObject = GetGlobalObjects.getControllablePlayer();
            PlayerBehaviors.turnPlayer(playerObject, InputConstants.INPUT_RIGHT);
        }
コード例 #2
0
        public void boost()
        {
            GameObject playerObject;

            playerObject = GetGlobalObjects.getControllablePlayer();
            StartCoroutine(PlayerBehaviors.activateSpeedBoost(playerObject));
        }
コード例 #3
0
        /// <summary>
        /// This static Coroutine method that will instantiate a Wall prefab at a set distance and rotation behind a given player gameobject.
        /// This will access the Cooldowns singleton instance.
        /// </summary>
        /// <param name="player">  The player gameobject to put the wall behind.</param>
        /// <param name="wallPrefab">  The wall prefab that will be instantiated.  Depricated.  Needs to be removed.</param>
        /// <returns> IEnumerator  </returns>
        public static IEnumerator ejectWall(GameObject player, GameObject wallPrefab)
        {
            Debug.Log("Phase 1: EjectWall called by: " + player.GetComponent <Controllers.PlayerController>().PlayerNum);

            Cooldowns cooldowns = GetGlobalObjects.getCooldownsInstance();
            int       playerNum = player.GetComponent <Controllers.PlayerController>().PlayerNum;

            Debug.Log("Phase 2: EjectWall called by: " + player.GetComponent <Controllers.PlayerController>().PlayerNum +
                      "  ready value: " + cooldowns.IsWallReady[playerNum]);
            if (cooldowns.IsWallReady[playerNum])
            {
                Debug.Log("Phase 3: EjectWall called by: " + player.GetComponent <Controllers.PlayerController>().PlayerNum);
                cooldowns.IsWallReady[playerNum] = false;

                Rigidbody vehicle = player.GetComponent <Rigidbody>();

                Vector3 behindVehicle = vehicle.transform.position - vehicle.transform.forward * PlayerConstants.WALL_SPAWN_DISTANCE;
                behindVehicle.y = PlayerConstants.WALL_HEIGHT;
                Debug.Log("Phase 4: EjectWall called by: " + player.GetComponent <Controllers.PlayerController>().PlayerNum);

                GameObject spawnedWall;
                spawnedWall = (GameObject)MonoBehaviour.Instantiate(Resources.Load(GlobalTags.WALL_PREFAB), behindVehicle, Quaternion.LookRotation(vehicle.velocity));

                Debug.Log("Phase 5: EjectWall called by: " + player.GetComponent <Controllers.PlayerController>().PlayerNum);
                NetworkServer.Spawn(spawnedWall);
                GameState.Instance.RpcSetWallToPlayer(player, spawnedWall);
                Debug.Log("Phase 6: EjectWall called by: " + player.GetComponent <Controllers.PlayerController>().PlayerNum + "  " + PlayerConstants.WALL_SPAWN_RESPAWN_TIME);
                yield return(new WaitForSeconds(PlayerConstants.WALL_SPAWN_RESPAWN_TIME));

                cooldowns.IsWallReady[playerNum] = true;
                Debug.Log("Phase 7*****: EjectWall called by: " + player.GetComponent <Controllers.PlayerController>().PlayerNum);
            }
        }
コード例 #4
0
 /// <summary>
 /// Logic to determine who hit what.
 /// Updates isAlive attribute and will deactivate the gameObject.
 /// </summary>
 /// <param name="other">The collision object containing details about the collision.</param>
 void OnCollisionEnter(Collision other)
 {
     if (other.collider.tag == GlobalTags.WALL_TAG)
     {
         Debug.Log(other.gameObject.GetComponent <WallController>().PlayerID + "'s wall Collision for Player" +
                   GetComponent <PlayerController>().PlayerNum + "at: " + transform.position.ToString());
         gameObject.SetActive(false);
         isAlive = false;
     }
     if (other.collider.tag == GlobalTags.BOUNDARY)
     {
         Debug.Log("Boundary Collision for Player" + GetComponent <PlayerController>().PlayerNum + "at: " + transform.position.ToString());
         gameObject.SetActive(false);
         isAlive = false;
     }
     else
     {
         int numPlayers = GetGlobalObjects.getNumberOfPlayers();
         for (int i = 0; i < numPlayers; i++)
         {
             if (other.collider.tag == GlobalTags.PLAYERS[i])
             {
                 Debug.Log(other.collider.tag + " and Player" + GetComponent <PlayerController>().PlayerNum + " ran into each other. BOOM!"
                           + "at: " + transform.position.ToString());
                 gameObject.SetActive(false);
                 isAlive = false;
             }
         }
     }
 }
コード例 #5
0
        /// <summary>
        /// Checks if game is over.  If so, moves camera to birds-eye-view position.
        /// </summary>
        /// <returns></returns>
        private IEnumerator CheckIfPlayerDead()
        {
            GameState gameState = GetGlobalObjects.getGameState();

            if (gameState.getGameOver() && !inBirdsEyeView)
            {
                // Adjust the camera to bird's-eye view
                goToBirdsEyeView();
                Debug.Log("BIRD EYE VIEW");
                yield return(new WaitForSeconds(10));
                //Application.Quit();
            }
        }
コード例 #6
0
        // we want to use LateUpdate() because it is always executed after all the other Update()'s called on this frame.
        // Since this is a follow camera, we want to follow the updated movements
        void LateUpdate()
        {
            if (!GetGlobalObjects.getGameState().getGameOver())
            {
                // Follow the player's transform
                transform.position =
                    (player.transform.position - player.transform.forward * CameraConstants.STANDARD_CAMERA_DISTANCE_MULT) +
                    CameraConstants.STANDARD_CAMERA_HEIGHT;

                // Follow the player's forward direction
                transform.LookAt(player.transform.position);
            }
            StartCoroutine(CheckIfPlayerDead());
        }
コード例 #7
0
        /// <summary>
        /// This static Coroutine method will put the player gameobject into boost mode (higher velocity) for the BOOST_DURATION time.
        /// Will access the singleton Cooldowns instance running in the game scene.
        /// </summary>
        /// <param name="player">  The player gameobject to be boosted.</param>
        /// <returns> IEnumerator </returns>
        public static IEnumerator activateSpeedBoost(GameObject player)
        {
            Cooldowns cooldowns = GetGlobalObjects.getCooldownsInstance();
            int       playerNum = player.GetComponent <Controllers.PlayerController>().PlayerNum;

            Rigidbody vehicle = player.GetComponent <Rigidbody>();

            if (cooldowns.IsBoostReady[playerNum] == true)
            {
                cooldowns.IsBoostReady[playerNum] = false;

                vehicle.velocity *= PlayerConstants.BOOST_AMOUNT;
                yield return(new WaitForSeconds(PlayerConstants.BOOST_DURATION));

                Debug.Log("Boost On Cooldown");

                vehicle.velocity /= PlayerConstants.BOOST_AMOUNT;
                yield return(new WaitForSeconds(PlayerConstants.BOOST_COOLDOWN));

                Debug.Log("Boost Off Cooldown");

                cooldowns.IsBoostReady[playerNum] = true;
            }
        }
コード例 #8
0
 /// <summary>
 /// Called when the associated GameObject is initialized.
 /// </summary>
 void Start()
 {
     player           = GetGlobalObjects.getControllablePlayer();
     playerController = player.GetComponent <PlayerController>();
 }