Début des vidéos dynamique
This commit is contained in:
parent
a1277c3e87
commit
c94adb2d6c
@ -314,7 +314,7 @@ AudioListener:
|
||||
type: 2}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 670213594}
|
||||
m_Enabled: 1
|
||||
m_Enabled: 0
|
||||
--- !u!124 &670213596
|
||||
Behaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -729,7 +729,6 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 4cdc0f9b9c7604ab9a5d4ac68eb8277f, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
raceFinishTime: 30
|
||||
videoID: 1
|
||||
--- !u!114 &1036252281
|
||||
MonoBehaviour:
|
||||
@ -828,7 +827,7 @@ AudioListener:
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 1180963258}
|
||||
m_Enabled: 1
|
||||
m_Enabled: 0
|
||||
--- !u!124 &1180963260
|
||||
Behaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -1234,7 +1233,6 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 4cdc0f9b9c7604ab9a5d4ac68eb8277f, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
raceFinishTime: 30
|
||||
videoID: 0
|
||||
--- !u!212 &1718131636
|
||||
SpriteRenderer:
|
||||
|
@ -43,7 +43,7 @@ public class BikeManager : MonoBehaviour {
|
||||
taco.SetPlayer(playerID);
|
||||
|
||||
|
||||
normalSpeed = distanceToRun / vm.raceFinishTime;
|
||||
normalSpeed = distanceToRun / gm.GetRaceNormalTime();
|
||||
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ public class ConfigurationLoader {
|
||||
public float normalTime;
|
||||
public float[] diameters = new float[2];
|
||||
public int[] sensors = new int[2];
|
||||
public float[] videoEnds = new float[8];
|
||||
|
||||
public ConfigurationLoader() {
|
||||
Load();
|
||||
@ -27,6 +28,11 @@ public class ConfigurationLoader {
|
||||
diameters[1] = obj["Vélos"]["Joueur2"]["DiamètreRoue"].n / 1000f;
|
||||
sensors[0] = (int) obj["Vélos"]["Joueur1"]["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() {
|
||||
|
@ -26,7 +26,7 @@ public class GameManager : MonoBehaviour {
|
||||
// Skins of the two players
|
||||
private int[] _skins = new int[2];
|
||||
|
||||
ConfigurationLoader conf;
|
||||
private ConfigurationLoader conf;
|
||||
|
||||
private void Awake(){
|
||||
// Singleton
|
||||
@ -96,6 +96,10 @@ public class GameManager : MonoBehaviour {
|
||||
return conf.sensors[bikeID];
|
||||
}
|
||||
|
||||
public float GetVideoEnd(int videoID) {
|
||||
return conf.videoEnds[videoID];
|
||||
}
|
||||
|
||||
public void SetSkins(int player1, int player2) {
|
||||
_skins[0] = player1;
|
||||
_skins[1] = player2;
|
||||
@ -108,8 +112,8 @@ public class GameManager : MonoBehaviour {
|
||||
// TODO: Remove once menus are ok
|
||||
void Update() {
|
||||
if (Input.GetButtonDown("SubmitP1")) {
|
||||
Debug.Log("Héhé Cancel");
|
||||
SetSkins(0, 0);
|
||||
SetSkins(1, 0);
|
||||
LaunchRace();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,5 @@ public class HUDProgress : MonoBehaviour {
|
||||
|
||||
public void SetProgress(float 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() {
|
||||
int c = impulses.Count(i => i > Time.time - delta);
|
||||
Debug.Log("I ru speed Count: " + impulses.Count() + " c " + c);
|
||||
return c;
|
||||
return c * distancePerTick;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,11 +8,11 @@ public abstract class Tachometer : MonoBehaviour {
|
||||
private string inputID;
|
||||
|
||||
// Config
|
||||
private float ticPerTurn;
|
||||
private int ticPerTurn;
|
||||
private float wheelDiameter;
|
||||
|
||||
// Process
|
||||
private float distancePerTick;
|
||||
protected float distancePerTick;
|
||||
|
||||
protected List<float> impulses = new List<float>();
|
||||
|
||||
@ -27,11 +27,14 @@ public abstract class Tachometer : MonoBehaviour {
|
||||
ticPerTurn = gm.GetSensorsCount(playerID);
|
||||
wheelDiameter = gm.GetBikeWheelDiameter(playerID);
|
||||
|
||||
Debug.Log("Config Loaded player " + playerID);
|
||||
Debug.Log("SensorsCount: " + ticPerTurn);
|
||||
Debug.Log("Diameter: " + wheelDiameter);
|
||||
|
||||
distancePerTick = wheelDiameter * Mathf.PI / ticPerTurn;
|
||||
}
|
||||
|
||||
private void RegisterTic() {
|
||||
Debug.Log("Register");
|
||||
impulses.Add(Time.time);
|
||||
}
|
||||
|
||||
|
@ -7,48 +7,30 @@ public class VideoManager : MonoBehaviour {
|
||||
|
||||
private VideoPlayer videoPlayer;
|
||||
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) {
|
||||
Debug.Log("PID: " + playerID);
|
||||
int id = GameManager.Instance.GetSkins(playerID);
|
||||
Debug.Log("PID: " + playerID + " id: " + id);
|
||||
var vp = GetVideoPlayer();
|
||||
vp.url = Application.streamingAssetsPath + "/" + id + ".webm";
|
||||
videoPlayer = gameObject.AddComponent<VideoPlayer>();
|
||||
|
||||
var gm = GameManager.Instance;
|
||||
|
||||
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 () {
|
||||
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
|
||||
",
|
||||
"Course": {
|
||||
"Distance": 300,
|
||||
"Distance": 400,
|
||||
"TempsNormal": 30
|
||||
},
|
||||
"Vélos": {
|
||||
"Joueur1": {
|
||||
"DiamètreRoue": 700,
|
||||
"NombreDeCapteurs": 4
|
||||
"NombreDeCapteurs": 1
|
||||
},
|
||||
"Joueur2": {
|
||||
"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