当前位置:操作系统 > 安卓/Android >>

android版《手工接水管》--unity3d制作的

这几天没事做,随便做了一个小demo,因为不会美术,所以就没有继续做下去,我的悲哀啊~~~
这是一个接水管的小demo,原本是flash游戏,下面看看我的例子吧~~~~

 

 \


代码就一个脚本的,也没什么可看的,大家随便都可以做的,呵呵~~~
[html]
using UnityEngine; 
using System.Collections; 
 
public class TestGoto : MonoBehaviour { 
    public GUISkin skin; 
    float width; 
    float height; 
    public Texture up; 
    public Texture down; 
    public Texture right; 
    public Texture left; 
    public Texture up_down; 
    public Texture right_left; 
    int[] images; 
    Vector4[] dires; 
    int flag; 
    int step; 
    int coml; 
    int row; 
    int m; 
    int n; 
    bool isend; 
    bool iswin; 
    int[] TF; 
    void Start () { 
       //width=80*(Screen.width/480); 
       width=Screen.width*0.12F; 
       height=width; 
       flag=0; 
       step=0; 
       row=4; 
       coml=8; 
       m=0; 
       n=0; 
       iswin=false; 
       images=new int[32]; 
       dires=new Vector4[32]; 
       TF=new int[32]; 
       for(int k=0;k<=31;k++){ 
         flag=Random.Range(1,7);   
         images[k]=flag; 
       }  
         
       //level 01 
    } 
     
    void OnGUI(){       
       
       GUI.skin=skin; 
       GUI.Window(1,new Rect(0,0,Screen.width,Screen.height),ShowWindow,""); 
        
       if(isend){ 
           WinOrLose();  
       } 
        
    } 
    void ShowWindow(int windowID){ 
       if(GUI.Button(new Rect(width*0.2F,0,width,height),"open")){        
             isend=true;         
       } 
        for(int j=0;j<row;j++){ 
           for(int i=0;i<coml;i++){             
             if(GUI.Button(new Rect(i*width+width*0.2F,(j+1)*height,width,height),select(images[j*coml+i]))){ 
                 step+=1; 
                 if(images[j*coml+i]<5){ 
                     images[j*coml+i]+=1; 
                     if(images[j*coml+i]==5){ 
                        images[j*coml+i]=1; 
                     } 
                  }else{ 
                     images[j*coml+i]+=1; 
                     if(images[j*coml+i]==7){ 
                        images[j*coml+i]=5; 
                     } 
                  } 
             } 
               
             Vector4 dir; 
             if(select(images[j*coml+i])==up){ 
                 dir=new Vector4(1,1,0,0); 
             }else if(select(images[j*coml+i])==right){ 
                 dir=new Vector4(0,1,1,0); 
             }else if(select(images[j*coml+i])==down){ 
                 dir=new Vector4(0,0,1,1); 
             }else if(select(images[j*coml+i])==left){ 
                 dir=new Vector4(1,0,0,1); 
             }else if(select(images[j*coml+i])==up_down){ 
                 dir=new Vector4(1,0,1,0); 
             }else{ 
                 dir=new Vector4(0,1,0,1); 
             } 
           &n

补充:移动开发 , Android ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,