using UnityEngine;

using System.Collections;


public class Example1 : MonoBehaviour {

/*

string GetInfo(string lastName, string firstName, int age){

return firstName + "," + lastName + ",Age"=+age;

}

*/

int Add(int a, int b){

return a+b;

}

public GameObject Cube;

public GameObject Silinder;

public int dir = 0;

/*

int Calc(int a, int b, out int result){

result = a + b;

result3 = "ok";

return a - b;

}

*/

public int Count = 10;

int Sum(int Count){

int sum1 = 0;

int sum = 0;

for(int i = 1; i<=Count; i++){

sum = Add (sum1, i);

sum1++;

}

return sum;

}

// Use this for initialization

void Start () {

int count = 10;

int result = Sum (Count);

Debug.Log (count+ result);

/*

string fullname = GetFullName("kim", "yuna");

Debug.Log (fullname);

int result = Add (30, 20);

Debug.Log(result);

//int result4;

//Add(30,20, out result2);

//Debug.Log (result);

int result3;

Calc (30, 20, out result3);

Debug.Log("result3_1="+result3 +"result3_2="+result);

*/

}

void moveLeft(GameObject object1){

object1.transform.Translate(new Vector3(-0.1f, 0, 0));

//object1.transform.Rotate(new Vector3(10f, 10f, 10f));

//object1.transform.localScale = new Vector3(10, 10, 10);

}

void moveRight(GameObject object2){

object2.transform.Translate(new Vector3(0.1f, 0, 0));

}

// Update is called once per frame

void Update () {

if (dir <0//director

moveLeft (Cube);

else if(dir >0)

moveRight(Cube);

}

//1per 60

void OnGUI(){

if(GUI.Button(new Rect(10,10,100,100), "Move Left")){

Debug.Log ("Clicked1");

//moveLeft(Cube);

dir = -1;

}

if(GUI.Button(new Rect(120,10,100,100), "stop")){

Debug.Log ("Clicked2");

//moveRight(Silinder);

dir = 0;

}

if(GUI.Button(new Rect(230,10,100,100), "Move Right")){

Debug.Log ("Clicked2");

//moveRight(Silinder);

dir = 1;

}

}

}




'Computer Language > 유니티' 카테고리의 다른 글

자료형(실수)  (0) 2014.03.31
자료형(정수)  (0) 2014.03.31
탱크 이동  (0) 2014.03.28
고스톱 만들기(두 좌표의 차이를 이용하여 이동)  (0) 2014.03.28
큐브 회전  (0) 2014.03.28



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


using UnityEngine;

using System.Collections;


public class GoStop : MonoBehaviour {

public GameObject Cube1;

public GameObject Cube2;

public GameObject Cube3;

public GameObject Target;

float x1, y1, z1;

float x2, y2, z2;

float x3, y3, z3;

// Use this for initialization

void Start () {

x1 = Target.transform.position.x - Cube1.transform.position.x;

y1 = Target.transform.position.y - Cube1.transform.position.y;

z1 = Target.transform.position.z - Cube1.transform.position.z;

Debug.Log("x1= " + x1 + ",y1= " + y1 + "z1 =" +z1);

x2 = Target.transform.position.x - Cube2.transform.position.x;

y2 = Target.transform.position.y - Cube2.transform.position.y;

z2 = Target.transform.position.z - Cube2.transform.position.z;

Debug.Log("x2= " + x2 + ",y2= " + y2 + "z2 =" +z2);

x3 = Target.transform.position.x - Cube3.transform.position.x;

y3 = Target.transform.position.y - Cube3.transform.position.y;

z3 = Target.transform.position.z - Cube3.transform.position.z;

Debug.Log("x3= " + x3 + ",y3= " + y3 + "z3 =" +z3);


}

// Update is called once per frame

void Update () {

if(Cube1.transform.position.z <Target.transform.position.z)

Cube1.transform.Translate(x1*0.01f,y1*0.01f,z1*0.01f);

if(Cube2.transform.position.z <Target.transform.position.z)

Cube2.transform.Translate(x2*0.01f,y2*0.01f,z2*0.01f);

if(Cube3.transform.position.z <Target.transform.position.z)

Cube3.transform.Translate(x3*0.01f,y2*0.01f,z3*0.01f);

}

}



짧은코드

using UnityEngine;

using System.Collections;


public class GoStop1 : MonoBehaviour {

public GameObject cube_1; //

public GameObject cube_2;

public GameObject cube_3;

public GameObject Target;

Vector3 v1, v2, v3;

// Use this for initialization

void Start () {

cube_1.rigidbody.AddForce(new Vector3(0,100,0)); //물체의 발사는 오브젝트.rigidbody.AddFroce(방향*힘)  공간벡터 Vector3(x,y,z)

cube_1.rigidbody.AddForce(Vector3.up*1000);

v1 = Target.transform.position - cube_1.transform.position;

v2 = Target.transform.position - cube_2.transform.position;

v3 = Target.transform.position - cube_3.transform.position;

Debug.Log("v1= " + v1 + ",v2= " + v2 + "v3 =" +v3);


}

// Update is called once per frame

void Update () {

if(cube_1.transform.position.z <Target.transform.position.z)

cube_1.transform.Translate(v1.x*0.01f,v1.y*0.01f,v1.z*0.01f);

if(cube_2.transform.position.z <Target.transform.position.z)

cube_2.transform.Translate(v2.x*0.01f,v2.y*0.01f,v2.z*0.01f);

if(cube_3.transform.position.z <Target.transform.position.z)

cube_3.transform.Translate(v3.x*0.01f,v3.y*0.01f,v3.z*0.01f);

}

}



'Computer Language > 유니티' 카테고리의 다른 글

자료형(정수)  (0) 2014.03.31
왼쪽 오른쪽 이동 그리고 정지  (0) 2014.03.31
탱크 이동  (0) 2014.03.28
큐브 회전  (0) 2014.03.28
c#  (0) 2014.03.28

sing UnityEngine;

using System.Collections;


public class Primative : MonoBehaviour {

public int Count = 3;

public int TotalRow =5;

public int TotalCol =10;

GameObject cube,cube1,cube3,cube4,cube5,cube6;

int row;

int col;

// Use this for initialization

void Start () {

for(int row = 1; row <= TotalRow; row++)

{

//cube = GameObject.CreatePrimitive(PrimitiveType.Cube);

//cube.transform.position = new Vector3(i*2, 0, 0);

for(int col = 1; col <= TotalCol; col++)

{

//row col 0 2 4 6 8                  row 1 3 5 7 9

if((row % 2 ==0 && col % 2 == 0) || (row % 2 == 1 && col % 2 == 1))

{

cube1 = GameObject.CreatePrimitive(PrimitiveType.Cube);

cube1.transform.position = new Vector3(col*2, row*2, 0);

if (row==1 && col==1)

{  

cube = cube1;

}

if (row==1 && col==3)

{

cube3 = cube1;

}

if (row==1 && col==5)

{

cube4 = cube1;

}

if (row==1 && col==7)

{

cube5 = cube1;

}

if (row==1 && col==9)

{

cube6 = cube1;

}

}

}

}

Debug.Log("Cube : x= " + cube.transform.position.x 

+ "Cube : y= " + cube.transform.position.y + "Cube : z= " + cube.transform.position.z);

}

// Update is called once per frame

void Update () {

cube.transform.Rotate(10, 10, 10);

cube3.transform.Rotate(10, 10, 10);

cube4.transform.Rotate(10, 10, 10);

cube5.transform.Rotate(10, 10, 10);

cube6.transform.Rotate(10, 10, 10);

/*

GameObject Capsule = GameObject.CreatePrimitive(PrimitiveType.Capsule);

Debug.Log("Capsule : x= " + Capsule.transform.localScale.x 

+ "Capsule : y= " + Capsule.transform.position.y + "Capsule : z= " + Capsule.transform.position.z);

*/

}

}


/*

cube = GameObject.CreatePrimitive(PrimitiveType.Cube);

Debug.Log("Cube : x= " + cube.transform.position.x 

+ "Cube : y= " + cube.transform.position.y + "Cube : z= " + cube.transform.position.z);

Debug.Log("Cube : x= " + cube.transform.localScale.x);

cube.transform.position=new Vector3(1,0,0);

cube1 = GameObject.CreatePrimitive(PrimitiveType.Cube);

Debug.Log("Cube : x= " + cube.transform.position.x 

+ "Cube : y= " + cube.transform.position.y + "Cube : z= " + cube.transform.position.z);

Debug.Log("Cube : x= " + cube.transform.localScale.x);

cube1.transform.position=new Vector3(3,0,0);

*/



'Computer Language > 유니티' 카테고리의 다른 글

자료형(정수)  (0) 2014.03.31
왼쪽 오른쪽 이동 그리고 정지  (0) 2014.03.31
탱크 이동  (0) 2014.03.28
고스톱 만들기(두 좌표의 차이를 이용하여 이동)  (0) 2014.03.28
c#  (0) 2014.03.28

c#, .net, asp, asp

관리되는 응용 프로그램(managed applications) -> unity3d engine

MS CLR(Common Language Runtime)-> 관리하기 어려워 만듬 DrawText (Windows Mac Linux), 메모리관리 1GIGA 300메가 OS가 쓰는 영역. 700메가 게임(100메가),영화, 메모리 부족경고 보내줌.

스테이지 10메가 스테이지2 10메가  스테이지 2로 갔을 경우 스테이지 1을 해제시킴.

Windows Mac Linux(OS), App1, App2

Api -> 코드를 통해서 os의 기능을 사용할 수 있도록. 파일 읽고 쓸 수 있도록 메모리에 값을 저장, 데이터를 보낸다던지.

관리되지 않는 응용 프로그램 (unmanaged applications) -> COCOS2D

gabage collector 

A->B->C->A  못지움. 그래서 이런 경우를 없애야 된다.


프로그램 = 코드(알고리즘) + 데이터(텍스쳐)


게임 C# 참조 그림


'Computer Language > 유니티' 카테고리의 다른 글

자료형(정수)  (0) 2014.03.31
왼쪽 오른쪽 이동 그리고 정지  (0) 2014.03.31
탱크 이동  (0) 2014.03.28
고스톱 만들기(두 좌표의 차이를 이용하여 이동)  (0) 2014.03.28
큐브 회전  (0) 2014.03.28

+ Recent posts