Skip to content

Commit 15db8a2

Browse files
committed
minor cleanup, add attribute Value to IGem
1 parent 1d8931c commit 15db8a2

File tree

4 files changed

+38
-23
lines changed

4 files changed

+38
-23
lines changed

.idea/.idea.unity c# workshop/.idea/contentModel.xml

Lines changed: 8 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.unity c# workshop/.idea/workspace.xml

Lines changed: 23 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Init/Scripts/Gem.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@ namespace EGaDSTutorial
66
{
77
public interface IGem
88
{
9+
float Value { get; }
910
void OnPickup();
10-
1111
}
1212

1313

1414
[RequireComponent(typeof(Collider2D))]
15-
[AddComponentMenu("Gem/Gem")]
15+
[AddComponentMenu("Gem/BaseGem")]
1616
public class Gem : MonoBehaviour, IGem
1717
{
1818
[SerializeField] private float _value;
19+
public float Value => _value;
1920

2021
public void OnPickup()
2122
{

Assets/Init/Scripts/Player.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,17 @@ class Player : MonoBehaviour
1313
#region Singleton
1414

1515
private static Player _instance;
16-
public static Player Instance
17-
{
18-
get { return _instance ? _instance : (_instance = FindObjectOfType<Player>()); }
19-
}
16+
public static Player Instance => _instance ? _instance : (_instance = FindObjectOfType<Player>());
2017

2118
#endregion
2219

2320
#region Movement
2421

2522
public void Update()
2623
{
27-
transform.position = transform.position + new Vector3(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"), 0) * Time.deltaTime * _speed;
24+
transform.position =
25+
transform.position + _speed * Time.deltaTime *
26+
new Vector3(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"), 0);
2827
}
2928

3029
#endregion
@@ -37,9 +36,5 @@ private void OnCollisionEnter2D(Collision2D other)
3736
}
3837

3938
#endregion
40-
41-
42-
43-
4439
}
4540
}

0 commit comments

Comments
 (0)