init
This commit is contained in:
commit
e0a842f222
796 changed files with 361371 additions and 0 deletions
55
Assets/Scripts/ScoreSystem.cs
Normal file
55
Assets/Scripts/ScoreSystem.cs
Normal file
|
@ -0,0 +1,55 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class ScoreSystem : MonoBehaviour{
|
||||
|
||||
int score;
|
||||
string scoreStr;
|
||||
TMP_Text scoreText;
|
||||
public int Score { get { return score; }
|
||||
set {
|
||||
score = value;
|
||||
score = Mathf.Min(99999999, score);
|
||||
scoreStr = string.Empty;
|
||||
scoreStr += score.ToString();
|
||||
scoreText.text = scoreStr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Awake(){
|
||||
scoreText = GetComponent<TMP_Text>();
|
||||
}
|
||||
|
||||
|
||||
public void AddScore(int amount, bool tween=true){
|
||||
score = Mathf.Min(99999999, score + amount);
|
||||
scoreStr = string.Empty;
|
||||
for (int i = 0; i < 8 - score.ToString().Length; i++){
|
||||
scoreStr += "0";
|
||||
}
|
||||
scoreStr += score.ToString();
|
||||
scoreText.text = scoreStr;
|
||||
|
||||
if (tween)
|
||||
{
|
||||
float scaleOffset = MyMethods.Remap(amount, 1, MyVars.enemyKillScore, 1.04f, 1.1f);
|
||||
|
||||
LeanTween.scale(gameObject, new Vector3(scaleOffset, scaleOffset, scaleOffset), 0.05f).setEaseOutElastic();
|
||||
LeanTween.scale(gameObject, Vector3.one, 0.075f).setDelay(0.05f).setEaseInSine();
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveScore(int amount){
|
||||
score = Mathf.Max(0, score - amount);
|
||||
scoreStr = string.Empty;
|
||||
for (int i = 0; i < 8 - score.ToString().Length; i++){
|
||||
scoreStr += "0";
|
||||
}
|
||||
scoreStr += score.ToString();
|
||||
scoreText.text = scoreStr;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue