private IEnumerator DoSniperStuff() { while (true) { // == Preaim == currentMode = SniperMode.Preaim; aimLaser.LineColor = colorPreaim; yield return(new WaitForEndOfFrame()); // wait for update of endpos of laser before enabling again aimLaser.gameObject.SetActive(true); yield return(new WaitForSeconds(preAimTime)); // == Prepare to Fire currentMode = SniperMode.PrepareToFire; aimLaser.LineColor = colorShoot; yield return(this.Delayed(preFireTime, () => { // == Fire == currentMode = SniperMode.Cooldown; weapon.FireOnce(); aimLaser.gameObject.SetActive(false); })); yield return(new WaitForSeconds(cooldownTime)); } }
// Use this for initialization void Start() { //找到System对象 if (!SystemObject) { SystemObject = GameObject.Find("System"); } //找到摄像机 if (!(mainCamera && cameraT)) { mainCamera = GameObject.Find("Main Camera"); cameraT = mainCamera.GetComponent<Camera>(); } //找到SniperMode组件 if (!lSniperMode) { lSniperMode = mainCamera.GetComponent<SniperMode>(); } //找到mainInput组件 if (!IMainInput) { IMainInput = SystemObject.GetComponent<mainInput>(); } }