Skip to content

001 refactoring#44

Open
Montagne94 wants to merge 2 commits into
HolyMonkey:masterfrom
Montagne94:001_Refactoring
Open

001 refactoring#44
Montagne94 wants to merge 2 commits into
HolyMonkey:masterfrom
Montagne94:001_Refactoring

Conversation

@Montagne94
Copy link
Copy Markdown

No description provided.


private void Start()
{
_target = Random.insideUnitCircle * _radius;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Дублирует код на 28-ой строке

using UnityEngine;

[RequireComponent(typeof(Enemy))]
public class EnemyMove : MonoBehaviour
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Может здесь тогда и стоит хранить цель?

Comment on lines +18 to +31
foreach (var target in _targets)
{
if (target != null)
{
if (Vector3.Distance(transform.position, target.transform.position) < _minDistanceToTarget)
{
if (target.TryGetComponent<Enemy>(out Enemy enemy))
{
enemy.Die();
CheckNumberOfEnemies();
}
}
}
}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

У юнити есть тригеры

}
}

private void CheckNumberOfEnemies()
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ну чек и чек, чекнит он, дальше что? Название совершенно не отражает суть

Comment on lines +11 to +21
if (Input.GetKey(KeyCode.W))
transform.Translate(Vector2.up * _speed * Time.deltaTime);

if (Input.GetKey(KeyCode.S))
transform.Translate(Vector2.down * _speed * Time.deltaTime);

if (Input.GetKey(KeyCode.A))
transform.Translate(Vector2.left * _speed * Time.deltaTime);

if (Input.GetKey(KeyCode.D))
transform.Translate(Vector2.right * _speed * Time.deltaTime);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Дубляж кода

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants