public void AddType(MonsterTemplate t) { try { types.Add(t.GetMonsterId(), t); } catch (Exception) { Debug.LogError("type " + t.GetMonsterId() + " already exists! ( " + t.GetType().Name + ")"); } }
/// <summary> /// Spawne bosse do hry dle jmena jeho typu /// </summary> public Boss SpawnBoss(string monsterTypeName, Vector3 position, int level) { MonsterTemplate template = MonsterTemplateTable.Instance.GetType(monsterTypeName); if (template == null) { throw new NullReferenceException("cant find monstertemplate for " + monsterTypeName); } string name; if (template.GetMonsterId() == MonsterId.CustomMonster) { name = ((CustomMonsterTemplate)template).GetOldTemplateFolderId(); } else { name = template.GetMonsterId().ToString(); } GameObject go = Resources.Load("Prefabs/entity/" + name + "/" + name) as GameObject; if (go == null) { throw new NullReferenceException("Prefabs/entity/" + name + "/" + name); } GameObject result = Object.Instantiate(go, position, Quaternion.identity) as GameObject; EnemyData data = result.GetComponent <EnemyData>(); //Monster m = RegisterNewMonster(data, id, false, level); Monster m = RegisterNewCustomMonster(data, template, false, level); if (m is Boss) { return((Boss)m); } else { Debug.LogError("tried to spawn boss - but it was a monster ! fix it in data"); throw new NullReferenceException(); } }