保齡球期末展示
記分板的主要的程式碼
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine;
public class Score : MonoBehaviour
{
public int score = 0;
public Text text;
public void Add(int ammount)
{
score += ammount;
UpdateDisplay();
}
// Use this for initialization
void Start () {
score = 0;
}
// Update is called once per frame
void UpdateDisplay () {
text.text = "Score" + score;
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bowling : MonoBehaviour {
public Transform pin;
public float threshold = .6f;
public int point = 1;
public Score score;
void Awake() {
score = GameObject.FindGameObjectWithTag("Score").GetComponent<Score>();
}
void CheckItFell()
{
try
{
if(pin.up.y <threshold) ///如果被撞的角度大小於threshold
{
score.Add(point);
gameObject.GetComponent<Collider>().enabled = false;
}
}
catch
{
Debug.Log("Looks like the pin went into the Dead Zone!");
}
}
void OnTriggerEnter(Collider other)
{
CheckItFell(); ///有無掉落
}
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}
建議新增的部分:
1.希望我們能增加一點遊戲性,球道部分可以做更多變化,球可以做不同的種類性質,變化可以多一點。
個人想進一步新增:
1.希望能對球多做一些物理上的變化(如選轉變化球等等)。
2.計分版的部分計算不同名次的分數等等。
3. 背景場景換成森林,雪地等等的讓體驗更好!
沒有留言:
張貼留言