是男人就下一百层代码
Posted xisheng
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了是男人就下一百层代码相关的知识,希望对你有一定的参考价值。
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class GameManage : MonoBehaviour private Image bg; private GameObject[] clouds; private GameObject[] award; private Transform gameCanvas; // Use this for initialization void Start () bg = GameObject.Find("BG").GetComponent<Image> (); clouds = Resources.LoadAll<GameObject> ("clouds"); award = Resources.LoadAll<GameObject> ("Award"); gameCanvas = GameObject.Find ("GameCanvas").transform; InvokeRepeating ("CreateAll", 0, 1); // Update is called once per frame void Update () bg.material.SetTextureOffset ("_MainTex", new Vector2 (0, Time.time / 5)); private void CreateAll() //生成云和物品 int rangeNum = Random.Range (0,5); GameObject tempObject = null; if (0 == rangeNum) tempObject = clouds [3]; else tempObject = clouds [Random.Range (0, clouds.Length - 1)]; GameObject clude = Instantiate (tempObject, new Vector3 (Random.Range(-340,341),800,0), Quaternion.identity); clude.transform.SetParent (gameCanvas, false); GameObject award = CreateAward (); if (award != null) Instantiate (award,new Vector3(0,20,0),Quaternion.identity).transform.SetParent (clude.transform,false); clude.AddComponent<CloudsMove> (); private GameObject CreateAward() int num = Random.Range (0, 9); GameObject temp = null; if (0 == num) temp = award [1]; else if (0 < num && num < 4) temp = award [0]; else temp = null; return temp;
using System.Collections; using System.Collections.Generic; using UnityEngine; public class CloudsMove : MonoBehaviour // Use this for initialization void Start () // Update is called once per frame void Update () transform.Translate (Vector3.up * Time.deltaTime * 3);
以上是关于是男人就下一百层代码的主要内容,如果未能解决你的问题,请参考以下文章
C/C++项目实战:《是男人就下一百层》,530 行源码分享
C语言项目实战:《是男人就下100层》零基础项目,160行源代码示例