ENFIN! Foutue vidéos

This commit is contained in:
Florent Guiotte 2018-03-14 22:50:45 +01:00
parent c94adb2d6c
commit 28750f4d94
5 changed files with 59 additions and 23 deletions

View File

@ -42,17 +42,24 @@ public class BikeManager : MonoBehaviour {
taco = gameObject.AddComponent<RAWTachometer>();
taco.SetPlayer(playerID);
normalSpeed = distanceToRun / gm.GetRaceNormalTime();
}
// Update is called once per frame
void Update () {
Speed = taco.GetSpeed();
vm.speed = Speed / normalSpeed;
if (taco.GetDistanceRun() < distanceToRun) {
Speed = taco.GetSpeed();
vm.speed = Speed / normalSpeed;
} else {
// Player finished
vm.speed = 1f;
}
}
public bool LoadingComplete() {
return vm.setUp;
}
void FixedUpdate() {
}

View File

@ -5,8 +5,10 @@ using UnityEngine.SceneManagement;
public enum States {
Menu = 0,
RaceSetup = 1,
Race = 2
LoadingScene = 5,
LoadingVideo = 10,
RaceSetup = 15,
Race = 20
}
public class GameManager : MonoBehaviour {
@ -33,9 +35,10 @@ public class GameManager : MonoBehaviour {
if (_instance != null && _instance != this) {
Debug.Log("WARNING: Other instance of GameManager found.");
Destroy(gameObject);
} else {
_instance = this;
}
return;
}
_instance = this;
// Don't destroy when loading new scene
DontDestroyOnLoad(transform.gameObject);
@ -112,20 +115,29 @@ public class GameManager : MonoBehaviour {
// TODO: Remove once menus are ok
void Update() {
if (Input.GetButtonDown("SubmitP1")) {
SetSkins(1, 0);
SetSkins(0, 1);
LaunchRace();
}
if (_status == States.LoadingVideo) {
Debug.Log(bm1.LoadingComplete() + " " + bm2.LoadingComplete());
if (bm1.LoadingComplete() && bm2.LoadingComplete()) {
Debug.Log("Videos are set up and ready to go!");
_status = States.RaceSetup;
StartCoroutine(SetupRace());
}
}
}
public void LaunchRace() {
_status = States.RaceSetup;
_status = States.LoadingScene;
StartCoroutine(LoadGameScene());
}
void OnLevelFinishedLoading(Scene scene, LoadSceneMode mode) {
// TODO: Check game status
if (_status == States.RaceSetup) {
StartCoroutine(SetupRace());
if (_status == States.LoadingScene) {
Debug.Log("Loading videos");
_status = States.LoadingVideo;
}
}

View File

@ -7,14 +7,17 @@ public class VideoManager : MonoBehaviour {
private VideoPlayer videoPlayer;
public float speed {get; set; }
public bool setUp = false;
private int skinID;
public void SetSkin(int playerID) {
videoPlayer = gameObject.AddComponent<VideoPlayer>();
var gm = GameManager.Instance;
int id = gm.GetSkins(playerID);
videoPlayer.url = Application.streamingAssetsPath + "/" + id + ".webm";
skinID = gm.GetSkins(playerID);
videoPlayer.url = Application.streamingAssetsPath + "/" + skinID + ".webm";
Debug.Log("Video Stats:" +
" canSetTime: " + videoPlayer.canSetTime +
@ -23,11 +26,25 @@ public class VideoManager : MonoBehaviour {
videoPlayer.skipOnDrop = true;
videoPlayer.isLooping = false;
videoPlayer.playOnAwake = false;
videoPlayer.prepareCompleted += VideoReady;
videoPlayer.Prepare();
}
float startTime = gm.GetVideoEnd(id) - gm.GetRaceNormalTime();
void VideoReady(VideoPlayer source) {
Debug.Log("Ok ima set");
videoPlayer.prepareCompleted -= VideoReady;
var gm = GameManager.Instance;
float startTime = gm.GetVideoEnd(skinID) - gm.GetRaceNormalTime();
videoPlayer.seekCompleted += VideoSetup;
videoPlayer.time = startTime;
}
void VideoSetup(VideoPlayer source) {
videoPlayer.seekCompleted -= VideoSetup;
videoPlayer.Play();
setUp = true;
}
void Update () {

View File

@ -7,8 +7,8 @@
NombreDeCapteurs: Le nombre de capteurs placés sur la roue du vélo
",
"Course": {
"Distance": 400,
"TempsNormal": 30
"Distance": 200,
"TempsNormal": 15
},
"Vélos": {
"Joueur1": {
@ -21,7 +21,7 @@
}
},
"Vidéos": {
0: {"Fin": 25},
0: {"Fin": 67},
1: {"Fin": 25},
2: {"Fin": 25},
3: {"Fin": 25},

View File

@ -5,12 +5,12 @@ EditorBuildSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Scenes:
- enabled: 1
path: Assets/Scenes/Menus.unity
guid: 14eaf8d7877bf4d50a0bed2739d2bf96
- enabled: 1
path: Assets/Scenes/GameManagerTest.unity
guid: 3bf6872fcde3f48108b47c2eaa97b6f7
- enabled: 1
path: Assets/Scenes/Menus.unity
guid: 14eaf8d7877bf4d50a0bed2739d2bf96
- enabled: 1
path: Assets/Scenes/GameScene.unity
guid: 8541a1132a4264d69b949d040e7244a4