예제 #1
0
    /// <summary>
    /// 创建新的怪物 若当前 nowMonsterIndex 索引以大于总数量,则游戏结束
    /// </summary>
    public void CreateNewMonster(bool _roundRun = false)
    {
        if (this.monsterPrefab == null)
        {
            return;
        }


        MonsterData monsterData = null;

        //MonsterActor monster = null;
        while (monsterData == null)
        {
            this.nowMonsterIndex++;
            if (this.nowMonsterIndex > LevelData.monsterList.Count)
            {
                this.GameOver();
                return;
            }

            //monsterData = LevelData.CreateMonsterActor(this.nowMonsterIndex);
            monsterData = LevelData.FindMonsterDataByIndex(this.nowMonsterIndex);
        }


        GameObject monsterObject = Instantiate(this.monsterPrefab);

        MonsterActor actor = monsterObject.GetComponent <MonsterActor>();

        actor.roundRun = _roundRun;
        monsterData.SettingData(actor);

        this.monsterActor = actor;

        Debug.Log("[New Monster]" + actor.monsterName);

        // 创建怪物预制体并添加 MonsterActor
        // todo...
    }