Skip to content

MyFirstRefactoring#27

Open
flangedmace wants to merge 18 commits into
HolyMonkey:masterfrom
flangedmace:RefactoredGroup1
Open

MyFirstRefactoring#27
flangedmace wants to merge 18 commits into
HolyMonkey:masterfrom
flangedmace:RefactoredGroup1

Conversation

@flangedmace
Copy link
Copy Markdown

No description provided.

Comment thread Assets/Group1/Scripts/Follower.cs Outdated

[RequireComponent(typeof(Rigidbody2D))]
[RequireComponent(typeof(CircleCollider2D))]
public abstract class Follower : 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 thread Assets/Group1/Scripts/Follower.cs Outdated
[SerializeField] private Rigidbody _rigidbody;

[SerializeField] private float _moveSpeed;
[SerializeField] private float _maxTargetDistance;
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 thread Assets/Group1/Scripts/Follower.cs Outdated

protected virtual void OnTriggerEnter2D(Collider2D collision) { }

private void SetTargetPosition()
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 thread Assets/Group1/Scripts/Player.cs Outdated

private void Start()
{
_startEnemies = GameObject.FindGameObjectsWithTag("Enemy").Length;
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.

Мы не используем FindGameObjectsWithTag

Comment thread Assets/Group1/Scripts/Player.cs Outdated
}
}

public IEnumerator BoostSpeed(float workingTime)
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.

duration

Comment thread Assets/Group1/Scripts/SpeedBooster.cs Outdated
{
if (collision.gameObject.TryGetComponent<Player>(out Player player))
{
StartCoroutine(player.BoostSpeed(player.BoostSpeedTime));
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 thread Assets/Group1/Scripts/Enemy.cs Outdated
{
if (collision.gameObject.TryGetComponent<Enemy>(out Enemy enemy))
{
GetComponentInParent<LevelFinisher>().AddKilledEnemy();
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 thread Assets/Group1/Scripts/EnemyMover.cs Outdated
_rigidbody.velocity = (_target - transform.position).normalized * _speed * Time.deltaTime;

if (transform.position == _target)
_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.

дубляж кода

Comment thread Assets/Group1/Scripts/EnemyMover.cs Outdated

private void Update()
{
_rigidbody.velocity = (_target - transform.position).normalized * _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.

Есть замечательная функция которая работает точней.
У тебя как минимум противник будет регулярно пролетать сквозь цель

Comment thread Assets/Group1/Scripts/LevelFinisher.cs Outdated
_maxEnemiesNumber = GetComponentsInChildren<Enemy>().Length;
}

public void AddKilledEnemy()
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 thread Assets/Group1/Scripts/Player.cs Outdated

private void Update()
{
_rigidbody.velocity = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")) * _moveSpeed * 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.

Слишком длинная строка

_rigidbody.velocity = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")) * _moveSpeed * Time.deltaTime;
}

public IEnumerator BoostSpeed(float duration, float multiplier)
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 thread Assets/Group1/Scripts/LevelFinisher.cs Outdated
Comment on lines +29 to +38
public void AddKilledEnemy(Enemy enemy)
{
_deadEnemies.Add(enemy);

if (_deadEnemies.Count >= _maxEnemiesNumber)
{
_menu.SetActive(true);
gameObject.SetActive(false);
}
}
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.

_aliveEnemies убираешь из него противника и смотришь осталось ли там что-то

{
public event OnDied Died;

public delegate void OnDied(Enemy sender);
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.

Делегаты мы сами не определяем, а если бы и определяли то стиль там не такой. Воспользуйся стандартными Action

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