using UnityEngine;

using System.Collections;


public class GameManagel : MonoBehaviour {

public GameObject Monster;

public GameObject Zombie;

public Transform[] point;      //it makes me use other GameObjects. Declare array...

public float CreateTime = 2.0f;

// Use this for initialization

void Start () {

point = GameObject.Find ("SpawnPoint").GetComponentsInChildren<Transform>();     //access SpawnPoint and its childrens

}

// Update is called once per frame

void Update () {

if(Time.time > CreateTime)

{

if(GameObject.FindGameObjectsWithTag("Monster").Length + GameObject.FindGameObjectsWithTag("Zombie").Length <=5)

{

CreateMonster();

CreateTime = Time.time + 2.0f;

}

}

}// end of Update().

void CreateMonster()

{

int idx = Random.Range(1,point.Length);

Instantiate(Monster,point[idx].position,Quaternion.identity);

Instantiate(Zombie,point[idx].position,Quaternion.identity);

//end of CreateMonster().

}


'유니티3D > 예제' 카테고리의 다른 글

UpDownRotate  (0) 2013.09.03
StreetLight.cs  (0) 2013.08.26
powercell.cs  (0) 2013.08.26
wall.cs  (0) 2013.08.26
All Script in ThirdPersonShooingGame  (0) 2013.08.23

using UnityEngine;

using System.Collections;


public class PowerCell : MonoBehaviour {

public float Speed = 3.0f;


// Update is called once per frame

void Update () {

gameObject.transform.Rotate(Vector3.up * Speed * Time.deltaTime);

}

void OnTriggerEnter(Collider col){

if(col.gameObject.tag == "Player")

{

//col.gameObject.GetComponent<scriptName>().CellPickUP();

col.gameObject.SendMessage("CellPickUp");

Destroy(gameObject);

}

}

}


'유니티3D > 예제' 카테고리의 다른 글

StreetLight.cs  (0) 2013.08.26
gamemanagel.cs  (0) 2013.08.26
wall.cs  (0) 2013.08.26
All Script in ThirdPersonShooingGame  (0) 2013.08.23
plane size 동적할당  (0) 2013.08.21

using UnityEngine;

using System.Collections;


public class Wall : MonoBehaviour {

public GameObject BulletSpark;

public AudioClip wallHit;


void OnCollisionEnter(Collision Col)

{

if(Col.transform.tag == "Bullet")

{

audio.clip = wallHit;

audio.Play();

GameObject newSpark = Instantiate(BulletSpark,Col.transform.position,Quaternion.LookRotation(-Col.transform.position))as GameObject//spark position : back -> front

Destroy(newSpark,8.0f);

Destroy(Col.gameObject);

}

}

}


'유니티3D > 예제' 카테고리의 다른 글

gamemanagel.cs  (0) 2013.08.26
powercell.cs  (0) 2013.08.26
All Script in ThirdPersonShooingGame  (0) 2013.08.23
plane size 동적할당  (0) 2013.08.21
HPBar  (0) 2013.08.20

'유니티3D > 예제' 카테고리의 다른 글

powercell.cs  (0) 2013.08.26
wall.cs  (0) 2013.08.26
plane size 동적할당  (0) 2013.08.21
HPBar  (0) 2013.08.20
시계바  (0) 2013.08.20

+ Recent posts