Пример #1
0
 public static void CreateCurrentEnemy()
 {
     //Create Enemy
     for (int i = 0; i < currentMonsters.Count; i++)
     {
         //create enemy
         Enemy      e       = (Enemy)GameFuncs.GetEntity(currentMonsters[i]);
         GameObject monster = null;
         if (currentMonsters.Count > 1)
         {
             monster = Instantiate((GameObject)GameFuncs.GetResource
                                       ("Prefabs/" + currentMonsters[i]), mpoints[i]);
         }
         else
         {
             monster = Instantiate((GameObject)GameFuncs.GetResource
                                       ("Prefabs/" + currentMonsters[i]), mone);
         }
         monster.name = "m" + i;
         Enemy en = monster.AddComponent <Enemy>();
         monster.AddComponent <OnEnemy>();
         GameFuncs.CopyEntity(en, currentMonsters[i]);
         en.anim     = monster.GetComponent <Animator>();
         en.battleId = monster.name;
         BattleGlobals.liveMonsters.Add(monster.name);
         //enemys'ui
         Transform canvas = monster.transform.Find("Canvas");
         canvas.Find("name").GetComponent <Text>().text = e.ename;
         Image ele = canvas.Find("ele/Image").GetComponent <Image>();
         ele.sprite = Resources.Load <Sprite>("Icons/" + e.ele);
         Slider hpSlider = canvas.Find("hp").GetComponent <Slider>();
         hpSlider.value = (float)e.currentHp / e.infos[0];
         en.hpSlider    = hpSlider;
     }
 }