public void targetFilmingCompleted(TargetToFilm ttf) { totalScore += ttf.scoreValue; Debug.Log("targetFilmingCompleted! Got Score: " + ttf.scoreValue + " Score:" + totalScore); textScrollerController.replaceLastText(infoTexts[curMission], ttf.tagName); endMission(); }
// Update is called once per frame void Update() { TargetToFilm ttf = null; UnityEngine.Ray ray = cam.ScreenPointToRay(new Vector3(1280 / 2, 720 / 2, 0)); UnityEngine.RaycastHit [] hits = Physics.RaycastAll(ray); bool nowHitting = false; for (int i = 0; i < hits.Length; ++i) { ttf = hits[i].transform.gameObject.GetComponent <TargetToFilm>(); if (ttf && ttf.targetActive) { nowHitting = true; totalFilmedTime += Time.deltaTime; GameObject.FindWithTag("GameController").GetComponent <GameController>().updateTotalFilmedTime(totalFilmedTime); if (crosshair.hasShot() == true) { totalFilmedTime = 0; GameObject.FindWithTag("GameController").GetComponent <GameController>().targetFilmingCompleted(ttf); ttf.targetActive = false; } break; } } crosshair.setFocus(ttf, nowHitting); if (nowHitting) { decreaseCooldown = 0; } else { decreaseCooldown += Time.deltaTime; } if (nowHitting == false && decreaseCooldown > 3.0f) { totalFilmedTime -= 0.5f * Time.deltaTime; if (totalFilmedTime < 0) { totalFilmedTime = 0; } } }
public void setFocus(TargetToFilm ttf, bool hasFocus) { //if (false == ttf.targetActive) return; if (hasFocus == true) { direction = -1.0f / ttf.timeToFilm; lastTtf = ttf; } else { if (lastTtf) { direction = 0.5f / lastTtf.timeToFilm; } } }