Début des vidéos dynamique
This commit is contained in:
parent
a1277c3e87
commit
c94adb2d6c
@ -314,7 +314,7 @@ AudioListener:
|
|||||||
type: 2}
|
type: 2}
|
||||||
m_PrefabInternal: {fileID: 0}
|
m_PrefabInternal: {fileID: 0}
|
||||||
m_GameObject: {fileID: 670213594}
|
m_GameObject: {fileID: 670213594}
|
||||||
m_Enabled: 1
|
m_Enabled: 0
|
||||||
--- !u!124 &670213596
|
--- !u!124 &670213596
|
||||||
Behaviour:
|
Behaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -729,7 +729,6 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 4cdc0f9b9c7604ab9a5d4ac68eb8277f, type: 3}
|
m_Script: {fileID: 11500000, guid: 4cdc0f9b9c7604ab9a5d4ac68eb8277f, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
raceFinishTime: 30
|
|
||||||
videoID: 1
|
videoID: 1
|
||||||
--- !u!114 &1036252281
|
--- !u!114 &1036252281
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
@ -828,7 +827,7 @@ AudioListener:
|
|||||||
m_PrefabParentObject: {fileID: 0}
|
m_PrefabParentObject: {fileID: 0}
|
||||||
m_PrefabInternal: {fileID: 0}
|
m_PrefabInternal: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1180963258}
|
m_GameObject: {fileID: 1180963258}
|
||||||
m_Enabled: 1
|
m_Enabled: 0
|
||||||
--- !u!124 &1180963260
|
--- !u!124 &1180963260
|
||||||
Behaviour:
|
Behaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -1234,7 +1233,6 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 4cdc0f9b9c7604ab9a5d4ac68eb8277f, type: 3}
|
m_Script: {fileID: 11500000, guid: 4cdc0f9b9c7604ab9a5d4ac68eb8277f, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
raceFinishTime: 30
|
|
||||||
videoID: 0
|
videoID: 0
|
||||||
--- !u!212 &1718131636
|
--- !u!212 &1718131636
|
||||||
SpriteRenderer:
|
SpriteRenderer:
|
||||||
|
|||||||
@ -43,7 +43,7 @@ public class BikeManager : MonoBehaviour {
|
|||||||
taco.SetPlayer(playerID);
|
taco.SetPlayer(playerID);
|
||||||
|
|
||||||
|
|
||||||
normalSpeed = distanceToRun / vm.raceFinishTime;
|
normalSpeed = distanceToRun / gm.GetRaceNormalTime();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,6 +11,7 @@ public class ConfigurationLoader {
|
|||||||
public float normalTime;
|
public float normalTime;
|
||||||
public float[] diameters = new float[2];
|
public float[] diameters = new float[2];
|
||||||
public int[] sensors = new int[2];
|
public int[] sensors = new int[2];
|
||||||
|
public float[] videoEnds = new float[8];
|
||||||
|
|
||||||
public ConfigurationLoader() {
|
public ConfigurationLoader() {
|
||||||
Load();
|
Load();
|
||||||
@ -27,6 +28,11 @@ public class ConfigurationLoader {
|
|||||||
diameters[1] = obj["Vélos"]["Joueur2"]["DiamètreRoue"].n / 1000f;
|
diameters[1] = obj["Vélos"]["Joueur2"]["DiamètreRoue"].n / 1000f;
|
||||||
sensors[0] = (int) obj["Vélos"]["Joueur1"]["NombreDeCapteurs"].n;
|
sensors[0] = (int) obj["Vélos"]["Joueur1"]["NombreDeCapteurs"].n;
|
||||||
sensors[1] = (int) obj["Vélos"]["Joueur2"]["NombreDeCapteurs"].n;
|
sensors[1] = (int) obj["Vélos"]["Joueur2"]["NombreDeCapteurs"].n;
|
||||||
|
|
||||||
|
for (int i = 0; i < 8; i++) {
|
||||||
|
videoEnds[i] = obj["Vidéos"][i]["Fin"].n;
|
||||||
|
Debug.Log("Video " + i + " end: " + videoEnds[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Check() {
|
private void Check() {
|
||||||
|
|||||||
@ -26,7 +26,7 @@ public class GameManager : MonoBehaviour {
|
|||||||
// Skins of the two players
|
// Skins of the two players
|
||||||
private int[] _skins = new int[2];
|
private int[] _skins = new int[2];
|
||||||
|
|
||||||
ConfigurationLoader conf;
|
private ConfigurationLoader conf;
|
||||||
|
|
||||||
private void Awake(){
|
private void Awake(){
|
||||||
// Singleton
|
// Singleton
|
||||||
@ -96,6 +96,10 @@ public class GameManager : MonoBehaviour {
|
|||||||
return conf.sensors[bikeID];
|
return conf.sensors[bikeID];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float GetVideoEnd(int videoID) {
|
||||||
|
return conf.videoEnds[videoID];
|
||||||
|
}
|
||||||
|
|
||||||
public void SetSkins(int player1, int player2) {
|
public void SetSkins(int player1, int player2) {
|
||||||
_skins[0] = player1;
|
_skins[0] = player1;
|
||||||
_skins[1] = player2;
|
_skins[1] = player2;
|
||||||
@ -108,8 +112,8 @@ public class GameManager : MonoBehaviour {
|
|||||||
// TODO: Remove once menus are ok
|
// TODO: Remove once menus are ok
|
||||||
void Update() {
|
void Update() {
|
||||||
if (Input.GetButtonDown("SubmitP1")) {
|
if (Input.GetButtonDown("SubmitP1")) {
|
||||||
Debug.Log("Héhé Cancel");
|
SetSkins(1, 0);
|
||||||
SetSkins(0, 0);
|
LaunchRace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -23,6 +23,5 @@ public class HUDProgress : MonoBehaviour {
|
|||||||
|
|
||||||
public void SetProgress(float p) {
|
public void SetProgress(float p) {
|
||||||
progress.transform.position = tstart.position * (1 - p) + tend.position * p;
|
progress.transform.position = tstart.position * (1 - p) + tend.position * p;
|
||||||
Debug.Log("HUDP: ima p" + p );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,8 +9,7 @@ public class RAWTachometer : Tachometer {
|
|||||||
|
|
||||||
public override float GetSpeed() {
|
public override float GetSpeed() {
|
||||||
int c = impulses.Count(i => i > Time.time - delta);
|
int c = impulses.Count(i => i > Time.time - delta);
|
||||||
Debug.Log("I ru speed Count: " + impulses.Count() + " c " + c);
|
return c * distancePerTick;
|
||||||
return c;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,11 +8,11 @@ public abstract class Tachometer : MonoBehaviour {
|
|||||||
private string inputID;
|
private string inputID;
|
||||||
|
|
||||||
// Config
|
// Config
|
||||||
private float ticPerTurn;
|
private int ticPerTurn;
|
||||||
private float wheelDiameter;
|
private float wheelDiameter;
|
||||||
|
|
||||||
// Process
|
// Process
|
||||||
private float distancePerTick;
|
protected float distancePerTick;
|
||||||
|
|
||||||
protected List<float> impulses = new List<float>();
|
protected List<float> impulses = new List<float>();
|
||||||
|
|
||||||
@ -27,11 +27,14 @@ public abstract class Tachometer : MonoBehaviour {
|
|||||||
ticPerTurn = gm.GetSensorsCount(playerID);
|
ticPerTurn = gm.GetSensorsCount(playerID);
|
||||||
wheelDiameter = gm.GetBikeWheelDiameter(playerID);
|
wheelDiameter = gm.GetBikeWheelDiameter(playerID);
|
||||||
|
|
||||||
|
Debug.Log("Config Loaded player " + playerID);
|
||||||
|
Debug.Log("SensorsCount: " + ticPerTurn);
|
||||||
|
Debug.Log("Diameter: " + wheelDiameter);
|
||||||
|
|
||||||
distancePerTick = wheelDiameter * Mathf.PI / ticPerTurn;
|
distancePerTick = wheelDiameter * Mathf.PI / ticPerTurn;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RegisterTic() {
|
private void RegisterTic() {
|
||||||
Debug.Log("Register");
|
|
||||||
impulses.Add(Time.time);
|
impulses.Add(Time.time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -7,48 +7,30 @@ public class VideoManager : MonoBehaviour {
|
|||||||
|
|
||||||
private VideoPlayer videoPlayer;
|
private VideoPlayer videoPlayer;
|
||||||
public float speed {get; set; }
|
public float speed {get; set; }
|
||||||
public float raceFinishTime = 30.0f;
|
|
||||||
public int videoID;
|
|
||||||
|
|
||||||
void Awake() {
|
|
||||||
//videoPlayer = gameObject.AddComponent<VideoPlayer>();
|
|
||||||
}
|
|
||||||
|
|
||||||
VideoPlayer GetVideoPlayer() {
|
|
||||||
if (videoPlayer == null)
|
|
||||||
videoPlayer = gameObject.AddComponent<VideoPlayer>();
|
|
||||||
return videoPlayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Start () {
|
|
||||||
// TODO: Aspect Ratio is not working?
|
|
||||||
var vp = GetVideoPlayer();
|
|
||||||
vp.aspectRatio = VideoAspectRatio.FitOutside;
|
|
||||||
Debug.Log(vp.aspectRatio);
|
|
||||||
vp.isLooping = true;
|
|
||||||
vp.playOnAwake = false;
|
|
||||||
vp.Prepare();
|
|
||||||
vp.Pause();
|
|
||||||
//videoPlayer.Play();
|
|
||||||
Run();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetSkin(int playerID) {
|
public void SetSkin(int playerID) {
|
||||||
Debug.Log("PID: " + playerID);
|
videoPlayer = gameObject.AddComponent<VideoPlayer>();
|
||||||
int id = GameManager.Instance.GetSkins(playerID);
|
|
||||||
Debug.Log("PID: " + playerID + " id: " + id);
|
var gm = GameManager.Instance;
|
||||||
var vp = GetVideoPlayer();
|
|
||||||
vp.url = Application.streamingAssetsPath + "/" + id + ".webm";
|
int id = gm.GetSkins(playerID);
|
||||||
|
videoPlayer.url = Application.streamingAssetsPath + "/" + id + ".webm";
|
||||||
|
|
||||||
|
Debug.Log("Video Stats:" +
|
||||||
|
" canSetTime: " + videoPlayer.canSetTime +
|
||||||
|
" canSetSkipOnDrop: " + videoPlayer.canSetSkipOnDrop);
|
||||||
|
|
||||||
|
videoPlayer.skipOnDrop = true;
|
||||||
|
videoPlayer.isLooping = false;
|
||||||
|
videoPlayer.playOnAwake = false;
|
||||||
|
videoPlayer.Prepare();
|
||||||
|
|
||||||
|
float startTime = gm.GetVideoEnd(id) - gm.GetRaceNormalTime();
|
||||||
|
videoPlayer.time = startTime;
|
||||||
|
videoPlayer.Play();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update () {
|
void Update () {
|
||||||
videoPlayer.playbackSpeed = speed;
|
videoPlayer.playbackSpeed = speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Run() {
|
|
||||||
videoPlayer.Play();
|
|
||||||
}
|
|
||||||
|
|
||||||
void WheelImpulse() {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,17 +7,27 @@
|
|||||||
NombreDeCapteurs: Le nombre de capteurs placés sur la roue du vélo
|
NombreDeCapteurs: Le nombre de capteurs placés sur la roue du vélo
|
||||||
",
|
",
|
||||||
"Course": {
|
"Course": {
|
||||||
"Distance": 300,
|
"Distance": 400,
|
||||||
"TempsNormal": 30
|
"TempsNormal": 30
|
||||||
},
|
},
|
||||||
"Vélos": {
|
"Vélos": {
|
||||||
"Joueur1": {
|
"Joueur1": {
|
||||||
"DiamètreRoue": 700,
|
"DiamètreRoue": 700,
|
||||||
"NombreDeCapteurs": 4
|
"NombreDeCapteurs": 1
|
||||||
},
|
},
|
||||||
"Joueur2": {
|
"Joueur2": {
|
||||||
"DiamètreRoue": 700,
|
"DiamètreRoue": 700,
|
||||||
"NombreDeCapteurs": 4
|
"NombreDeCapteurs": 1
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"Vidéos": {
|
||||||
|
0: {"Fin": 25},
|
||||||
|
1: {"Fin": 25},
|
||||||
|
2: {"Fin": 25},
|
||||||
|
3: {"Fin": 25},
|
||||||
|
4: {"Fin": 25},
|
||||||
|
5: {"Fin": 25},
|
||||||
|
6: {"Fin": 25},
|
||||||
|
7: {"Fin": 15}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user