Exemplo n.º 1
0
    protected virtual void OnBattleWin()
    {
        MainWindow mainWindow = FindObjectOfType <MainWindow>();

        if (mainWindow != null)
        {
            mainWindow.gameObject.SetActive(false);
        }

        GameObject       victoryPanel = (GameObject)Instantiate(Resources.Load("Prefabs/BattleResult/VictoryPanel"), GameObject.Find("MainCanvas").transform);
        BattleVictory    bv           = victoryPanel.GetComponent <BattleVictory>();
        BattleResultData resultData   = null;

        if (_map.IsWallMap)
        {
            WaveTplData waveTpl = TemplateManager.GetWaveTpl(_wave.TplId);
            resultData     = DropManager.CreateBattleResult(waveTpl.Dropid);
            resultData.Exp = waveTpl.Exp;
        }
        else
        {
            resultData     = DropManager.CreateBattleResult(_map.Tpl.Dropid, _map.Tpl);
            resultData.Exp = _map.Tpl.Exp;
        }
        resultData.Exp = (int)(resultData.Exp * (1 + Random.Range(-0.1f, 0.1f)));
        _hero.ObtainPastExp(resultData.Exp);

        resultData.BattleType = BattleType;
        bv.data = resultData;

        if (BattleType == BATTLE_TYPE_TREEHOLE)
        {
            TreeHoleCtrl.Instance.Win();
        }
        else if (BattleType == BATTLE_TYPE_CHAPTER)
        {
            WorldCtrl.Instance.Win();
        }

        _beAttacking = false;

        GameModel.Instance.WinTime++;

#if !DISABLESTEAMWORKS
        SteamAchievementMgr.Instance.AchievementAboutNumChanged();
        SteamAchievementMgr.Instance.WinABattle();
        if (BattleType == BATTLE_TYPE_TREEHOLE)
        {
            if (TreeHoleCtrl.Instance.CurrentLayerNum == 30)
            {
                SteamAchievementMgr.Instance.PastLastHole();
            }
        }
#endif

        GlobalEventLocator.Instance.dispatch(new GameEvent(GameEvent.BATTLE_STATE_CHANGED));
        _hero.ClearBuffs();
        UserSkillMgr.CancelSkill();

        if (BattleType == BATTLE_TYPE_GUARD)
        {
            GameModel.Instance.Wave++;
            SoundManager.InstanceOfScene.PlayPeaceBmg();
        }


        GameModel.Instance.OpenFunc(GameModel.FUNC_ID_BAG);
        if (!GameModel.Instance.IsFuncOpen(GameModel.FUNC_ID_INLAY))
        {
            foreach (var item in bv.data.Items)
            {
                if (item.Type == GoodsInfo.TYPE_GEM)
                {
                    GameModel.Instance.OpenFunc(GameModel.FUNC_ID_INLAY);
                }
            }
            if (!GameModel.Instance.IsFuncOpen(GameModel.FUNC_ID_INLAY) && GameModel.Instance.HeroInfo.Level >= SystemConsts.OPEN_INLAY_LEVEL)
            {
                GameModel.Instance.OpenFunc(GameModel.FUNC_ID_INLAY);
            }
        }

        DataService.Instance.Safe = true;

        AdManager.Instance.ShowInterstitial();
    }