位置: 编程技术 - 正文

unity3d 中实现猜拳游戏(unity3d做游戏)

编辑:rootadmin
using UnityEngine;using System.Collections;public class caiquan : MonoBehaviour { public Rect r1; public Rect r2; //public Texture t1; //public Texture t2; //public Texture t3; public Texture[] textures; public int computerCP; public int playerCP; public string result; public bool isShowTime=true; public float MaxTime=3; void Start () { r1=new Rect(,,,); r2=new Rect(,,,); } // Update is called once per frame void Update () { if (isShowTime) { computerShow (); } else { MaxTime-=Time.deltaTime; if(MaxTime<0){ isShowTime=true; MaxTime=; } } } void computerShow(){ if (computerCP < 2) { computerCP&#;&#;; } else { computerCP=0; } } void OnGUI(){ GUI.Label (new Rect(0,0,,),result); r1=GUI.Window (0, r1, WindowFunc1, "Computer VS Player"); r2=GUI.Window (1, r2, WindowFunc2, "Player Input"); } void WindowFunc1(int id){ GUI.DragWindow (new Rect (0, 0, , )); GUI.Box (new Rect (, , , ),textures[computerCP] ); GUI.Box (new Rect (, , , ),textures[playerCP] ); } void WindowFunc2(int id){ if (GUI.Button (new Rect (, , , ), textures [0])) { playerCP=0; computerChuPai(); panding(); } if (GUI.Button (new Rect (, , , ), textures [1])) { playerCP=1; computerChuPai(); panding(); } if (GUI.Button (new Rect (, , , ), textures [2])) { playerCP=2; computerChuPai(); panding(); } GUI.DragWindow (new Rect (0, 0, , )); } void computerChuPai(){ computerCP = Random.Range (0,3); } void panding(){ if (computerCP == playerCP) { result="ping ju"; }else if (computerCP - playerCP == -1||computerCP-playerCP==2) { result = "computer win"; } else if (computerCP - playerCP == 1|| computerCP-playerCP==-2) { result="player win"; } }}

推荐整理分享unity3d 中实现猜拳游戏(unity3d做游戏),希望有所帮助,仅作参考,欢迎阅读内容。

unity3d 中实现猜拳游戏(unity3d做游戏)

文章相关热门搜索词:unity3d quaternion,unity3d游戏算法,unity答题游戏,unity3d怎么打组,unity3d gameobject,unity3d游戏算法,unity3d gameobject,unity3d dotween,内容如对您有帮助,希望把文章链接给更多的朋友!

unity3d加密代码结束篇 确定Mono可以成功后,我就自己修改了它的源代码,一开始虽然不顺利,但幸运的是可以用g_warning打印。通过打印发现自己多解密了一个字节。最终成功

委托、事件、单例在Unity3D中的使用 原文请点击这里翻译:claudioHereIdemonstratehowtocreatedelegates,eventsandsingletonstoworkinconjunction.ThistutorialiswrittenforUnity3D,However,similarcodecanbeusedforanyC#or.NETapplication.

Unity3d 基于物理渲染Physically-Based Rendering之最终篇 前情提要:讲求基本算法Unity3d基于物理渲染Physically-BasedRendering之specularBRDFplus篇Unity3d基于物理渲染Physically-BasedRendering之实现最后我们用fragmentshader实现

本文链接地址:https://www.jiuchutong.com/biancheng/383575.html 转载请保留说明!

上一篇:Unity3d 基于物理渲染Physically-Based Rendering之实现(unity3d物理现象模拟)

下一篇:unity3d加密代码结束篇(unity游戏加密)

免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

鄂ICP备2023003026号

网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

友情链接: 武汉网站建设 电脑维修 湖南楚通运网络