Nextrek
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
using UnityEngine; using System.Collections; using System.Collections.Generic; public class EnemyPool : MonoBehaviour { public static EnemyPool Instance; public Transform[] enemyPrefeb; private bool startGame = false; private int totalEnemies = 0; private int killedEnemies = 0; private int aliveEnemies = 0; private static int MAX_ENEMY = 100; private static float SPAWING_TIME = 5; // every 3 secs private float _timer = SPAWING_TIME; List<int> toBeCreated = new List<int>(); void Awake() { Instance = this; } void Start() { } public void InsertEnemy(int type,int cnt) { if ((type < 0) || (type > (enemyPrefeb.Length-1))) { Debug.LogError("type " + type + ", cannot be used. Discarding " + cnt + " enemies!"); return; } totalEnemies += cnt; for(int i=0;i<cnt;i++) { // push toBeCreated.Add(i); } Debug.Log("adding enemy type:" + type + " " + " count: "+cnt); } public void DestroyOneEnemy(GameObject enemy) { Debug.Log("Enemy Destroyed"); aliveEnemies--; killedEnemies++; } public void StartGame() { startGame = true; } void Update() { if (startGame) { _timer -= Time.deltaTime; if (_timer < 0) { _timer += SPAWING_TIME; if (aliveEnemies < MAX_ENEMY) { if (toBeCreated.Count > 0) { // pop int type = toBeCreated[0]; toBeCreated.RemoveAt(0); GameManager.CreateEnemy(enemyPrefeb[type]); aliveEnemies++; } } } } } public int getRemainingEnemiesToKill() { return totalEnemies - killedEnemies; } } |
Commits for Nextrek/3DSpace/Assets/Custum/Scripts/EnemyPool.cs
Revision | Author | Commited | Message |
---|---|---|---|
140 Diff | LMancini | Thu 13 Nov, 2014 23:04:13 +0000 | |
139 Diff | DRuega | Mon 10 Nov, 2014 21:34:58 +0000 | I nemici ora se la prendono pure con gli alleati, non puntano solo il giocatore. |
127 Diff | DRuega | Thu 06 Nov, 2014 16:52:49 +0000 | Aggiungo PilotNameGenerator.cs Genera nomi random alle navi... così sembra più figo :) :) |
125 Diff | DRuega | Thu 06 Nov, 2014 13:44:02 +0000 | Migliorata la ricerca del nemico più vicino pesando di più la differenza angolare. |
122 Diff | DRuega | Thu 06 Nov, 2014 10:12:00 +0000 | Tocco Magico :P |
117 Diff | DRuega | Tue 28 Oct, 2014 13:39:51 +0000 | |
112 Diff | FMMortaroli | Thu 09 Oct, 2014 14:21:59 +0000 | |
107 | FMMortaroli | Thu 09 Oct, 2014 11:56:46 +0000 |