using System.Collections;
using System.Collections.Generic;
using UnityEngine;

using TMPro;
using System;
using UnityEngine.TextCore.Text;

public class ScoreC : MonoBehaviour
{
    [SerializeField] private float scoreMultiplier = 10;
    [SerializeField] private TMP_Text scoreValue = null;
    [SerializeField] private new CameraC camera = null;
    [SerializeField] private CharacterC character = null;

    private bool gameIsOn;

    // Start is called before the first frame update
    void Start()
    {
        this.gameIsOn = true;
    }

    // Update is called once per frame
    void Update()
    {
        if (!this.gameIsOn)
        {
            return;
        }

        int score = Math.Max(0, Mathf.FloorToInt(this.scoreMultiplier * this.character.transform.position.x));
        this.scoreValue.text = score.ToString();
    }

    public void StopScoring()
    {
        this.gameIsOn = false;
        this.camera.Reset();
        this.character.StopMoving();
    }
}
