1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Assets.Scripts;
using UnityEngine.UI;
public class UIController : MonoBehaviour
{
public Text Distance;
public Text Score;
public Text HighScore;
public Text NbVials;
public Image Battery;
public Image Progression;
public Sprite[] ProgressionSprites;
public List<Sprite> BatteryImages;
private Player _player;
private int _oldHs;
void Start ()
{
_player = GameObject.FindWithTag("Player").GetComponent<Player>();
HighScore.enabled = false;
_oldHs = PlayerPrefs.GetInt("highscore");
}
void Update ()
{
Distance.text = (int.Parse(Distance.text) + 1).ToString();
_player.Score += 1;
Score.text = _player.Score.ToString();
NbVials.text = _player.NbVials.ToString();
DisplayBattery();
HandlePowerUps();
HandleScore();
}
private void HandleScore()
{
if (_oldHs < _player.Score)
HighScore.enabled = true;
}
private void HandlePowerUps()
{
}
private void DisplayBattery()
{
Battery.sprite = BatteryImages[_player.Battery/8];
Progression.sprite = ProgressionSprites[_player.Progression / 5];
}
}