Sinh sản sóng

0
105

Đã kiểm tra với phiên bản: 5.1
– –
Khó khăn: Người mới bắt đầu
Đem lại những đợt sóng nguy hiểm vô hạn để thách thức người chơi của chúng tôi.

GameController

Expand view

Copy code
using UnityEngine;
using System.Collections;

public class GameController : MonoBehaviour
{
public GameObject hazard;
public Vector3 spawnValues;
public int hazardCount;
public float spawnWait;
public float startWait;
public float waveWait;

void Start ()
{
StartCoroutine (SpawnWaves ());
}

IEnumerator SpawnWaves ()
{
yield return new WaitForSeconds (startWait);
while (true)
{
for (int i = 0; i < hazardCount; i++)
{
Vector3 spawnPosition = new Vector3 (Random.Range (-spawnValues.x, spawnValues.x), spawnValues.y, spawnValues.z);
Quaternion spawnRotation = Quaternion.identity;
Instantiate (hazard, spawnPosition, spawnRotation);
yield return new WaitForSeconds (spawnWait);
}
yield return new WaitForSeconds (waveWait);
}
}
}


1


2


3


4


5


6


7


8


9


10


11


12


13


14


15


16


17


18


19


20


21


22


23


24


25


26


27


28


29


30


31


32


33


DestroyByTime

Expand view

Copy code
using UnityEngine;
using System.Collections;

public class DestroyByTime : MonoBehaviour
{
public float lifetime;

void Start ()
{
Destroy (gameObject, lifetime);
}
}


1


2


3


4


5


6


7


8


9


10


11


12


LEAVE A REPLY

Please enter your comment!
Please enter your name here