Skip to content

First commit with refactoring#42

Open
kakavlya wants to merge 6 commits into
HolyMonkey:masterfrom
kakavlya:master
Open

First commit with refactoring#42
kakavlya wants to merge 6 commits into
HolyMonkey:masterfrom
kakavlya:master

Conversation

@kakavlya
Copy link
Copy Markdown

No description provided.

Comment thread Assets/Level/Scripts/Enemy/Enemy.cs Outdated

private void Start()
{
_target = Random.insideUnitCircle * 4;
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.

дубляж кода

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.

  • магическое число

using System.Collections.Generic;
using UnityEngine;

public class GameController : 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.

Ну да, контроллер


public class GameController : MonoBehaviour
{
public static GameController Constroller;
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.

Мы не используем синглтон и это корявая реализация

public class GameController : MonoBehaviour
{
public static GameController Constroller;
private const string Message = "SendMEssage";
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.

SendMEssage

_target.SetActive(true);
}

private void Update(){
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 +22 to +29
{
_elapsedTime -= Time.deltaTime;
if (_elapsedTime < 0)
{
_timePassed = false;
_playerMover.Speed /= 2;
}
}
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.

Должна быть возможность подобрать несколько бустеров за раз

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.

Всё ешё актуально

{
[SerializeField] private float _speed;

public float Speed { get => _speed; set => _speed = value; }
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 Update()
{
Vector3 movement = new Vector3(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"), 0);
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.

   [SerializeField] private float _speed;

    public float Speed { get => _speed; set => _speed = value; }
Оставил как есть, так как через  SerializedField устанавливаем _speed в Unity. Через гетер и сетер модифицируем скорость. Если это не правильно решение, какое лучше использовать ?
SetTarget();
}

private void SetTarget()
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.

Set должен устанавливать состояние из параметра. Почитай про CQRS

Comment on lines +18 to +29
private void Update(){
foreach (var enemy in _enemies)
{
if (enemy == null)
continue;

if (Vector3.Distance(_player.gameObject.gameObject.GetComponent<Transform>().position, enemy.gameObject.gameObject.transform.position) < 0.2f)
{
_player.SendMessage(Message, enemy);
}
}
}
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.

Что с форматированием?

if (enemy == null)
continue;

if (Vector3.Distance(_player.gameObject.gameObject.GetComponent<Transform>().position, enemy.gameObject.gameObject.transform.position) < 0.2f)
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 +22 to +29
{
_elapsedTime -= Time.deltaTime;
if (_elapsedTime < 0)
{
_timePassed = false;
_playerMover.Speed /= 2;
}
}
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