Advertisement
Guest User

ZombieSpawnerScript.js

a guest
Jan 31st, 2013
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. //ZombieSpawnerScript.js
  2. var Zombie : Transform;
  3.  
  4. var maxSpawnNumber = 10;
  5. var spawnInterval = 60;
  6. var tempSpawnInterval = spawnInterval;
  7. var spawnNumber = 0;
  8. var spawnHealth = 100;
  9. var spawnSpeed : float = 3.0;
  10. var randomSpeed : boolean = false;
  11. var minRandom : float = 3;
  12. var maxRandom : float = 6;
  13. var jumpEnabled : boolean = false;
  14. var wander : boolean = false;
  15.  
  16.  
  17. function FixedUpdate () {
  18.  
  19.  
  20.  
  21.  
  22. tempSpawnInterval --;
  23.  
  24.  
  25. if(tempSpawnInterval <= 0){
  26. if(spawnNumber < maxSpawnNumber){
  27.  
  28. spawnZombie(spawnHealth, spawnSpeed, randomSpeed, minRandom, maxRandom, jumpEnabled, wander);
  29.  
  30. tempSpawnInterval = spawnInterval;
  31. spawnNumber ++;
  32. }
  33. }
  34. }
  35.  
  36.  
  37. function spawnZombie(health : int, speed : float, randSpeed : boolean, minRandom : float, maxRandom : float, jump : boolean, wander: boolean){
  38.  
  39. var newZombieInstance : Transform;
  40.  
  41. newZombieInstance = Instantiate(Zombie, transform.position, transform.rotation);
  42. var zombScript : ZombieScript = newZombieInstance.GetComponent(ZombieScript);
  43.  
  44. zombScript.maxHealth = health;
  45. zombScript.health = health;
  46. zombScript.zombieSpeed = speed;
  47. zombScript.randomSpeed = randSpeed;
  48. zombScript.minRandomSpeed = minRandom;
  49. zombScript.maxRandomSpeed = maxRandom;
  50. zombScript.jumpEnabled = jump;
  51. zombScript.wander = wander;
  52.  
  53.  
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement