Esempio n. 1
0
 public virtual void SetupHealthManager()
 {
     gamestateTracker           = FindObjectOfType <GamestateTracker>();
     gamestateTrackerPhotonView = gamestateTracker.GetComponent <PhotonView>();
     networkManager             = FindObjectOfType <NetworkManager>();
     maxHealth    = health;
     myPhotonView = GetComponent <PhotonView>();
 }
Esempio n. 2
0
    void Spawn(int teamId)
    {
        GamestateTracker gamestateTracker = FindObjectOfType <GamestateTracker>();
        TeamEntry        teamEntry        = gamestateTracker.teams.Get((short)teamId);
        bool             selected         = teamEntry.hasSelectedVehicle;

        teamEntry.isDead = false;
        short vehicle = teamEntry.vehicle;

        teamEntry.Commit(RespawnErrorHandler);

        Transform sp;

        if (teamId > spawnPoints.Count)
        {
            sp = spawnPoints[0];
        }
        else
        {
            sp = spawnPoints[teamId - 1];
        }

        List <string> vehicleNames = gamestateTracker.GetComponent <GamestateVehicleLookup>().sortedVehicleNames;

        string vehiclePrefabName;

        if (selected)
        {
            vehiclePrefabName = "VehiclePrefabs/" + vehicleNames[vehicle];
        }
        else
        {
            int randomVehicleNumber = Random.Range(0, defaultPlayerVehiclePrefabNames.Count);
            vehiclePrefabName = defaultPlayerVehiclePrefabNames[randomVehicleNumber];
            TeamEntry teamEntryAgain = gamestateTracker.teams.Get((short)teamId);
            teamEntryAgain.vehicle            = (short)randomVehicleNumber;
            teamEntryAgain.hasSelectedVehicle = true;
            teamEntryAgain.Commit();
        }

        object[] instantiationData = new object[] { teamId };

        //Put strong brakes on for spawn
        var spawnedVehicle = PhotonNetwork.Instantiate(vehiclePrefabName, sp.position, sp.rotation, 0, instantiationData);

        /*
         * PhysXWheelCollider[] wheelColliders = spawnedVehicle.GetComponentsInChildren<PhysXWheelCollider>();
         * foreach (PhysXWheelCollider wc in wheelColliders) {
         *  wc.brakeTorque = 10000;
         * }*/
    }
Esempio n. 3
0
    void SpawnPlayerVehicles()
    {
        List <string> vehicleNames = gamestateTracker.GetComponent <GamestateVehicleLookup>().sortedVehicleNames;

        for (int i = 0; i < Mathf.Min(sortedTeams.Count, spawnpoints.Count); i++)
        {
            string vehiclePrefabName = defaultVehiclePrefabName;

            if (sortedTeams[i].hasSelectedVehicle)
            {
                vehiclePrefabName = "VehicleDummyPrefabs/" + vehicleNames[sortedTeams[i].vehicle];
            }

            object[] instantiationData = new object[] { (int)sortedTeams[i].id };

            PhotonNetwork.Instantiate(vehiclePrefabName, spawnpoints[i].position, spawnpoints[i].rotation, 0, instantiationData);
        }
    }
Esempio n. 4
0
 //  USED
 public void SelectMap()
 {
     lobbySlotMaster.selectedMap = sceneName;
     GetComponent <PhotonView>().RPC(nameof(UpdateMapImageAndName), RpcTarget.AllBufferedViaServer);
     _gamestateTracker.GetComponent <PhotonView>().RPC(nameof(GamestateTracker.UpdateMapDetails), RpcTarget.AllBufferedViaServer, sceneName, sceneDisplayName);
 }