找传奇、传世资源到传世资源站!

见缝插针 小游戏源码

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

游戏见缝插针from clipboardusing System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.UI;using UnityEngine.SceneManagement;public class GameManager : MonoBehaviour { private Transform startPoint; private Transform spawnPoint; private Pin currentPin; private bool isGameOver = false; private int score = 0; private Camera mainCamera; public Text scoreText; public GameObject pinPrefab; public float speed = 3;// Use this for initializationvoid Start () { startPoint = GameObject.Find("StartPoint").transform; spawnPoint = GameObject.Find("SpawnPoint").transform; mainCamera = Camera.main; SpawnPin();} private void Update() { if (isGameOver) return; if (Input.GetMouseButtonDown(0)) { score ; scoreText.text = score.ToString(); currentPin.StartFly(); SpawnPin(); } } void SpawnPin() { currentPin = GameObject.Instantiate(pinPrefab, spawnPoint.position, pinPrefab.transform.rotation).GetComponent<Pin>(); } public void GameOver() { if (isGameOver) return; GameObject.Find("Circle").GetComponent<RotateSelf>().enabled = false; StartCoroutine(GameOverAnimation()); isGameOver = true; } IEnumerator GameOverAnimation() { while (true) { mainCamera.backgroundColor = Color.Lerp(mainCamera.backgroundColor, Color.red, speed * Time.deltaTime); mainCamera.orthographicSize = Mathf.Lerp(mainCamera.orthographicSize, 4, speed * Time.deltaTime); if( Mathf.Abs( mainCamera.orthographicSize-4 )<0.01f) { break; } yield return 0; } yield return new WaitForSeconds(0.2f); SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); }}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复