From 88ce9369dac0f9fc1c7c304e7641c94e6149211f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Nu=C8=9Biu?= Date: Wed, 29 May 2019 19:31:30 +0300 Subject: [PATCH] Rename Player to PlayerController and move rigidbody to base class --- Assets/Scripts/src/Base/PlayerBase.cs | 11 +++++++++++ .../src/Player/{Player.cs => PlayerController.cs} | 9 +++------ 2 files changed, 14 insertions(+), 6 deletions(-) rename Assets/Scripts/src/Player/{Player.cs => PlayerController.cs} (76%) diff --git a/Assets/Scripts/src/Base/PlayerBase.cs b/Assets/Scripts/src/Base/PlayerBase.cs index 401d623..10573b3 100644 --- a/Assets/Scripts/src/Base/PlayerBase.cs +++ b/Assets/Scripts/src/Base/PlayerBase.cs @@ -1,7 +1,18 @@ +using System; +using UnityEngine; + namespace src.Base { public abstract class PlayerBase : GameplayComponent { public float movementSpeed = 4f; + + /* Movement */ + protected Rigidbody2D Rigidbody2d; + + protected void Start() + { + Rigidbody2d = GetComponent(); + } } } \ No newline at end of file diff --git a/Assets/Scripts/src/Player/Player.cs b/Assets/Scripts/src/Player/PlayerController.cs similarity index 76% rename from Assets/Scripts/src/Player/Player.cs rename to Assets/Scripts/src/Player/PlayerController.cs index 206adbd..83b7068 100644 --- a/Assets/Scripts/src/Player/Player.cs +++ b/Assets/Scripts/src/Player/PlayerController.cs @@ -4,14 +4,11 @@ using UnityEngine; namespace src.Player { - public class Player : PlayerBase + public class PlayerController : PlayerBase { - /* Movement */ - private Rigidbody2D _rigidbody2d; - private void Start() { - _rigidbody2d = GetComponent(); + base.Start(); } private void Update() @@ -37,7 +34,7 @@ namespace src.Player var movementVector = new Vector2(horizontal, vertical); - _rigidbody2d.position += movementSpeed * Time.deltaTime * movementVector; + Rigidbody2d.position += movementSpeed * Time.deltaTime * movementVector; #elif UNITY_IOS || UNITY_ANDROID // Phone movement is not supported yet. #elif UNITY_PS4 || UNITY_XBOXONE