using UnityEngine;
using System.Collections;
public class Tank1 : MonoBehaviour {
int state = 1;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
float speed = 0.2f;
float bound = 15.0f;
if (state == 1) {
if (transform.position.z < bound)
transform.Translate(0.0f, 0.0f, speed);
else {
transform.Rotate(0, 90, 0);
state = 2;
}
}
else if (state == 2) {
if (transform.position.x < bound)
transform.Translate(0.0f, 0.0f, speed);
else{
transform.Rotate(0, 90, 0);
state = 3;
}
}
else if (state == 3) {
if (transform.position.z > -bound)
transform.Translate(0.0f, 0.0f, speed);
else{
state = 4;
transform.Rotate(0, 90, 0);
}
}
else if (state == 4) {
if (transform.position.x > -bound)
transform.Translate(0.0f, 0.0f, speed);
else{
transform.Rotate(0, 90, 0);
state = 5;
}
}
else if (state == 5) {
if (transform.position.z < bound)
transform.Translate(0.0f, 0.0f, speed);
else{
state = 6;
}
}
}
}
//hp mp 이용
/*
while (true) {
hp -= 10;
mp -= 10;
level += 1;
if (mp < 0)
mp = 0;
Debug.Log ("Hp = " + hp + ", Mp = " + mp);
if (mp <= 0 && hp <= 0)
break;
}
Debug.Log ("while end");
*/
/*
short a = 0x0001; // ~00000001
short b = 0x0003; // ~00000010
int c = a & b;
int d = a | b;
Debug.Log ("a = " + a);
Debug.Log ("b = " + b);
Debug.Log ("c = " + c);
Debug.Log ("d = " + d);
*/
/*
int a = 1 << 2;
int b = 8 >> 2;
int c = 1 << (2 + (8 >> 2));
int d = (1 << 2) + (8 >> 2);
Debug.Log ("a = " + a);
Debug.Log ("b = " + b);
Debug.Log ("c = " + c);
Debug.Log ("d = " + d);
*/
/*
if (true && false || true && true) {
Debug.Log ("true");
}
else {
Debug.Log ("false");
}
*/
/*
int score = 250;
if (score >= 300) {
Debug.Log ("1st");
}
else if (score >= 250) {
Debug.Log ("2nd");
}
else if (score >= 200) {
Debug.Log ("3rd");
}
else if (score >= 150) {
Debug.Log ("4th");
}
else if (score >= 100) {
Debug.Log ("5th");
}
else if (score >= 50) {
Debug.Log ("6th");
}
else {
Debug.Log ("etc");
}
*/
/*
string name1 = "kim";
if (name1 == "kim") {
Debug.Log ("true");
}
else {
Debug.Log ("false");
}
*/
/*
for (i = 1; i <= 5; i++) {
Debug.Log ("i = " + i);
}
*/
/*
Debug.Log ("x = " + transform.forward.x);
Debug.Log ("y = " + transform.forward.y);
Debug.Log ("z = " + transform.forward.z);
*/
/*
Debug.Log ("scale.x = " + transform.localScale.x);
float scale = transform.localScale.x - 2;
Debug.Log ("scale.x = " + scale);
*/
/*
int x = 20;
int y = 30;
int result = x * y;
Debug.Log ("x = " + x + ", y = " + y + ", result = " + result);
*/
/*
Debug.Log ("Name = " + this.name);
Debug.Log ("x = " + transform.position.x + ", y = " + transform.position.y
+ ", z = " + transform.position.z);
*/
/*
string lastName = "Hong";
string firstName = "Gil Dong";
string Age = "30";
Debug.Log (lastName + ", " + firstName + ", age = " + Age);
*/
/*
int i = 100;
int j = 200;
int sum = 0;
sum = i + j;
Debug.Log ("sum = " + sum + ", j = " + j + ", i = " + i);
*/
/*
char c1 = 'c';
short s1 = 16000;
string name1 = "KOREA 2002";
Debug.Log("Hello, world!");
Debug.Log ("i = " + i);
Debug.Log ("c = " + c1);
Debug.Log ("s = " + s1);
Debug.Log ("name = " + name1);
*/
'Computer Language > 유니티' 카테고리의 다른 글
자료형(정수) (0) | 2014.03.31 |
---|---|
왼쪽 오른쪽 이동 그리고 정지 (0) | 2014.03.31 |
고스톱 만들기(두 좌표의 차이를 이용하여 이동) (0) | 2014.03.28 |
큐브 회전 (0) | 2014.03.28 |
c# (0) | 2014.03.28 |