using UnityEngine;

using System.Collections;

using System;

using Shadow;


namespace Shadow{

class Vector{

double x, y, z;

}

}

namespace Sun{

class Vector{

double x, y, z;

}

}


public class chap10_3 : MonoBehaviour {


// Use this for initialization

void Start () {

Sun.Vector a = new Vector();

}

// Update is called once per frame

void Update () {

}

}


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

c# array  (0) 2014.05.16
int[] a -> System.Array  (0) 2014.05.16
배열 선언  (0) 2014.05.16
추상 클래스  (0) 2014.05.13
로그 찍기  (0) 2014.05.13

using UnityEngine;

using System.Collections;


public class chap10_1 : MonoBehaviour {


// Use this for initialization

void Start () {

int[] scores = new int[4];

scores[0] = 20;

scores[1] = 30;

scores[2] = 50;

scores[3] = 70;

int index = 0;

foreach(int s in scores){

//print (i);

print (string.Format("scores[{0}] = {1}", index, s));

index++;

}

for(int i = 0; i < 4; i++){

//print(scores[i]);

print (string.Format("scores[{0}]= {1}", i, scores[i]));

}

}

// Update is called once per frame

void Update () {

}

}


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

int[] a -> System.Array  (0) 2014.05.16
using 사용법  (0) 2014.05.16
추상 클래스  (0) 2014.05.13
로그 찍기  (0) 2014.05.13
문자열 거꾸로 찍기  (0) 2014.05.13

using UnityEngine;

using System.Collections;


public class chap8 : MonoBehaviour {


abstract class Animal{

protected string name;

public Animal(string name){

this.name = name;

}

//protected string GetInfo(){return "Animail:name=" + name;}  error

public string GetInfo(){return "Animal:name=" + name;}

public abstract void Cry();

}

class Tiger:Animal{

public Tiger(string name):base(name){}

public override void Cry() { Debug.Log("Tiger Cry");}

}

// Use this for initialization

void Start () {

Tiger t1 = new Tiger("HODORI");

t1.Cry();

print (t1.GetInfo());

}

// Update is called once per frame

void Update () {

}

}


     

      



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

using 사용법  (0) 2014.05.16
배열 선언  (0) 2014.05.16
로그 찍기  (0) 2014.05.13
문자열 거꾸로 찍기  (0) 2014.05.13
확장 클래스  (0) 2014.05.13

chap8_1.cs -> 

public interface ILogger{

void WriteLog(string log);

}

class ConsoleLogger:ILogger{

public void WriteLog(string log){

Debug.Log(string.Format("{0}, {1}", DateTime.Now.ToLocalTime(), log));

}

}

class FileLogger : ILogger{

StreamWriter writer;

public FileLogger(string path){

writer = File.CreateText(path);

writer.AutoFlush = true;

}

public void WriteLog(string message){

writer.WriteLine("{0}, {1}", DateTime.Now.ToShortTimeString(), message);

}

}


public class CH8_1 : MonoBehaviour {

ILogger[] loggers = new ILogger[2];

// Use this for initialization

void Start () {

ConsoleLogger console = new ConsoleLogger();

FileLogger fileLogger = new FileLogger(Application.dataPath + "/log.txt");

loggers[0] = console;

loggers[1] = fileLogger;

AddLog("GameStart");

AddLog("User 320 Enter");

AddLog("Enter Room 1");

AddLog("Leave Room 1");

}

void AddLog(string message){

for(int i = 0; i < loggers.Length; i++){

loggers[i].WriteLog(message);

}

}

// Update is called once per frame

void Update () {

AddLog(Time.time.ToString());

}

}



ClimateMonitor.cs->


using UnityEngine;

using System.Collections;

using System;

using System.IO;


public class ClimateMonitor : MonoBehaviour {

private ILogger logger;

public int temperature = 0;

public void SetLogger(ILogger logger){

this.logger = logger;

}

// Use this for initialization

void Start () {

SetLogger(new ConsoleLogger());

}

// Update is called once per frame

void Update () {

int t = (int)(Time.time) % 100;

if(t != temperature){

SetTemperature(t);

}

}

void SetTemperature(int t){

temperature = t;

logger.WriteLog(" temperature is " + t);

}

}


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

배열 선언  (0) 2014.05.16
추상 클래스  (0) 2014.05.13
문자열 거꾸로 찍기  (0) 2014.05.13
확장 클래스  (0) 2014.05.13
얕은 복사와 깊은 복사  (0) 2014.05.12

using UnityEngine;

using System.Collections;


public static class StringExtension{

public static string Reverse(this string s){

string text = "";

for(int i = s.Length - 1; i >= 0; i--)

{

text += s[i];

}

return text;

}

}


public class chap8_1 : MonoBehaviour {


// Use this for initialization

void Start () {

string text = "abcde";

text = text.Reverse();

print(text);

}

// Update is called once per frame

void Update () {

}

}



오예 신나부러~~!!!!~!~!~


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

추상 클래스  (0) 2014.05.13
로그 찍기  (0) 2014.05.13
확장 클래스  (0) 2014.05.13
얕은 복사와 깊은 복사  (0) 2014.05.12
out 을 이용하여 메인에서 배열을 써봅시다.  (0) 2014.05.09

using UnityEngine;

using System.Collections;


public static class IntegerExtension

