using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class NewBehaviourScript : MonoBehaviour {
Text mytxt00;
Text mytxt1;
Text mytxt3;
Text mytxt5;
Text mytxt7;
Text mytxt9;
Text mytxt11;
Text mytxt13;
Text mytxtx;
int mymoney1=100;
// Use this for initialization
void Start () {
mytxt00= GameObject.Find("Canvas/Panel/Text00").GetComponent<Text>();
mytxt1 = GameObject.Find ("Canvas/Panel/Text1").GetComponent<Text> ();
mytxt3 = GameObject.Find ("Canvas/Panel/Text3").GetComponent<Text> ();
mytxt5 = GameObject.Find ("Canvas/Panel/Text5").GetComponent<Text> ();
mytxt7 = GameObject.Find ("Canvas/Panel/Text7").GetComponent<Text> ();
mytxt9 = GameObject.Find ("Canvas/Panel/Text9").GetComponent<Text> ();
mytxt11 = GameObject.Find ("Canvas/Panel/Text11").GetComponent<Text> ();
mytxt13 = GameObject.Find ("Canvas/Panel/Text13").GetComponent<Text> ();
mytxtx = GameObject.Find ("Canvas/Panel/Textx").GetComponent<Text> ();
mytxtx.text =mymoney1.ToString ();
}
// Update is called once per frame
void Update () {
}
public void myfun()
{
int num=0,num1=0,num2=0,num3=0,num4=0,num5=0,num6=0,num7=0;
num=Random.Range(0,8);
if (num == 0) {
num1 = 1;num2 = 0;num3 = 0;num4 = 0;num5 = 0;num6 = 0;num7 = 0;
mymoney1 = mymoney1+1;
}
if (num == 1) {
num1 = 0;num2 = 1;num3 = 0;num4 = 0;num5 = 0;num6 = 0;num7 = 0;
mymoney1 = mymoney1+5;
}
if (num == 2) {
num1 = 0;num2 = 0;num3 = 1;num4 = 0;num5 = 0;num6 = 0;num7 = 0;
mymoney1 = mymoney1+10;
}
if (num == 3) {
num1 = 0;num2 = 0;num3 = 0;num4 = 1;num5 = 0;num6 = 0;num7 = 0;
mymoney1 = mymoney1+25;
}
if (num == 4) {
num1 = 0;num2 = 0;num3 = 0;num4 = 0;num5 = 1;num6 = 0;num7 = 0;
mymoney1 = mymoney1+50;
}
if (num == 5) {
num1 = 0;num2 = 0;num3 = 0;num4 = 0;num5 = 0;num6 = 1;num7 = 0;
mymoney1 = mymoney1+100;
}
if (num == 6) {
num1 = 0;num2 = 0;num3 = 0;num4 = 0;num5 = 0;num6 = 0;num7 = 1;
mymoney1 = mymoney1+200;
}
mytxt00.text = num.ToString ();
mytxt1.text = num1.ToString ();
mytxt3.text = num2.ToString ();
mytxt5.text = num3.ToString ();
mytxt7.text = num4.ToString ();
mytxt9.text = num5.ToString ();
mytxt11.text = num6.ToString ();
mytxt13.text = num7.ToString ();
mytxtx.text =mymoney1.ToString ();
//Image img = GameObject.Find ("Image").GetComponent<Image> ();
//img.color = UnityEngine.Color.red;
//mytxt1.text =Random.Range(1,2).ToString();
//float translation = Time.deltaTime * 10;
}
public void myfun1()
{
mymoney1 = mymoney1 - 1;
}
public void myfun2()
{
mymoney1 = mymoney1 - 5;
}
public void myfun3()
{
mymoney1 = mymoney1 - 10;
}
public void myfun4()
{
mymoney1 = mymoney1 - 25;
}
public void myfun5()
{
mymoney1 = mymoney1 - 50;
}
public void myfun6()
{
mymoney1 = mymoney1 - 100;
}
public void myfun7()
{
mymoney1 = mymoney1 - 200;
}
}
沒有留言:
張貼留言