Esempio n. 1
0
    /// <summary>
    /// Возвращает нужную строку
    /// Если нужная строка есть за границами контейнера, переиспользует ее
    /// </summary>
    /// <param name="entityType"></param>
    /// <returns></returns>
    private ScoreRowPresenter GetScoreRow(EntityType entityType)
    {
        ScoreRowPresenter scoreRowPresenterReference = entityType == EntityType.Player ? _playerScoreRowPresenterTemplate : _enemyScoreRowPresenterTemplate;
        ScoreRowPresenter scoreRowPresenter          = null;

        if (_scoreRowDatas.Count >= _maxCountRows)
        {
            if (_scoreRowDatas[0].EntityType == entityType)
            {
                scoreRowPresenter = _scoreRowDatas[0].ScoreRowPresenter;
                scoreRowPresenter.transform.localPosition = _startPosition.localPosition;

                _scoreRowDatas.RemoveAt(0);
            }
        }

        if (ReferenceEquals(scoreRowPresenter, null))
        {
            scoreRowPresenter = Instantiate(scoreRowPresenterReference, _startPosition.position, Quaternion.identity, _container);
        }

        _scoreRowDatas.Add(new ScoreRowData(entityType, scoreRowPresenter));

        return(scoreRowPresenter);
    }
Esempio n. 2
0
    /// <summary>
    /// Отобразить выброшенное количество очков
    /// </summary>
    /// <param name="scoreValue">Количество выброшенных очков</param>
    /// <param name="entityType">Сущность, которая бросала кости</param>
    public void ShowThrowScore(int scoreValue, EntityType entityType = EntityType.Player)
    {
        bool isShowedUsername = GameplayManager.SelectedGameModeType == GameModeType.Throw_Online;

        ScoreRowPresenter scoreRowPresenter = GetScoreRow(entityType);

        scoreRowPresenter.Init(scoreValue, isShowedUsername);

        Vector3 rowTargetPosition = new Vector3(0, -70, 0);

        for (int i = _scoreRowDatas.Count - 1; i >= 0; i--)
        {
            Transform row = _scoreRowDatas[i].ScoreRowPresenter.transform;

            float movingSpeed = _scoreRowDatas.Count - 1 == i ? _rightMovingSpeed : _topMovingSpeed;

            StartCoroutine(MoveTo(row, rowTargetPosition, movingSpeed));
            rowTargetPosition.y += _spacing;
        }
    }
Esempio n. 3
0
 public ScoreRowData(EntityType entityType, ScoreRowPresenter scoreRowPresenter)
 {
     EntityType        = entityType;
     ScoreRowPresenter = scoreRowPresenter;
 }