예제 #1
0
    public void setupHeroTeam()
    {
        GDEunitTeamData team
            = SDDataManager.Instance.getHeroTeamByTeamId
                  (SDGameManager.Instance.currentHeroTeamId);

        GM.initCurrentGoddess(team.goddess);
        List <GDEHeroData> all = SDDataManager.Instance.getHerosFromTeam
                                     (SDGameManager.Instance.currentHeroTeamId);

        if (all.Count <= 0)
        {
            Transform s = Instantiate(heroPrefab) as Transform;
            s.SetParent(heroParent);
            s.localScale = Vector3.one;
            s.name       = SDConstants.HERO_TAG + 0;
            //s.position = HeroPos[index++].position;
            int index = 0;
            s.position = getPosByIndex(index, false);

            BattleRoleData heroUnit = s.GetComponent <BattleRoleData>();
            heroUnit.posIndex = 1;
            //heroUnit.sidePosId = index;
            heroUnit.initHeroController(1);
            return;
        }
        for (int i = 0; i < all.Count; i++)
        {
            if (all[i] != null)
            {
                Transform s = Instantiate(heroPrefab) as Transform;
                s.SetParent(heroParent);
                s.localScale = Vector3.one;
                s.name       = SDConstants.HERO_TAG + all[i].hashCode;
                //s.position = HeroPos[index++].position;
                int index = all[i].teamPos;
                s.position = getPosByIndex(index, false);

                BattleRoleData heroUnit = s.GetComponent <BattleRoleData>();
                heroUnit.posIndex = i;
                //heroUnit.sidePosId = index;
                heroUnit.initHeroController(all[i].hashCode);
            }
        }
    }