From 047ca6cc9cf1739f84a88d6d53685beaacbfbb7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Nu=C8=9Biu?= Date: Thu, 8 Aug 2019 23:37:12 +0300 Subject: [PATCH] Rename enemy classes --- Assets/Scripts/src/Base/EnemyBase.cs | 2 +- ...ectionOnlyOnCollision.cs => BasicCollisionEnemy.cs} | 7 +++---- ...OnCollision.cs.meta => BasicCollisionEnemy.cs.meta} | 0 ...mChangeDirection.cs => BasicRandomMovementEnemy.cs} | 10 +++++++--- ...ection.cs.meta => BasicRandomMovementEnemy.cs.meta} | 0 5 files changed, 11 insertions(+), 8 deletions(-) rename Assets/Scripts/src/Enemy/{EnemyThatChangeDirectionOnlyOnCollision.cs => BasicCollisionEnemy.cs} (52%) rename Assets/Scripts/src/Enemy/{EnemyThatChangeDirectionOnlyOnCollision.cs.meta => BasicCollisionEnemy.cs.meta} (100%) rename Assets/Scripts/src/Enemy/{EnemyThatRandomChangeDirection.cs => BasicRandomMovementEnemy.cs} (84%) rename Assets/Scripts/src/Enemy/{EnemyThatRandomChangeDirection.cs.meta => BasicRandomMovementEnemy.cs.meta} (100%) diff --git a/Assets/Scripts/src/Base/EnemyBase.cs b/Assets/Scripts/src/Base/EnemyBase.cs index cf322e6..171631c 100644 --- a/Assets/Scripts/src/Base/EnemyBase.cs +++ b/Assets/Scripts/src/Base/EnemyBase.cs @@ -23,7 +23,7 @@ public abstract class EnemyBase : MonoBehaviour, IExplosable protected void FixedUpdate() { if (gameStateManager.IsGamePaused || gameStateManager.IsPlayerMovementForbidden) {return;} - Rigidbody2d.MovePosition(Rigidbody2d.position + Direction * Speed * Time.deltaTime); + Rigidbody2d.MovePosition(Rigidbody2d.position + Speed * Time.deltaTime * Direction); } public void OnTriggerEnter2D(Collider2D other) diff --git a/Assets/Scripts/src/Enemy/EnemyThatChangeDirectionOnlyOnCollision.cs b/Assets/Scripts/src/Enemy/BasicCollisionEnemy.cs similarity index 52% rename from Assets/Scripts/src/Enemy/EnemyThatChangeDirectionOnlyOnCollision.cs rename to Assets/Scripts/src/Enemy/BasicCollisionEnemy.cs index 168d982..4716694 100644 --- a/Assets/Scripts/src/Enemy/EnemyThatChangeDirectionOnlyOnCollision.cs +++ b/Assets/Scripts/src/Enemy/BasicCollisionEnemy.cs @@ -1,9 +1,8 @@ -namespace Assets.Scripts.src.Enemy +namespace src.Enemy { - public class EnemyThatChangeDirectionOnlyOnCollision : EnemyBase + public class BasicCollisionEnemy : EnemyBase + /* Enemy that will change direction only on collision. */ { - - //Momentan lasam asa, o sa difere probabil la animatii and stats, nu stiu sigur protected new void Start() { Speed = 4f; diff --git a/Assets/Scripts/src/Enemy/EnemyThatChangeDirectionOnlyOnCollision.cs.meta b/Assets/Scripts/src/Enemy/BasicCollisionEnemy.cs.meta similarity index 100% rename from Assets/Scripts/src/Enemy/EnemyThatChangeDirectionOnlyOnCollision.cs.meta rename to Assets/Scripts/src/Enemy/BasicCollisionEnemy.cs.meta diff --git a/Assets/Scripts/src/Enemy/EnemyThatRandomChangeDirection.cs b/Assets/Scripts/src/Enemy/BasicRandomMovementEnemy.cs similarity index 84% rename from Assets/Scripts/src/Enemy/EnemyThatRandomChangeDirection.cs rename to Assets/Scripts/src/Enemy/BasicRandomMovementEnemy.cs index fb2528b..6631cfb 100644 --- a/Assets/Scripts/src/Enemy/EnemyThatRandomChangeDirection.cs +++ b/Assets/Scripts/src/Enemy/BasicRandomMovementEnemy.cs @@ -1,9 +1,10 @@ using UnityEngine; -namespace Assets.Scripts.src.Enemy +namespace src.Enemy { public class EnemyThatRandomChangeDirection : EnemyBase { + /* Enemy that will move randomly */ protected new void Start() { Speed = 4f; @@ -12,9 +13,12 @@ namespace Assets.Scripts.src.Enemy protected new void FixedUpdate() { + var pos = transform.position; + var x = pos.x; + var y = pos.y; if (gameStateManager.IsGamePaused || gameStateManager.IsPlayerMovementForbidden) { return; } - if (transform.position.x == Mathf.Floor(transform.position.x) && - transform.position.y == Mathf.Floor(transform.position.y)) + if (x == Mathf.Floor(x) && + y == Mathf.Floor(y)) { if (RandomChange()) { diff --git a/Assets/Scripts/src/Enemy/EnemyThatRandomChangeDirection.cs.meta b/Assets/Scripts/src/Enemy/BasicRandomMovementEnemy.cs.meta similarity index 100% rename from Assets/Scripts/src/Enemy/EnemyThatRandomChangeDirection.cs.meta rename to Assets/Scripts/src/Enemy/BasicRandomMovementEnemy.cs.meta