Exemplo n.º 1
0
 protected override void OnStart()
 {
     mo = SceneMoba3.instance;
     if (mo == null)
     {
         return;
     }
     aiLv      = mo.aiLv;
     myCamp    = thisCs.groupIndex == 1 ? mo.CampBlue : mo.CampRed;
     enemyCamp = thisCs.groupIndex == 1 ? mo.CampRed : mo.CampBlue;
     myHome    = thisCs.groupIndex == 1 ? mo.HomeBlue : mo.HomeRed;
     InitTowers();
     myHomeRadius = myHome.GetComponent <SphereCollider>().radius;
     aiSkillHandler.SetSkills(thisCs.GetSkills());
     OnPlayerAction += this.PlayerAction;
 }
Exemplo n.º 2
0
    public override void InitScene()
    {
        instance           = this;
        GameLibrary.isMoba = true;
        sceneType          = SceneType.MB3;
        Debug.Log("SceneUIManager.instance");
        if (SceneUIManager.instance != null)
        {
            Debug.Log("SceneUIManager.instance.heroRebornThumb");
            rebornThumbs = SceneUIManager.instance.heroRebornThumb.GetComponentsInChildren <HeroRebornThumb>();
        }

        int           level    = playerData.GetInstance().selfData.level;
        MobaRobotNode robotCfg = FSDataNodeTable <MobaRobotNode> .GetSingleton().DataNodeList[level];

        if (robotCfg != null)
        {
            List <long> randIds = null;
            if (!GameLibrary.isNetworkVersion)
            {
                long mainId = BattleUtil.GetRandomTeam(1)[0];
                randIds = BattleUtil.GetRandomTeam(8, new List <long>()
                {
                    mainId
                });
                HeroData myLocalData = new HeroData(mainId);
                myLocalData.AddFakeEquips(robotCfg.equipment_lv, robotCfg.equipment_grade);
                Globe.moba3v3MyTeam1 = new HeroData[] { myLocalData, new HeroData(randIds[5]), new HeroData(randIds[6]), new HeroData(randIds[7]) };
            }
            else
            {
                randIds = BattleUtil.GetRandomTeam(5, new List <long>()
                {
                    Globe.moba3v3MyTeam1[0].id
                });
            }

            HeroData myTeammate2 = new HeroData(randIds[0], robotCfg.hero_lv, robotCfg.hero_grade, robotCfg.hero_star);
            myTeammate2.AddFakeEquips(robotCfg.equipment_lv, robotCfg.equipment_grade);
            Globe.moba3v3MyTeam2 = new HeroData[] { myTeammate2, null, null, null };
            HeroData myTeammate3 = new HeroData(randIds[1], robotCfg.hero_lv, robotCfg.hero_grade, robotCfg.hero_star);
            myTeammate3.AddFakeEquips(robotCfg.equipment_lv, robotCfg.equipment_grade);
            Globe.moba3v3MyTeam3 = new HeroData[] { myTeammate3, null, null, null };
            HeroData enemyTeamm1 = new HeroData(randIds[2], robotCfg.hero_lv, robotCfg.hero_grade, robotCfg.hero_star);
            enemyTeamm1.AddFakeEquips(robotCfg.equipment_lv, robotCfg.equipment_grade);
            Globe.moba3v3EnemyTeam1 = new HeroData[] { enemyTeamm1, null, null, null };
            HeroData enemyTeamm2 = new HeroData(randIds[3], robotCfg.hero_lv, robotCfg.hero_grade, robotCfg.hero_star);
            enemyTeamm2.AddFakeEquips(robotCfg.equipment_lv, robotCfg.equipment_grade);
            Globe.moba3v3EnemyTeam2 = new HeroData[] { enemyTeamm2, null, null, null };
            HeroData enemyTeamm3 = new HeroData(randIds[4], robotCfg.hero_lv, robotCfg.hero_grade, robotCfg.hero_star);
            enemyTeamm3.AddFakeEquips(robotCfg.equipment_lv, robotCfg.equipment_grade);
            Globe.moba3v3EnemyTeam3 = new HeroData[] { enemyTeamm3, null, null, null };
        }

        Moba3SceneConfigNode node = null;

        #region Scene build
        var naviCfg = FSDataNodeTable <Moba3v3NaviNode> .GetSingleton().DataNodeList;

        if (naviCfg != null)
        {
            for (int i = 0; i < blueLeft.Length; i++)
            {
                blueLeft[i].transform.position  = GetNaviById(i + 1, naviCfg, 1);
                blueRight[i].transform.position = GetNaviById(i + 1, naviCfg, 2);
                redLeft[i].transform.position   = GetNaviById(i + 1, naviCfg, 3);
                RedRight[i].transform.position  = GetNaviById(i + 1, naviCfg, 4);
            }
        }
        cfg = FSDataNodeTable <Moba3SceneConfigNode> .GetSingleton().DataNodeList;

        if (cfg != null)
        {
            foreach (var id in cfg.Keys)
            {
                node = cfg[id];
                switch (node.type)
                {
                case 0:
                    block = node;
                    break;

                case 1:
                    heroCfg.Add(node);
                    break;

                case 2:
                    monsterCfg.Add(node);
                    break;

                case 3:
                    towersCfg.Add(node);
                    break;

                case 4:
                    campCfg.Add(node);
                    break;

                case 5:
                    homeCfg.Add(node);
                    break;

                case 6:
                    wildMonsterCfg.Add(node);
                    break;

                case 7:
                    wildMonsterCfgRed.Add(node);
                    break;

                case 8:
                    wildBossCfg.Add(node);
                    break;

                default:
                    break;
                }
            }
        }

        BuildScene();
        #endregion
        InitHeroData(sceneType);
        CreatAllHeros(sceneType);
        InitHpAndAttackRatio();
        RefreshInfo();

        InitAllTowers();
        SetPriority();
        CampRed.OnDead  += (CharacterState cs) => ShowResult(true);
        CampBlue.OnDead += (CharacterState cs) => ShowResult(false);

        SpawnMonsters = GetComponentsInChildren <SpawnMonster>();
        for (int i = 0; i < SpawnMonsters.Length; i++)
        {
            SpawnMonsters[i].OnCreatMonster += OnMonsterCreated;
        }

        List <CharacterState> allHeros = new List <CharacterState>();
        allHeros.AddRange(herosBlue);
        allHeros.AddRange(herosRed);
        allHeros.ForEach((CharacterState c) => AddHeroAIs(c));
        InitHeroRebornThumbs(allHeros);
        ReloadAllHeroSounds(allHeros);
        CDTimer.GetInstance().AddCD(5, (int count, long id) => Block.SetActive(false));
        CDTimer.GetInstance().AddCD(30, (int count, long id) => RebornCD++, 10);
        CampRed.priority = MobaAIPlayerPriority.CampLow;

        if (FightTouch._instance != null)
        {
            FightTouch._instance.TpPosition = HomeBlue.transform.position;
            FightTouch._instance.tpEffect1  = Resource.CreatPrefabs("HuiCheng_01", gameObject, Vector3.one, "Effect/Prefabs/Item/");
            FightTouch._instance.tpEffect2  = Resource.CreatPrefabs("HuiCheng_02", gameObject, Vector3.one, "Effect/Prefabs/Item/");
        }
        Debug.Log("base.InitScene");
        base.InitScene();
    }