This commit is contained in:
Your Name 2018-03-16 03:01:33 +01:00
commit 4b2ba10568
4 changed files with 37 additions and 14 deletions

View File

@ -51,8 +51,6 @@ public class HighscoreLetterManager : BaseInputBehavior
private Image upButtonImage; private Image upButtonImage;
private Image downButtonImage; private Image downButtonImage;
private bool letterIsChanging; private bool letterIsChanging;
private bool upButtonPressed;
private bool downButtonPressed;
//private DateTime lastInput; //private DateTime lastInput;
//public int InputDelay = 500; //public int InputDelay = 500;
private bool _isActive; private bool _isActive;
@ -146,17 +144,13 @@ public class HighscoreLetterManager : BaseInputBehavior
if (letterIsChanging) return; if (letterIsChanging) return;
lastInput = DateTime.Now; lastInput = DateTime.Now;
letterIsChanging = true; letterIsChanging = true;
upButtonPressed = false;
downButtonPressed = false;
if (plus) if (plus)
{ {
CurrentIndex++; CurrentIndex++;
upButtonPressed = true;
} }
else else
{ {
CurrentIndex--; CurrentIndex--;
downButtonPressed = true;
} }
if (CurrentIndex < 0) CurrentIndex = Alphanumerics.Count - 1; if (CurrentIndex < 0) CurrentIndex = Alphanumerics.Count - 1;
else if (CurrentIndex >= Alphanumerics.Count) CurrentIndex = 0; else if (CurrentIndex >= Alphanumerics.Count) CurrentIndex = 0;
@ -171,5 +165,8 @@ public class HighscoreLetterManager : BaseInputBehavior
return move; return move;
} }
private void Awake()
{
CurrentIndex = 0;
}
} }

View File

@ -7,8 +7,10 @@ using UnityEngine.UI;
public class HighscoreRecordMenuManager : BaseInputBehavior public class HighscoreRecordMenuManager : BaseInputBehavior
{ {
public GameObject[] Letters; public GameObject[] Letters;
private static HighscoreRecordMenuManager[] Recorders = new HighscoreRecordMenuManager[2];
public Text PseudoText; public Text PseudoText;
public Text TimeText; public Text TimeText;
public Text WaitText;
public Image TransportImage; public Image TransportImage;
public string XAxisName public string XAxisName
{ {
@ -33,15 +35,17 @@ public class HighscoreRecordMenuManager : BaseInputBehavior
private int _selectionIndex = 0; private int _selectionIndex = 0;
private bool selectionChanging; private bool selectionChanging;
private bool waitFor;
public HighscoreEntry Entry { get; private set; } public HighscoreEntry Entry { get; private set; }
public bool Finished { get; private set; }
public int PlayerIndex { get { return Player2 ? 1 : 0; } }
public int OtherPlayerIndex { get { return Player2 ? 0 : 1; } }
// Use this for initialization // Use this for initialization
void Start() void Start()
{ {
Recorders[PlayerIndex] = this;
if (Letters != null && Letters.Any()) if (Letters != null && Letters.Any())
{ {
var manager = Letters[0].GetComponent<HighscoreLetterManager>(); var manager = Letters[0].GetComponent<HighscoreLetterManager>();
@ -53,6 +57,16 @@ public class HighscoreRecordMenuManager : BaseInputBehavior
// Update is called once per frame // Update is called once per frame
void Update() void Update()
{ {
if (Finished)
{
if (waitFor)
{
if(WaitText!=null) WaitText.text = "En attente du joueur " + (Player2 ? "2" : "1");
if (Recorders[OtherPlayerIndex].Finished)
GameManager.Instance.DisplayMenu();
}
return;
}
if (PseudoText != null) if (PseudoText != null)
PseudoText.text = GetPseudo(); PseudoText.text = GetPseudo();
if (TransportImage != null && Entry != null && GameManager.Instance.Transports != null && Entry.transport < GameManager.Instance.Transports.Count) if (TransportImage != null && Entry != null && GameManager.Instance.Transports != null && Entry.transport < GameManager.Instance.Transports.Count)
@ -76,17 +90,32 @@ public class HighscoreRecordMenuManager : BaseInputBehavior
Entry.pseudo = GetPseudo(); Entry.pseudo = GetPseudo();
HighscoresManager.Current.AddNewEntry(Entry); HighscoresManager.Current.AddNewEntry(Entry);
} }
GameManager.Instance.DisplayMenu(); Finish();
//GameManager.Instance.DisplayMenu();
} }
} }
} }
} }
private void Finish()
{
Finished = true;
if (!Recorders[OtherPlayerIndex].Finished)
{
waitFor = true;
}
}
private void Awake() private void Awake()
{ {
Finished = false;
waitFor = false;
//on récupère le highscore du joueur //on récupère le highscore du joueur
Entry = Player2 ? GameManager.Instance.EntryP2 : GameManager.Instance.EntryP1; Entry = Player2 ? GameManager.Instance.EntryP2 : GameManager.Instance.EntryP1;
CheckEntry(); CheckEntry();
} }
private void CheckEntry() private void CheckEntry()

View File

@ -45,6 +45,5 @@ public class ScrollBarButtonScript : MonoBehaviour
// Update is called once per frame // Update is called once per frame
void Update() void Update()
{ {
} }
} }

View File

@ -161,7 +161,6 @@ public class SelectorBehavior : BaseInputBehavior
//Resources.Load<Sprite>("suit_life_meter_2"); //Resources.Load<Sprite>("suit_life_meter_2");
var imageName = CurrentTransport.GetChild(0).gameObject.GetComponent<Image>().mainTexture.name; var imageName = CurrentTransport.GetChild(0).gameObject.GetComponent<Image>().mainTexture.name;
imageName = imageName.Substring(0, imageName.IndexOf('_')) + "_320x320"; imageName = imageName.Substring(0, imageName.IndexOf('_')) + "_320x320";
Debug.Log(imageName);
PlayerPanelImage.sprite = Resources.Load<Sprite>("Images/"+imageName); PlayerPanelImage.sprite = Resources.Load<Sprite>("Images/"+imageName);
PlayerPanelImage.color = Selected ? SelectorColor : NormalColor; PlayerPanelImage.color = Selected ? SelectorColor : NormalColor;
PlayerPanelImage.preserveAspect = true; PlayerPanelImage.preserveAspect = true;
@ -180,7 +179,6 @@ public class SelectorBehavior : BaseInputBehavior
if (!string.IsNullOrEmpty(YAxisName) && !Selected) if (!string.IsNullOrEmpty(YAxisName) && !Selected)
{ {
var verticalAxis = Input.GetAxis(YAxisName); var verticalAxis = Input.GetAxis(YAxisName);
Debug.Log(" "+Input.GetAxis(YAxisName));
if (Math.Abs(verticalAxis) == 1) if (Math.Abs(verticalAxis) == 1)
{ {
bool? move = IsPositiveMove(verticalAxis); bool? move = IsPositiveMove(verticalAxis);