using UnityEngine;
using System.Collections;publicclass GemStone : MonoBehaviour {publicfloat xoffset = -4.8f;publicfloat yoffset = -2f;publicint rowIndex=0;publicint clouIndex=0;public GameObject[] gemstonebgs;//寶石數(shù)組publicint gemstontype;//寶石類型private GameObject gemastoneBg;public SpriteRenderer spriteRenderer;publicbool isSelectd{set{if(value){spriteRenderer.color = Color.red;}else{spriteRenderer.color = Color.white;}}}public CameController cameController;// Use this for initializationvoid Awake(){}void Start () {cameController = GameObject.Find ("GameCortoller").GetComponent<CameController> ();spriteRenderer = gemastoneBg.GetComponent<SpriteRenderer> ();}// Update is called once per framevoid Update () {}publicvoidUpdatePosition(int _rowIndex,int _coluIndex)//沒有特效的下落特效{rowIndex = _rowIndex;clouIndex = _coluIndex;this.transform.position = new Vector3 (clouIndex+xoffset, rowIndex+yoffset, 0);}publicvoidTweenPOsition(int _rowIndex,int _coluIndex)//當(dāng)消除之后的插件特效{rowIndex = _rowIndex;clouIndex = _coluIndex;iTween.MoveTo (this.gameObject,iTween.Hash("x",clouIndex+xoffset,"y",rowIndex+yoffset,"time",0.4f));}publicvoidRandomCreateGemstone()//生成隨機(jī)類型的寶石{if (gemastoneBg != null) {return; }gemstontype = Random.Range(0, gemstonebgs.Length);gemastoneBg = Instantiate(gemstonebgs[gemstontype]) as GameObject;gemastoneBg.transform.parent = this.transform;}publicvoidOnMouseDown()//鼠標(biāo)點擊事件{cameController.Select (this);}publicvoidDisPose()//釋放寶石!{Destroy (this.gameObject);Destroy (gemastoneBg.gameObject);cameController = null;}
}
Backone.cs的代碼 用來支持andorid設(shè)備虛擬返回鍵
using UnityEngine;
using System.Collections;publicclass BackOne : MonoBehaviour {// Use this for initializationvoid Start () {}// Update is called once per framevoid Update () {//android 鍵盤的虛擬返回鍵if(Input.GetKey(KeyCode.Escape)){Application.LoadLevel("Load");}}
}
頁面跳轉(zhuǎn)之間的代碼EnergButtoncripts.cs
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
publicclass EnergButtonScript : MonoBehaviour {//游戲的鍵值類// Use this for initializationvoid Start () {}// Update is called once per framevoid Update () {}publicvoidEnergClick(){CameController cameColtroller = new CameController ();cameColtroller.EnergRelease ();}publicvoidExit(){Application.LoadLevel ("Load");}publicvoidButtomRemove(){GameObject.FindGameObjectWithTag ("Gameover").GetComponent<RomoveBottom> ().isRomove = true;}///<summary>////////////</summary>publicvoidSeStart()//重新開始{CameController c = new CameController ();c.SecendStart ();}publicvoidLoad(){Application.LoadLevel ("GameStart");}publicvoidExplain(){Application.LoadLevel ("My");}publicvoidOpen(){Application.Quit ();}publicvoidBack(){Application.LoadLevel ("Load");}publicvoidAudio(){if (GameObject.FindGameObjectWithTag ("AudioText").GetComponent<Text> ().text == "Open") {PlayerPrefs.SetInt("Index",1);GameObject.FindGameObjectWithTag ("Audio").GetComponentInChildren<Text> ().text = "Close";print("1");}if (GameObject.FindGameObjectWithTag ("AudioText").GetComponent<Text> ().text == "Close") {PlayerPrefs.SetInt("Index",0);GameObject.FindGameObjectWithTag ("AudioText").GetComponent<Text> ().text = "Open";}}
}
主界面菜單按鈕下落 RomoveButton.cs
using UnityEngine;
using System.Collections;
publicclass RomoveBottom : MonoBehaviour {publicfloat RomoveSpeed = 1.5f;publicbool isRomove = false;//在游戲開始界面進(jìn)行返回的按鈕!// Use this for initializationvoid Start () {}//-313// Update is called once per framevoid Update () {if (isRomove) {transform.Translate (-Vector3.up * RomoveSpeed);if (transform.localPosition.y <= -185) {RomoveSpeed = 0.0f;}}}
}
Score.cs 分?jǐn)?shù)的腳本
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
publicclass ScoreScript : MonoBehaviour {//分?jǐn)?shù)的類publicint Score=0;publicint Experience=0;//關(guān)卡Text s;Text e;// Use this for initializationvoid Start () {s=transform.GetComponent<Text> ();e=transform.GetComponent<Text> ();}// Update is called once per framevoid Update () {s.text = Experience.ToString ();e.text = Score.ToString ();}
}
退出游戲的腳本 Screen.cs
using UnityEngine;
using System.Collections;publicclass Screen : MonoBehaviour {// Use this for initializationvoid Start () {}//退出整個游戲場景// Update is called once per framevoid Update () {if(Input.GetKey(KeyCode.Escape)){Application.Quit();}}
}
動畫腳本 SkillAnimation.cs
using UnityEngine;
using System.Collections;publicclass SkillAnimation : MonoBehaviour {//當(dāng)經(jīng)驗條滿格的時候,進(jìn)行技能輸出!int current;int count;float timer;publicint fps=10;Object [] ani;publicstring path;// Use this for initializationvoid Start () {current = 0;ani = Resources.LoadAll("Image/"+path+"/img");count = ani.Length;}// Update is called once per framevoid Update () {if (ani != null) {timer+=Time.deltaTime;if(timer>=1.0f/fps){timer=0;current++;if(current>count-1){current=0;}this.renderer.material.mainTexture = (Texture2D)ani[current];}}}
}