Skip to content

Commit

Permalink
minor cleanup, add attribute Value to IGem
Browse files Browse the repository at this point in the history
  • Loading branch information
imcdo committed Nov 4, 2019
1 parent 1d8931c commit 15db8a2
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 23 deletions.
14 changes: 8 additions & 6 deletions .idea/.idea.unity c# workshop/.idea/contentModel.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 23 additions & 6 deletions .idea/.idea.unity c# workshop/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Assets/Init/Scripts/Gem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@ namespace EGaDSTutorial
{
public interface IGem
{
float Value { get; }
void OnPickup();

}


[RequireComponent(typeof(Collider2D))]
[AddComponentMenu("Gem/Gem")]
[AddComponentMenu("Gem/BaseGem")]
public class Gem : MonoBehaviour, IGem
{
[SerializeField] private float _value;
public float Value => _value;

public void OnPickup()
{
Expand Down
13 changes: 4 additions & 9 deletions Assets/Init/Scripts/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,17 @@ class Player : MonoBehaviour
#region Singleton

private static Player _instance;
public static Player Instance
{
get { return _instance ? _instance : (_instance = FindObjectOfType<Player>()); }
}
public static Player Instance => _instance ? _instance : (_instance = FindObjectOfType<Player>());

#endregion

#region Movement

public void Update()
{
transform.position = transform.position + new Vector3(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"), 0) * Time.deltaTime * _speed;
transform.position =
transform.position + _speed * Time.deltaTime *
new Vector3(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"), 0);
}

#endregion
Expand All @@ -37,9 +36,5 @@ private void OnCollisionEnter2D(Collision2D other)
}

#endregion




}
}

0 comments on commit 15db8a2

Please sign in to comment.