-
Notifications
You must be signed in to change notification settings - Fork 5
/
GameManager.cs
43 lines (37 loc) · 1.06 KB
/
GameManager.cs
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
using System.Collections.Generic;
using UnityEngine;
namespace Section.Lists.Challenge01
{
public class GameManager : MonoBehaviour
{
/// Challenge Overview:
/// Create a list of names and print each.
/// On key press:
/// remove" a random element from the list
/// re-print the remaining names
///
public List<string> names = new List<string>();
// Start is called before the first frame update
void Start()
{
foreach (var name in names)
{
Debug.Log(name);
}
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Delete))
{
var nameToRemove = names[Random.Range(0, names.Count)];
names.Remove(nameToRemove);
foreach (var name in names)
{
Debug.Log(name);
}
Debug.Log("We removed " + nameToRemove);
}
}
}
}