{

public static int Square(this int myInt){

return myInt * myInt;

}

public static int Power1(this int myInt, int exponet)

{

int result = myInt;

for ( int i = 0; i < exponet; i++ ){

result = result * myInt;

}

return result;

}

public static int Add(int a, int b)

{

return a + b;

}

public static string NewAdd1(this string a, string b)

{

return a + " " + b;

}

}


public class Extansed : MonoBehaviour {


// Use this for initialization

void Start () {

int myInt = 2;

print (myInt.Square());

print (myInt.Power1(3));

string a = "hobbang";

print (a.NewAdd1("dfd"));

}

// Update is called once per frame

void Update () {

}

}



using UnityEngine;

using System.Collections;


public class MyClassho

{

public int MyField1;

public int MyField2;

public MyClassho DeepCopy()

{

MyClassho newCopy1 = new MyClassho();

newCopy1.MyField1 = this.MyField1;

newCopy1.MyField2 = this.MyField2;

return newCopy1;

}

public MyClassho(){

}

public MyClassho(int myfield){

//myfield = 10;

Debug.Log(myfield);

}

}


public class comp : MonoBehaviour {

MyClassho sourceho = new MyClassho(15);

// Use this for initialization

void Start () {

//sourceho.MyField1;

sourceho.MyField1 = 10;

sourceho.MyField2 = 20;

MyClassho target = sourceho;

target.MyField2 = 30;

print (sourceho.MyField1 + " " + sourceho.MyField2);

print (target.MyField1 + " " + target.MyField2);

print("Deep Copy");

MyClassho sourceho1 = new MyClassho();

sourceho1.MyField1 = 10;

sourceho1.MyField2 = 20;

MyClassho target1 = sourceho1.DeepCopy();

target1.MyField2 = 30;

print (sourceho1.MyField1 + " " + sourceho1.MyField2);

print (target1.MyField1 + " " + target1.MyField2);

}

// Update is called once per frame

void Update () {

}

}




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

문자열 거꾸로 찍기  (0) 2014.05.13
확장 클래스  (0) 2014.05.13
out 을 이용하여 메인에서 배열을 써봅시다.  (0) 2014.05.09
원 구 실린더 계산 하기. base()사용법  (0) 2014.05.09
열거형  (0) 2014.05.02

using UnityEngine;

using System.Collections;


public class Fill{

public void  FillArray(out int[] arr)

{

arr = new int[5] {1, 2, 3, 4, 5} ;

}

}


public class Pro : MonoBehaviour {

// Use this for initialization

void Start () {

int[] theArray;

Fill fill=new Fill();

//Fill.FillArray(out theArray);

fill.FillArray(out theArray);

print ("Array element are:13131");

for( int i = 0; i < theArray.Length; i++)

{

print("TheArray[i]= "+theArray[i] + " ");

}

print ("exit");

}

// Update is called once per frame

void Update () {

}

}


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

확장 클래스  (0) 2014.05.13
얕은 복사와 깊은 복사  (0) 2014.05.12
원 구 실린더 계산 하기. base()사용법  (0) 2014.05.09
열거형  (0) 2014.05.02
비행기와 퍼즐 맞추기  (0) 2014.05.02

class TestClass

{

public class Shape

{

public const double PI = Mathf.PI;

protected double x, y;

public Shape()

{

}

public Shape(double x, double y)

{

this.x = x;

this.y = y;

}

public virtual double Area()

{

return x * y;

}

}

public class Circle : Shape

{

public Circle(double r) : base (r, 0)

{

}

public override double Area()

{

return PI * x * x;

}

}

public class Sphere : Shape

{

public Sphere(double r) : base (r, 0)

{

}

public override double Area()

{

return 4 * PI * x * x;

}

}

public class Cylinder : Shape

{

public Cylinder(double r, double h): base(r, h)

{

}

public override double Area()

{

return 2 * PI * x * x + 2 * PI * x * y;

}

}

/*

public TestClass()

{

}

*/

}


public class virtualclass : MonoBehaviour {

// Use this for initialization

void Start () {

double r = 3.0, h =5.0;

TestClass.Shape c = new TestClass.Circle(r);

string c1 = string.Format("Area of Circle = {0:F2}", c.Area());

print (c1);

TestClass.Shape s = new TestClass.Sphere(r);

string s1 = string.Format("Area of Sphere = {0:F2}", s.Area());

print(s1);

TestClass.Shape l = new TestClass.Cylinder(r, h);

string l1 = string.Format("Area of Cylinder = {0:F2}", l.Area());

print (l1);

}

// Update is called once per frame

void Update () {

}

}



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

얕은 복사와 깊은 복사  (0) 2014.05.12
out 을 이용하여 메인에서 배열을 써봅시다.  (0) 2014.05.09
열거형  (0) 2014.05.02
비행기와 퍼즐 맞추기  (0) 2014.05.02
카메라 좌표찍기  (0) 2014.05.02

using UnityEngine;

using System.Collections;




public class yulgurhyung : MonoBehaviour {

// Use this for initialization

enum Fruits{Orange, Apple, Banana, Strawberry, Grape};

void Start () {

Fruits ft = Fruits.Apple;

switch(ft)

{

case Fruits.Orange:

print();

break;

case Fruits.Apple:

print();

break;

case Fruits.Banana:

print();

break;

case Fruits.Strawberry:

print();

break;

case Fruits.Grape:

print();

break;

}

}

// Update is called once per frame

void Update () {

//print (Fruits.Orange);

// print (Fruits.Grape);

//print (Fruits.Strawberry);

}

}


+ Recent posts