예제 #1
0
 public void AddType(MonsterTemplate t)
 {
     try
     {
         types.Add(t.GetMonsterId(), t);
     }
     catch (Exception)
     {
         Debug.LogError("type " + t.GetMonsterId() + " already exists! ( " + t.GetType().Name + ")");
     }
 }
예제 #2
0
        /// <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();
            }
        }