public void SetType(EnemyParser.EnemyType type) { this.type = type; EnemyParser.EnemyInfo info = EnemyParser.GetEnemyInfo(type); weapon.SetDamage(info.damage); health.SetMax(info.health); reloadTime = info.reloadTime / 1000; Material pickedMaterial = null; foreach (var material in materials) { if (material.type != type) { continue; } pickedMaterial = material.material; break; } if (pickedMaterial != null) { meshRenderer.material = pickedMaterial; } }
void Awake() { parser = this; var diffIno = FindObjectOfType <DifficultyInfo>(); if (diffIno != null) { difficulty = FindObjectOfType <DifficultyInfo>().diff; Destroy(diffIno.gameObject); } EnemyTemplates = new Dictionary <EnemyType, EnemyInfo>(); string info; string path = Application.streamingAssetsPath + "/enemies.txt"; StreamReader streamReader = new StreamReader(path); info = streamReader.ReadToEnd(); foreach (EnemyType type in System.Enum.GetValues(typeof(EnemyType))) { EnemyInfo nextEnemy = new EnemyInfo { type = type, health = GetInfo(type, "Health", info), damage = GetInfo(type, "Dmg", info), reloadTime = GetInfo(type, "Reload", info), scoreGiven = GetInfo(type, "Score", info) }; if (nextEnemy.health == -1) { nextEnemy.health = 1; } if (nextEnemy.damage == -1) { nextEnemy.damage = 1; } if (nextEnemy.reloadTime == -1) { nextEnemy.reloadTime = 1; } if (nextEnemy.scoreGiven == -1) { nextEnemy.scoreGiven = 1; } EnemyTemplates.Add(type, nextEnemy); } }
public XMLParser(RoomHandler roomHand, Game1 gm) { roomHandler = roomHand; itemParser = new ItemParser(gm); enemyParser = new EnemyParser(gm); trapParser = new TrapsParser(gm); npcParser = new NPCParser(gm); blockParser = new BlockParser(gm); doorParser = new DoorParser(gm, roomHandler); conditionParser = new ConditionParser(); spawnerParser = new SpawnerParser(gm); }
private void KillEnemy(object sender, Health.HealthEventArgs e) { Health health = sender as Health; currentWave.Remove(health.transform.root.gameObject); health.OnDepletion -= KillEnemy; var controller = health.GetComponent <EnemyController>(); player.AddPoints(EnemyParser.GetEnemyInfo(controller.type).scoreGiven); if (currentWave.Count == 0) { ++currentMap; PrepareWave(); } }