2016年12月30日 星期五
2016年12月23日 星期五
161223
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;
}
}
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;
}
}
2016年12月15日 星期四
161216 黃綠紅
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Counter : MonoBehaviour {
int num;
double fMyWaitTime=3.0;
double WaitTimecount=0;
// Use this for initialization
void Start () {
num = 0;
}
// Update is called once per frame
void Update () {
Text mytxt=GameObject.Find("Text").GetComponent<Text>();
num = num + 1;
int countnum = num % 3;
mytxt.text =countnum.ToString();
WaitTimecount=0;
mywait ();
if (countnum==0)
{
Image img = GameObject.Find ("Image").GetComponent<Image> ();
img.color = new Color(1.0F, 0.0F, 0.0F, 1.0F);
}
if (countnum==1)
{
Image img = GameObject.Find ("Image").GetComponent<Image> ();
img.color = new Color(0.0F, 1.0F, 0.0F, 1.0F);
}
if (countnum==2)
{
Image img = GameObject.Find ("Image").GetComponent<Image> ();
img.color = new Color(1.0F, 1.0F, 0.0F, 1.0F);
}
}
void mywait()
{
while (WaitTimecount <= fMyWaitTime) {
//do stuff;
WaitTimecount = WaitTimecount + 0.01;
Debug.Log ( WaitTimecount );
}
}
}
using System.Collections;
using UnityEngine.UI;
public class Counter : MonoBehaviour {
int num;
double fMyWaitTime=3.0;
double WaitTimecount=0;
// Use this for initialization
void Start () {
num = 0;
}
// Update is called once per frame
void Update () {
Text mytxt=GameObject.Find("Text").GetComponent<Text>();
num = num + 1;
int countnum = num % 3;
mytxt.text =countnum.ToString();
WaitTimecount=0;
mywait ();
if (countnum==0)
{
Image img = GameObject.Find ("Image").GetComponent<Image> ();
img.color = new Color(1.0F, 0.0F, 0.0F, 1.0F);
}
if (countnum==1)
{
Image img = GameObject.Find ("Image").GetComponent<Image> ();
img.color = new Color(0.0F, 1.0F, 0.0F, 1.0F);
}
if (countnum==2)
{
Image img = GameObject.Find ("Image").GetComponent<Image> ();
img.color = new Color(1.0F, 1.0F, 0.0F, 1.0F);
}
}
void mywait()
{
while (WaitTimecount <= fMyWaitTime) {
//do stuff;
WaitTimecount = WaitTimecount + 0.01;
Debug.Log ( WaitTimecount );
}
}
}
--------------------------------------------------
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class bbb : MonoBehaviour {
int num;
double fMyWaitTime=3.0;
double WaitTimecount=0;
// Use this for initialization
void Start () {
num = 0;
}
// Update is called once per frame
void Update () {
Text mytxt=GameObject.Find("Text1").GetComponent<Text>();
num = num + 1;
int countnum = num % 3;
mytxt.text =countnum.ToString();
WaitTimecount=0;
mywait ();
if (countnum==0)
{
Image img = GameObject.Find ("Image2").GetComponent<Image> ();
img.color = new Color(0.0F, 0.0F, 0.0F, 1.0F);
}
if (countnum==1)
{
Image img = GameObject.Find ("Image2").GetComponent<Image> ();
img.color = new Color(0.0F, 1.0F, 0.0F, 1.0F);
}
if (countnum==2)
{
Image img = GameObject.Find ("Image2").GetComponent<Image> ();
img.color = new Color(0.0F, 0.0F, 0.0F, 1.0F);
}
}
void mywait()
{
while (WaitTimecount <= fMyWaitTime) {
//do stuff;
WaitTimecount = WaitTimecount + 0.01;
Debug.Log ( WaitTimecount );
}
}
}
-----------------------------------------------
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class ccc : MonoBehaviour {
int num;
double fMyWaitTime=3.0;
double WaitTimecount=0;
// Use this for initialization
void Start () {
num = 0;
}
// Update is called once per frame
void Update () {
Text mytxt=GameObject.Find("Text1").GetComponent<Text>();
num = num + 1;
int countnum = num % 3;
mytxt.text =countnum.ToString();
WaitTimecount=0;
mywait ();
if (countnum==0)
{
Image img = GameObject.Find ("Image3").GetComponent<Image> ();
img.color = new Color(0.0F, 0.0F, 0.0F, 1.0F);
}
if (countnum==1)
{
Image img = GameObject.Find ("Image3").GetComponent<Image> ();
img.color = new Color(0.0F, 0.0F, 0.0F, 1.0F);
}
if (countnum==2)
{
Image img = GameObject.Find ("Image3").GetComponent<Image> ();
img.color = new Color(1.0F, 1.0F, 0.0F, 1.0F);
}
}
void mywait()
{
while (WaitTimecount <= fMyWaitTime) {
//do stuff;
WaitTimecount = WaitTimecount + 0.01;
Debug.Log ( WaitTimecount );
}
}
}
2016年12月8日 星期四
161209
using UnityEngine;
using System.Collections;
public class Player : MonoBehaviour {
public GameObject obj_Player;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update ()
{
obj_Player = GameObject.Find("Capsule");
if (Input.GetKeyDown (KeyCode.A)) {
obj_Player.transform.position += new Vector3 (-0.1f, 0, 0);
} else if (Input.GetKeyDown (KeyCode.D)) {
obj_Player.transform.position += new Vector3 (0.1f, 0, 0);
} else if (Input.GetKeyDown (KeyCode.W)) {
obj_Player.transform.position += new Vector3 (0, 0, 0.1f);
} else if (Input.GetKeyDown (KeyCode.S)) {
obj_Player.transform.position += new Vector3 (0, 0, -0.1f);
}
}
}
using System.Collections;
public class Player : MonoBehaviour {
public GameObject obj_Player;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update ()
{
obj_Player = GameObject.Find("Capsule");
if (Input.GetKeyDown (KeyCode.A)) {
obj_Player.transform.position += new Vector3 (-0.1f, 0, 0);
} else if (Input.GetKeyDown (KeyCode.D)) {
obj_Player.transform.position += new Vector3 (0.1f, 0, 0);
} else if (Input.GetKeyDown (KeyCode.W)) {
obj_Player.transform.position += new Vector3 (0, 0, 0.1f);
} else if (Input.GetKeyDown (KeyCode.S)) {
obj_Player.transform.position += new Vector3 (0, 0, -0.1f);
}
}
}
2016年12月1日 星期四
161202 轉圈圈哦
using UnityEngine;
public class ExampleClass : MonoBehaviour
{
void Update()
{
// Rotate the object around its local X axis at 1 degree per second
transform.Rotate(10*Vector3.up * Time.deltaTime);
// ...also rotate around the World's Y axis
transform.Rotate(Vector3.left * Time.deltaTime, Space.World);
}
}
-
using UnityEngine;
using System.Collections;
public class test : MonoBehaviour
{
Vector3[] T = new Vector3[4];
// Use this for initialization
void Start()
{
T[0] = new Vector3(8f, -6.161964e-17f, 4f);
T[1] = new Vector3(-8f, -6.161964e-17f, 6f);
T[2] = new Vector3(-8f, -6.161964e-17f, -4f);
T[3] = new Vector3(8f, -6.161964e-17f, -6f);
}
int aa = 0;
// Update is called once per frame
void Update()
{
transform.position = Vector3.MoveTowards(transform.position, T[aa], 10 * Time.deltaTime);
if (transform.position == T[aa])
aa = (aa + 1) % 4;
}
}
2016年11月10日 星期四
20161111
using UnityEngine;
using System.Collections;
public class Player : MonoBehaviour {
public GameObject obj_Player;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update ()
{
obj_Player = GameObject.Find("Sphere");
if (Input.GetKeyDown (KeyCode.A)) {
obj_Player.transform.position += new Vector3 (-0.5f, 0, 0);
} else if (Input.GetKeyDown (KeyCode.D)) {
obj_Player.transform.position += new Vector3 (0.5f, 0, 0);
} else if (Input.GetKeyDown (KeyCode.W)) {
obj_Player.transform.position += new Vector3 (0, 0, 0.5f);
} else if (Input.GetKeyDown (KeyCode.S)) {
obj_Player.transform.position += new Vector3 (0, 0, -0.5f);
}
}
}
using System.Collections;
public class Player : MonoBehaviour {
public GameObject obj_Player;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update ()
{
obj_Player = GameObject.Find("Sphere");
if (Input.GetKeyDown (KeyCode.A)) {
obj_Player.transform.position += new Vector3 (-0.5f, 0, 0);
} else if (Input.GetKeyDown (KeyCode.D)) {
obj_Player.transform.position += new Vector3 (0.5f, 0, 0);
} else if (Input.GetKeyDown (KeyCode.W)) {
obj_Player.transform.position += new Vector3 (0, 0, 0.5f);
} else if (Input.GetKeyDown (KeyCode.S)) {
obj_Player.transform.position += new Vector3 (0, 0, -0.5f);
}
}
}
2016年11月3日 星期四
161104
using System.Collections;
using UnityEngine.UI;
using System;
using System.Linq;
using System.Collections.Generic;
public class NewBehaviourScript : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public void myfun()
{
float rnum=0;
rnum=GameObject.Find("Slider2").GetComponent<Slider>().value;
Text mytxt=GameObject.Find("Text2").GetComponent<Text>();
mytxt.text =rnum.ToString();
Image img = GameObject.Find ("Image2").GetComponent<Image> ();
img.color = new Color(rnum, 0.0F, 0.0F, 1.0F); // (紅red,綠green,藍blue,透明)
}
public void myfunn()
{
float bnum = 0;
bnum=GameObject.Find("Slider").GetComponent<Slider>().value;
Text mytxt=GameObject.Find("Text").GetComponent<Text>();
mytxt.text =bnum.ToString();
Image img = GameObject.Find ("Image").GetComponent<Image> ();
img.color = new Color(0,0,bnum,1); // (紅red,綠green,藍blue,透明)
}
public void myfunnn()
{
float gnum = 0;
gnum=GameObject.Find("Slider1").GetComponent<Slider>().value;
Text mytxt=GameObject.Find("Text1").GetComponent<Text>();
mytxt.text =gnum.ToString();
Image img = GameObject.Find ("Image1").GetComponent<Image> ();
img.color = new Color(0,gnum,0,1); // (紅red,綠green,藍blue,透明)
}
public void myfunnnn()
{
float gnum = 0;
float bnum = 0;
float rnum = 0;
gnum=GameObject.Find("Slider1").GetComponent<Slider>().value;
Text mytxt1=GameObject.Find("Text1").GetComponent<Text>();
mytxt1.text =gnum.ToString();
bnum=GameObject.Find("Slider").GetComponent<Slider>().value;
Text mytxt=GameObject.Find("Text").GetComponent<Text>();
mytxt.text =bnum.ToString();
rnum=GameObject.Find("Slider2").GetComponent<Slider>().value;
Text mytxt2=GameObject.Find("Text2").GetComponent<Text>();
mytxt2.text =rnum.ToString();
Image img = GameObject.Find ("Image3").GetComponent<Image> ();
img.color = new Color(rnum,gnum,bnum,1); // (紅red,綠green,藍blue,透明)
}
}
using UnityEngine.UI;
using System;
using System.Linq;
using System.Collections.Generic;
public class NewBehaviourScript : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public void myfun()
{
float rnum=0;
rnum=GameObject.Find("Slider2").GetComponent<Slider>().value;
Text mytxt=GameObject.Find("Text2").GetComponent<Text>();
mytxt.text =rnum.ToString();
Image img = GameObject.Find ("Image2").GetComponent<Image> ();
img.color = new Color(rnum, 0.0F, 0.0F, 1.0F); // (紅red,綠green,藍blue,透明)
}
public void myfunn()
{
float bnum = 0;
bnum=GameObject.Find("Slider").GetComponent<Slider>().value;
Text mytxt=GameObject.Find("Text").GetComponent<Text>();
mytxt.text =bnum.ToString();
Image img = GameObject.Find ("Image").GetComponent<Image> ();
img.color = new Color(0,0,bnum,1); // (紅red,綠green,藍blue,透明)
}
public void myfunnn()
{
float gnum = 0;
gnum=GameObject.Find("Slider1").GetComponent<Slider>().value;
Text mytxt=GameObject.Find("Text1").GetComponent<Text>();
mytxt.text =gnum.ToString();
Image img = GameObject.Find ("Image1").GetComponent<Image> ();
img.color = new Color(0,gnum,0,1); // (紅red,綠green,藍blue,透明)
}
public void myfunnnn()
{
float gnum = 0;
float bnum = 0;
float rnum = 0;
gnum=GameObject.Find("Slider1").GetComponent<Slider>().value;
Text mytxt1=GameObject.Find("Text1").GetComponent<Text>();
mytxt1.text =gnum.ToString();
bnum=GameObject.Find("Slider").GetComponent<Slider>().value;
Text mytxt=GameObject.Find("Text").GetComponent<Text>();
mytxt.text =bnum.ToString();
rnum=GameObject.Find("Slider2").GetComponent<Slider>().value;
Text mytxt2=GameObject.Find("Text2").GetComponent<Text>();
mytxt2.text =rnum.ToString();
Image img = GameObject.Find ("Image3").GetComponent<Image> ();
img.color = new Color(rnum,gnum,bnum,1); // (紅red,綠green,藍blue,透明)
}
}
using UnityEngine;
using System.Collections;
public class Player : MonoBehaviour {
public GameObject obj_Player;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update ()
{
obj_Player = GameObject.Find("Sphere");
if (Input.GetKeyDown (KeyCode.A)) {
obj_Player.transform.position += new Vector3 (-0.5f, 0, 0);
} else if (Input.GetKeyDown (KeyCode.D)) {
obj_Player.transform.position += new Vector3 (0.5f, 0, 0);
} else if (Input.GetKeyDown (KeyCode.W)) {
obj_Player.transform.position += new Vector3 (0, 0, 0.5f);
} else if (Input.GetKeyDown (KeyCode.S)) {
obj_Player.transform.position += new Vector3 (0, 0, -0.5f);
}
}
}
2016年10月14日 星期五
161014-Unity
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System.Timers;
public class NewBehaviourScript : MonoBehaviour {
// Use this for initialization
void Start () {
Text mytxt1 = GameObject.Find ("Canvas/Panel/Text1"). GetComponent<Text> ();
mytxt1.text = System.DateTime.Now.ToString ("MM/dd/yyyy");
Text mytxt = GameObject.Find ("Canvas/Panel/Text"). GetComponent<Text> ();
mytxt.text= System.DateTime.Now.ToString(" hh:mm:ss");
}
// Update is called once per frame
void Update () {
}
public void myfun()
{
Text mytxt2 = GameObject.Find ("Canvas/Panel/Text2"). GetComponent<Text> ();
}
}
-
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class NewBehaviourScript1 : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public void myfun()
{
Time.timeScale = 0;
Text mytxt1 = GameObject.Find ("Canvas/Panel/Text1"). GetComponent<Text> ();
mytxt1.text = System.DateTime.Now.ToString ("MM/dd/yyyy");
Text mytxt = GameObject.Find ("Canvas/Panel/Text"). GetComponent<Text> ();
mytxt.text= System.DateTime.Now.ToString(" hh:mm:ss");
}
}
-
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class NewBehaviourScript2 : MonoBehaviour {
public bool timerOn = true;
float time;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (timerOn)
{
time += Time.deltaTime;
}
Text mytxt1 = GameObject.Find ("Canvas/Panel/Text1"). GetComponent<Text> ();
mytxt1.text = System.DateTime.Now.ToString ("MM/dd/yyyy");
Text mytxt = GameObject.Find ("Canvas/Panel/Text"). GetComponent<Text> ();
mytxt.text= System.DateTime.Now.ToString(" hh:mm:ss");
}
}
161014-visual studio
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication4
{
public partial class Form1 : Form
{
DateTime dtNext;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
dtNext = DateTime.Now.AddHours(2);
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
textBox1.Text = DateTime.Now.ToString();
TimeSpan MySpan = dtNext.Subtract(DateTime.Now);
string diffHour = Convert.ToString(MySpan.Hours) ;
string diffMin = Convert.ToString(MySpan. Minutes);
string diffSec = Convert.ToString(MySpan. Seconds);
label1.Text = "還有" + diffHour + " 時 " + diffMin + " 分 " + diffSec + " 秒 ";
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
timer1.Enabled = true;
}
private void button2_Click(object sender, EventArgs e)
{
timer1.Enabled = false;
}
}
2016年10月7日 星期五
161007
=
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Random crandom = new Random();
int myrandom = crandom.Next();
int c = myrandom % 3 + 1;
textBox1.Text = "亂數"+c.ToString();
if (c==1)
{
button2.Visible = true;
button3.Visible = false;
button4.Visible = false;
}
if (c==2)
{
button2.Visible = false;
button3.Visible = true;
button4.Visible = false;
}
if (c==3)
{
button2.Visible = false;
button3.Visible = false;
button4.Visible = true;
}
}
private void Form1_Load(object sender, EventArgs e)
{
button2.Visible = false;
button3.Visible = false;
button4.Visible = false;
}
}
}
=
=
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class NewBehaviourScript : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public void myfun()
{
Text mytxt = GameObject.Find ("Canvas/Panel/Text").GetComponent<Text> ();
int c = Random.Range (1, 4);
mytxt.text =c.ToString();
Image Imgy = GameObject.Find ("Canvas/Panel/Image").GetComponent<Image>();
if ( c== 1) {
Imgy.sprite = Resources.Load<Sprite> ("Image/v") as Sprite;
}
if ( c== 2) {
Imgy.sprite = Resources.Load<Sprite> ("Image/o") as Sprite;
}
if ( c== 3) {
Imgy.sprite = Resources.Load<Sprite> ("Image/w") as Sprite;
}
}
}
訂閱:
文章 (Atom)