スコアアタック用のカウント
テキストを配置
Level直下にスクリプト用意してみる
↑で配置したテキストオブジェクトをセットしておく
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class CountTimer : MonoBehaviour{
public float CountDownTime;
public Text TextCountDown;
void Start(){
CountDownTime = 60.0f;
}
void Update(){
TextCountDown.text = CountDownTime.ToString("f3");
CountDownTime -= Time.deltaTime;
if(CountDownTime <= 0.0f){
CountDownTime = 0.0f;
}
}
}
カウントダウン値を敵を倒した時に取得してスコアを変動させたい
早く倒せば得点が高くなるみたいな
Health_Enemy.csを改造すれば良いかも
まずは変数を追加
private GameObject countDownObject;
CountTimer countTimer;
private int addTimeScore;
得点発生部分で加算してあげる
if (PointsWhenDestroyed != 0){
countDownObject = GameObject.Find("CountTimer");
countTimer = countDownObject.GetComponent<CountTimer>();
addTimeScore = (int)countTimer.CountDownTime;
if(hitObjectName == "PlayerWeapon2(Clone)DamageArea (UnityEngine.GameObject)"){
meleeScore = meleeScore + addTimeScore;
CorgiEnginePointsEvent.Trigger(PointsMethods.Add, meleeScore);
}else{
shotScore = shotScore + addTimeScore;
CorgiEnginePointsEvent.Trigger(PointsMethods.Add, shotScore);
}
}
なんとか基本は出来た
youtu.be
射撃攻撃で倒すと今まで10点なんだけど、カウントダウンの数値が加算されてます