- Home /
How would i make a point/wave system like this
Hello, I am trying to make a wave system so far i have this code. Which works well and makes it so it adds 5 enemy each wave and does it's job but in the picture bellow there there is art work getting shown every round, on round one it shows a 1 on round two a 2 and so on. How would you go about doing this?
Thanks for your time.
#pragma strict
var spawnPoints : Transform[];
var enemyPrefabs : GameObject[];
var yieldTimeMin = 2;
var yieldTimeMax = 5;
static var enemyCounter = 0;
var spawnXOffsetMin = 0;
var spawnXOffsetMax = 0;
var spawnZOffsetMin = 0;
var spawnZOffsetMax = 0;
var defaultSpawnNumber = 5;
var waveNumber = 1;
var isSpawning = false;
function SpawnEnemies(wave : int)
{
var spawnNum = (defaultSpawnNumber + 5 * (wave - 1));
isSpawning = true;
for(var i = 0; i < spawnNum;i++)
{
yield WaitForSeconds(Random.Range(yieldTimeMin, yieldTimeMax));
var object : GameObject = enemyPrefabs[Random.Range(0, enemyPrefabs.Length)];
var position : Transform = spawnPoints[Random.Range(0, spawnPoints.Length)];
Instantiate(object, position.position +
Vector3(Random.Range(spawnXOffsetMin, spawnXOffsetMax), 0,
Random.Range(spawnZOffsetMin, spawnZOffsetMax)), position.rotation);
enemyCounter++;
}
isSpawning = false;
}
function UpdateWave()
{
waveNumber++;
SpawnEnemies(waveNumber);
}
function Start ()
{
SpawnEnemies(waveNumber);
}
function Update ()
{
if(enemyCounter == 0 && !isSpawning)
{
UpdateWave();
}
}
Please format your code by indenting it 4 spaces or 1 tab before pasting or by highlighting it and clicking on the code button after pasting. I've fixed it for you this time.
Answer by CharlesD · Aug 15, 2012 at 07:09 AM
There are two option here, either simply use the GUI methods to draw the value of the waveNumber in a label on the screen or to use a bitmap font. A bitmap font will allow your text to be colored, smudged, stained, etc. I personally have not done anything with bitmap fonts, but this website seems to have some information on the process, and there are likely to be some existing topics on the matter, hopefully this helps you out.
The Script spawn my enemies correctly but does not refresh start a new wave with more zombies. Any help with that Please.
Answer by xwpedram_N · Jan 07, 2014 at 04:41 AM
use something like :
var UserName = new Array();
var UserRate = new Array();
function OnGUI() {
var Numbers : int = UserName .length;
var rows : int = 0;
for( var i = 0; i < Numbers; i=i)
{
if(rows % 2 == 1)
GUI.DrawTexture(Rect(0 ,(rows * 130) + 4 ,Screen.width,128), ImgBG2, ScaleMode.StretchToFill,true);
for( var j = 0 ; j < inrows ; j++)
{
try
GUI.Label(Rect((Screen.width - 305) - ( j * ProductWidth) ,(rows * 130) + 14 ,165,10),UserName[i],style);
GUI.Label(Rect((Screen.width - 305) - ( j * ProductWidth) ,(rows * 130) + 30 ,165,10),UserRate[i],style);
i++;
if(i == ProductName.length)
break;
}
and after new rate make
UserRate.Clear();
UserName.Clear();
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
I need help with a companion!!! 2 Answers
Games and websites 1 Answer
play music on key press 1 Answer
Will not shoot, also my character will only move side ways. 1 Answer