/// <summary> /// Creates the VehicleManagers ready to drive. The actual vehicles are hidden and then cloned as CarManagerType.Replayer /// </summary> /// <param name="Vehicle"></param> /// <param name="color"></param> public void CreateLiveRacersForReplayerToHide() { Debug.Log("DrivingPlayManager Create Hidden Racers For Replay"); VehicleManagers.Clear(); playingOffline = true; if (GameData.current.Scene == "Desert") { RenderSettings.fog = false; } else { RenderSettings.fog = true; } RenderSettings.fogDensity = 0.015f; Race.Current = new Race(); Race.Current.Laps = 3; //OK we have to create these but the vehicle get hidden and then cloned as CarManagerType.Replayer PlayerCarManager = new VehicleManager(0, CarManagerType.Player, Main.Instance.Vehicles[0].Vehicle, Main.Instance.Vehicles[0].Color); VehicleManagers.Add(PlayerCarManager); if (!GameObject.Find("DrivingGUICanvas(Clone)")) { DrivingGUICanvas = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/DrivingGUICanvas"), new Vector3(354f, 183f, 0), Quaternion.identity); } DrivingGUICanvas.GetComponent <DrivingMenuController>().ShowPanel(false); for (int Opp = 1; Opp < Main.Instance.Vehicles.Count; Opp++) { iVehicleManager AICarManager; AICarManager = new VehicleManager((byte)Opp, CarManagerType.AI, Main.Instance.Vehicles[Opp].Vehicle, Main.Instance.Vehicles[Opp].Color); VehicleManagers.Add(AICarManager); } Race.Current.ArrangeGrid(); CamSelector.Instance.Init(); RaceRecorder.current = new RaceRecorder(VehicleManagers); Recrdng.Current.Recordables = VehicleManagers.Select(vm => new RecordableVehicle(vm)).ToList(); RaceRecorder.current.State = "Stopped"; PauseCars(); }
public void PlayOffline(string Vehicle, string color) { List <String> AvailableColors = new List <String> { "Red", "Pink", "Purp", "Black", "Blue", "Yellow", "Green" }; VehicleManagers.Clear(); playingOffline = true; if (GameData.current.Scene == "Desert") { RenderSettings.fog = false; } else { RenderSettings.fog = true; } RenderSettings.fogDensity = 0.015f; //if (Race.Current != null) Debug.Log("Need to RaceCurrentDispose"); Havent found a problem here yet Race.Current = new Race(); Race.Current.Laps = _MainScript.Laps; PlayerCarManager = new VehicleManager(0, CarManagerType.Player, Vehicle, color); VehicleManagers.Add(PlayerCarManager); AvailableColors.Remove(color); if (!GameObject.Find("DrivingGUICanvas(Clone)")) { DrivingGUICanvas = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/DrivingGUICanvas"), new Vector3(354f, 183f, 0), Quaternion.identity); } Transform trCanvas = DrivingGUICanvas.transform; trCanvas.Find("pnlDrivingMenu/Speedo").GetComponent <SpeedoController>().Init(); InputGUI = GameObject.Find("ControlCanvas"); SendPlayerInstantiateEvent(PlayerCarManager.goCar.transform); //this event is consumed by scenery that Tracks the player car like the Spectator and the pheasant for (int Opp = 0; Opp < _MainScript.OpponentCount; Opp++) { string _veh = "Car"; if (_MainScript.RandomVehicles == false) { _veh = Vehicle; } else { switch (UnityEngine.Random.Range(0, 3)) { case 0: break; case 1: _veh = "Hotrod"; break; case 2: _veh = "Anglia"; break; } } int Rnd = UnityEngine.Random.Range(0, AvailableColors.Count); String _color = AvailableColors[Rnd]; iVehicleManager AICarManager; AICarManager = new VehicleManager((byte)(Opp + 1), CarManagerType.AI, _veh, _color); AvailableColors.Remove(_color); VehicleManagers.Add(AICarManager); } if (_MainScript.Ghost) { GhostCarManager = new VehicleManager(99, CarManagerType.Ghost, "Ghost", "G"); //if(File.Exists(Application.persistentDataPath + "/" + Game.current.Filename + ".gst")) } Race.Current.ArrangeGrid(); CamSelector.Instance.Init(); RaceRecorder.current = new RaceRecorder(VehicleManagers); Recrdng.Current = new Recrdng(); RaceRecorder.current.State = "Recording"; }