Пример #1
0
    void Start()
    {
        m_curLevelIndex = DataManager.instance.level;

        // Init Walkers
        var walkerDatas = DataManager.instance.walkerDatas;

        for (int i = 0; i < walkerDatas.Count; ++i)
        {
            var walkerObj  = Instantiate(GameManager.instance.walkerPrefab);
            var walkerCtrl = walkerObj.GetComponent <Walker> ();
            walkerCtrl.Init(walkerDatas [i]);
            walkerObj.transform.position = GetSpwanPoint("Walker" + i.ToString());

            m_justiceTeam.AddActor(walkerCtrl);
        }

        // Init Xian
        int xianIndex = 0;
        var xianDatas = DataManager.instance.xianDatas;

        for (int i = 0; i < xianDatas.Count; ++i)
        {
            var xianData = xianDatas [i];
            if (xianData.isKaiGuang)
            {
                var objXian = Instantiate(GameManager.instance.xianPrefab);
                var xian    = objXian.GetComponent <Xian> ();
                xian.Init(xianData);
                xian.transform.position = GetSpwanPoint("Xian" + xianIndex.ToString());
                xianIndex += 1;
            }
        }

        // Init Monsters
        var level       = DataManager.instance.level;
        var levelConfig = GameManager.instance.levelConfigs [level];

        for (int i = 0; i < levelConfig.monsters.Length; ++i)
        {
            var mcfg = levelConfig.monsters [i];

            var monsterObj  = Instantiate(GameManager.instance.monsterPrefab);
            var monsterCtrl = monsterObj.GetComponent <Monster> ();
            monsterCtrl.Init(mcfg.id, mcfg.lv);
            monsterCtrl.transform.position = GetSpwanPoint("Monster" + i.ToString());

            m_evilTeam.AddActor(monsterCtrl);
        }

        m_justiceTeam.oppTeam = m_evilTeam;
        m_justiceTeam.onTeamStartBattleEnd = OnTeamStartBattleEnd;
        m_justiceTeam.onTeamAttackTurnEnd  = OnTeamAttackTurnEnd;

        m_evilTeam.oppTeam = m_justiceTeam;
        m_evilTeam.onTeamStartBattleEnd = OnTeamStartBattleEnd;
        m_evilTeam.onTeamAttackTurnEnd  = OnTeamAttackTurnEnd;

        state = State.Start;
    }