Example #1
0
    public void UpdateUI(Model_Mission model_Mission)
    {
        if (model_Mission != null)
        {
            this.model_Mission = model_Mission;

            mission_Sprite.spriteName = UICommon.MISSION_ICON_PATH + model_Mission.magicId;
            DataMission dataMission = DataManager.instance.dataMissionGroup.GetMission(model_Mission.magicId);
            name_Label.text = dataMission.name;
        }

        // 更新当前选中
        if (isSelected)
        {
            UpdateFrame(true);
            missionDetialUI.UpdateUI(model_Mission);

            InstancePlayer.instance.uiDataStatus.UpdateSelectedMission(model_Mission.magicId);
        }

        // 更新是否解锁
        UpdateUnlock(isUnlock);
        UpdateBoss(isBoss);

        // 更新星级
        UpdateStar(model_Mission.starCount);
    }
Example #2
0
    private void ParseMissions(List <SlgPB.Mission> missions, out SlgPB.Mission lastNormalMission, out SlgPB.Mission lastEliteMission)
    {
        lastNormalMission = null;
        lastEliteMission  = null;

        foreach (SlgPB.Mission mission in missions)
        {
            Model_Mission modelMission = new Model_Mission(mission.missonId);
            modelMission.Parse(mission);

//			modelMission.referenceMission = DataManager.instance.dataMissionGroup.GetMission(modelMission.missionId);
//			Assert.assert(modelMission.referenceMission != null);

            ReplaceMission(modelMission);

            if (modelMission.starCount > 0)
            {
                if (modelMission.difficulty == DataConfig.MISSION_DIFFICULTY.NORMAL)
                {
                    lastNormalMission = mission;
                }
                else if (modelMission.difficulty == DataConfig.MISSION_DIFFICULTY.ELITE)
                {
                    lastEliteMission = mission;
                }
            }
        }
    }
Example #3
0
    public Model_Mission GetLastUnlockMission(DataConfig.MISSION_DIFFICULTY difficult, int minStarCount = 0)
    {
        Chapters chapters = null;

        if (difficult == DataConfig.MISSION_DIFFICULTY.NORMAL)
        {
            chapters = _chaptersNormal;
        }
        else
        {
            chapters = _chaptersElite;
        }

        Model_Mission findMission = null;

        foreach (Campaign campaign in chapters.list)
        {
            foreach (Model_Mission mission in campaign.list)
            {
                if (mission.actived && mission.starCount >= minStarCount)
                {
                    findMission = mission;
                }
            }
        }

        return(findMission);
    }
Example #4
0
    /*
     * public int TryUnlockFirstMission()
     * {
     *      DataConfig.MISSION_DIFFICULTY difficulty = DataConfig.MISSION_DIFFICULTY.NORMAL;
     *      int stageId = 1;
     *      int missionId = 1;
     *
     *      Campaign campaign = GetCampaign (difficulty, stageId);
     *      Model_Mission mission = campaign.list [missionId];
     *      mission.actived = true;
     *      return mission.magicId;
     * }
     */

    public void SetStar(int missionMagicId, int star)
    {
        Model_Mission mission = new Model_Mission(missionMagicId);

        mission = GetMission(mission.difficulty, mission.stageId, mission.missionId);
        mission.SetStar(star);
    }
Example #5
0
    private void InitChaptersNormal()
    {
        _chaptersNormal = new Chapters();

        DataConfig.MISSION_DIFFICULTY difficulty = DataConfig.MISSION_DIFFICULTY.NORMAL;

        DataMissionGroup missionGroup = DataManager.instance.dataMissionGroup;

        List <DataMissionGroup.DataCampaign> dataCampaigns = missionGroup.GetCampaigns(difficulty);

        foreach (DataMissionGroup.DataCampaign dataCampaign in dataCampaigns)
        {
            Campaign campaign = new Campaign(dataCampaign.stageId);
            _chaptersNormal.list.Add(campaign);

            foreach (DataMission dataMission in dataCampaign.missions)
            {
                Model_Mission modelMission = new Model_Mission(dataMission.magicId);
//				modelMission.type = difficulty;
//				modelMission.stageId = stageId;
//				modelMission.missionId = m.missionId;
//				modelMission.starMask = 0;
//				modelMission.remainFightNum = DEFAULT_FIGHT_NUM;

//				modelMission.referenceMission = DataManager.instance.dataMissionGroup.GetMission(m.magicId);
//				Assert.assert(modelMission.referenceMission != null);

                campaign.list.Add(modelMission);
            }
        }
    }
Example #6
0
    private bool CheckCommand_PassMission(DataGuide dataGuide)
    {
        int missionId = (int)dataGuide.A;

        Model_Mission mission = InstancePlayer.instance.model_User.model_level.GetMission(missionId);

        return(mission.starCount > 0);
    }
Example #7
0
    public bool IsNextNormalCampaignUnlock(int nextStageId)
    {
        Campaign      campaign      = GetCampaign(DataConfig.MISSION_DIFFICULTY.NORMAL, nextStageId);
        Model_Mission first_Mission = campaign.list [0];
        bool          isUnlcok      = first_Mission.actived;

        return(isUnlcok);
    }
Example #8
0
    public bool IsNextEliteCampaignUnlock(int nextStageId)
    {
        Campaign      campaign     = GetCampaign(DataConfig.MISSION_DIFFICULTY.NORMAL, nextStageId);
        Model_Mission last_Mission = campaign.list [campaign.list.Count - 1];
        bool          isUnlcok     = last_Mission.actived;

        return(isUnlcok);
    }
Example #9
0
    public override void Send(StartFightRequest content, DelegateConnectCallback callback)
    {
        base.Send(content, callback);

        Model_Mission mission = InstancePlayer.instance.model_User.model_level.GetMission(content.missionId);

        Assert.assert(mission.actived);

        _request = content;
    }
Example #10
0
    public void TryUnlockNextMission(int battleMissionId)
    {
        /*
         * if (battleMissionId == 0) {
         *      return TryUnlockFirstMission ();
         * }
         */



        DataConfig.MISSION_DIFFICULTY difficulty = DataMission.GetDifficulty(battleMissionId);

        Model_Mission lastUnlockMission = GetLastUnlockMission(difficulty, 1);
        int           stageId           = lastUnlockMission.stageId;
        int           missionId         = lastUnlockMission.missionId;

        Campaign campaign = GetCampaign(difficulty, stageId);

        if (campaign.list.Count == missionId)
        {
            //it is last mission in campaign

            Chapters chapters = GetChapters(difficulty);
            if (stageId < chapters.list.Count)
            {
                if (difficulty == DataConfig.MISSION_DIFFICULTY.NORMAL)
                {
                    Campaign      nextCampaign = GetCampaign(difficulty, stageId + 1);
                    Model_Mission nextMission  = nextCampaign.list [0];
                    if (CheckMissionUnlock(nextMission))
                    {
                        nextMission.actived = true;
                    }
                }


//				return nextMission.referenceMission.magicId;
            }
        }
        else
        {
            int           nextMissionIndex = missionId;
            Model_Mission nextMission      = campaign.list[nextMissionIndex];
            if (CheckMissionUnlock(nextMission))
            {
                nextMission.actived = true;
            }
//			return nextMission.magicId;
        }

        if (difficulty == DataConfig.MISSION_DIFFICULTY.NORMAL)
        {
            TryUnlockEliteFirstMission(battleMissionId);
        }
    }
Example #11
0
    public int GetLastUnlockMissionMagicId(DataConfig.MISSION_DIFFICULTY difficult)
    {
        Model_Mission mission = GetLastUnlockMission(difficult);

        if (mission != null)
        {
            return(mission.magicId);
        }

        return(0);
    }
Example #12
0
    public bool CheckMissionUnlock(Model_Mission modelMission)
    {
        DataMission dataMission = DataManager.instance.dataMissionGroup.GetMission(modelMission.magicId);
        int         totalStar   = GetAllMissionsStar(modelMission.difficulty);

        if (totalStar < dataMission.Star)
        {
            return(false);
        }

        return(true);
    }
Example #13
0
    public bool IsMissionUnlock(int magicId)
    {
        int stageId = DataMission.GetStageId(magicId);

        DataConfig.MISSION_DIFFICULTY difficulty = DataMission.GetDifficulty(magicId);
        int missionId = DataMission.GetMissionId(magicId);

        Model_Mission model_Mission = GetMission(difficulty, stageId, missionId);
        bool          isUnlcok      = model_Mission.actived;

        return(isUnlcok);
    }
    override protected void DisposeContent(MultiFightResponse content)
    {
        InstancePlayer.instance.multiFightPrizeItems = content.prizeItems;

        InstancePlayer.instance.model_User.UpdateUserBasic(content.response.user);

        Model_Mission modelMission = InstancePlayer.instance.model_User.model_level.GetMission(_multiFightRequest.missionId);

        modelMission.remainFightNum -= _multiFightRequest.num;

        CalcWinResult();
    }
Example #15
0
    public void UpdateUI(Model_Mission model_Mission)
    {
        _model_Mission = model_Mission;

        int         magicId     = model_Mission.magicId;
        DataMission dataMission = DataManager.instance.dataMissionGroup.GetMission(magicId);
        int         power       = InstancePlayer.instance.model_User.model_Formation.CalcPower();

        if (dataMission != null)
        {
            Mission_Name_Label.text = dataMission.name;

            int fightNum = 0;
            if (model_Mission.difficulty == DataConfig.MISSION_DIFFICULTY.NORMAL)
            {
                fightNum = Model_Mission.FIGHT_NUM_NORMAL;
            }
            else
            {
                fightNum = Model_Mission.FIGHT_NUM_ELITE;
            }

            total_fight_num = fightNum;

            left_fight_num = model_Mission.remainFightNum;

            Left_Count.text = model_Mission.remainFightNum + "/" + fightNum;

            Recommend_Power.text = dataMission.evaluate + "";
            Need_Energy.text     = dataMission.EnergyCost + "";
            Current_Power.text   = power + "";

            Honor_Label.text = dataMission.honor + "";
            Exp_Label.text   = dataMission.exp + "";

            // 更新可掉落Item
            UpdateItem(dataMission.itemsId);
        }


        int stageId = DataMission.GetStageId(magicId);

        DataConfig.MISSION_DIFFICULTY difficulty = DataMission.GetDifficulty(magicId);
        int allStarCount = InstancePlayer.instance.model_User.model_level.GetAllMissionsStar(difficulty, stageId);

        Star_Label.text   = allStarCount + "";
        Energy_Label.text = power + "";


        // 更新星级
        UpdateStar(_model_Mission.starCount);
    }
Example #16
0
    //  更新Mission列表
    public void UpdateMissionList()
    {
        List <Model_Mission> model_missions;

        Model_User model_User = InstancePlayer.instance.model_User;

        Model_Level model_level = InstancePlayer.instance.model_User.model_level;

        DataConfig.MISSION_DIFFICULTY difficulty = DataMission.GetDifficulty(_missionMagicId);
        int stageId = DataMission.GetStageId(_missionMagicId);

        Model_Level.Campaign campaign = model_level.GetCampaign(difficulty, stageId);
        model_missions = campaign.list;

        int n = model_missions.Count;
        int currentSelectId = 0;

        GameObject cell_prefab = Resources.Load(MISSION_CELL_PATH) as GameObject;

        for (int i = 0; i < n; ++i)
        {
            GameObject cell = NGUITools.AddChild(grid_Mission.gameObject, cell_prefab);
            grid_Mission.AddChild(cell.transform);
            cell.name = UIHelper.GetItemSuffix(i);

            Model_Mission model_Mission = model_missions [i];

            MissionCellUI cellUI = cell.GetComponent <MissionCellUI> ();
            cellUI.missionDetialUI = missionDetialUI;
            cellUI.missionPanel    = this;

            cellUI.isUnlock = model_Mission.actived;

            //  当前关卡选中项
            if (_missionMagicId == model_Mission.magicId)
            {
                cellUI.isSelected = true;
            }

            // Boss
            if (i == n - 1)
            {
                cellUI.isBoss = true;
            }

            cellUI.UpdateUI(model_Mission);
            mission_cell_list.Add(cellUI);
        }

        grid_Mission.animateSmoothly = false;
        grid_Mission.repositionNow   = true;
    }
Example #17
0
    override protected void DisposeContent(StartFightResponse content)
    {
        InstancePlayer.instance.currentFightId = content.fightId;

        InstancePlayer.instance.model_User.UpdateUserBasic(content.response.user);

        Model_Mission modelMission = InstancePlayer.instance.model_User.model_level.GetMission(_request.missionId);

        modelMission.remainFightNum--;

        DataMission dataMission = DataManager.instance.dataMissionGroup.GetMission(_request.missionId);

        InstancePlayer.instance.model_User.model_Energy.SubEnergy(dataMission.EnergyCost);
    }
Example #18
0
    public void EndFight()
    {
        // 同步战斗中损失到阵型
        InstancePlayer.instance.model_User.model_Formation.SyncBattleDamageUnit();

        bool isOffline = IsStartOfOffline();

        if (isOffline)
        {
            SceneHelper.SwitchScene(AppConfig.SCENE_NAME_BATTLE_OFFLINE);
        }
        else
        {
            _isBattleWin = InstancePlayer.instance.battle.IsPlayerWin();

            Model_Mission modelMission   = InstancePlayer.instance.model_User.model_level.GetMission(InstancePlayer.instance.battle.mission.magicId);
            int           battleStarMask = InstancePlayer.instance.battleEvaluation.starMask;  // _isBattleWin ? 7 : 0;
            battleStarMask |= modelMission.starMask;

            List <SlgPB.UnitGroup> deadUnits = PBConnect_finishBattle.GetPlayerDeadUnits();
            int fightId = InstancePlayer.instance.currentFightId;

            PBConnect_finishBattle.FinishBattle(fightId, deadUnits, _isBattleWin, battleStarMask, OnEndFight);


            /*
             * FinishBattleRequest request = new FinishBattleRequest ();
             * request.api = new Model_ApiRequest ().api;
             *
             * request.fightId = InstancePlayer.instance.currentFightId;
             * ListHelper.Push (request.unitGroup, PBConnect_finishBattle.GetPlayerDeadUnits ());
             *
             * if(InstancePlayer.instance.battle.IsPlayerWin ())
             * {
             *      request.fightResult = (int)PBConnect_finishBattle.FIGHT_RESULT.WIN;
             *      request.star = 7;
             *      _isBattleWin = true;
             * }
             * else
             * {
             *      request.fightResult = (int)PBConnect_finishBattle.FIGHT_RESULT.LOSS;
             *      request.star = 0;
             *      _isBattleWin = false;
             * }
             *
             * (new PBConnect_finishBattle ()).Send (request, OnEndFight);
             */
        }
    }
Example #19
0
    public void ReplaceMission(Model_Mission modelMission)
    {
        Campaign campaign = GetCampaign(modelMission.difficulty, modelMission.stageId);

        for (int i = 0; i < campaign.list.Count; ++i)
        {
            if (campaign.list[i].missionId == modelMission.missionId)
            {
                campaign.list[i] = modelMission;
                return;
            }
        }

        Assert.assert(false);
    }
Example #20
0
    public void TryUnlockEliteFirstMission(int battleMissionId)
    {
        Assert.assert(DataMission.GetDifficulty(battleMissionId) == DataConfig.MISSION_DIFFICULTY.NORMAL);

        DataConfig.MISSION_DIFFICULTY difficulty = DataConfig.MISSION_DIFFICULTY.ELITE;
        int stageId   = DataMission.GetStageId(battleMissionId);
        int missionId = DataMission.GetMissionId(battleMissionId);

        Campaign campaign = GetCampaign(difficulty, stageId);

        if (campaign.list.Count == missionId)
        {
            Model_Mission mission = GetMission(difficulty, stageId, 1);
            mission.actived = true;
        }
    }
    public override void Send(MultiFightRequest content, DelegateConnectCallback callback)
    {
        base.Send(content, callback);

        InstancePlayer.instance.multiFightPrizeItems.Clear();

        Model_Mission mission = InstancePlayer.instance.model_User.model_level.GetMission(content.missionId);

        Assert.assert(mission.actived);

        DataMission dataMission = DataManager.instance.dataMissionGroup.GetMission(content.missionId);

        InstancePlayer.instance.model_User.model_Energy.SubEnergy(dataMission.EnergyCost * content.num);

        InstancePlayer.instance.multiFightHeroGotExp.Clear();

        _multiFightRequest = content;
    }
Example #22
0
    public override void Open(params object[] parameters)
    {
        base.Open(parameters);
        if (parameters != null)
        {
            magicId     = (int)parameters [0];
            clear_count = (int)parameters [1];
        }

        Model_Mission model_Mission = InstancePlayer.instance.model_User.model_level.GetMission(magicId);

        left_label.text  = model_Mission.remainFightNum + "";
        clear_label.text = string.Format(CLEAR_TEXT, clear_count);


        ui_scrollview.enabled = false;

        StartCoroutine(CreateContentAll());
    }
Example #23
0
    public static RESULT CheckStartFight(int missionMagicId)
    {
        DataMission dataMission = DataManager.instance.dataMissionGroup.GetMission(missionMagicId);

        int totalEnergyCost = dataMission.EnergyCost * 1;

        if (InstancePlayer.instance.model_User.model_Energy.energy < totalEnergyCost)
        {
            return(RESULT.LACK_ENERGY);
        }

        Model_Mission modelMission = InstancePlayer.instance.model_User.model_level.GetMission(missionMagicId);

        if (modelMission.remainFightNum < 1)
        {
            return(RESULT.LACK_TIMES);
        }

        return(RESULT.OK);
    }
    private bool IsTileActive(string tileName)
    {
        int index = GetTileIndex(tileName);

        if (_campaign == null)
        {
            return(index == 0);
        }
        else
        {
            if (index >= _campaign.list.Count)
            {
                return(false);
            }
            else
            {
                Model_Mission mission = _campaign.list[index];
                return(mission.actived);
            }
        }
    }
Example #25
0
    private void InitChaptersElite()
    {
        _chaptersElite = new Chapters();

        DataConfig.MISSION_DIFFICULTY difficulty = DataConfig.MISSION_DIFFICULTY.ELITE;

        DataMissionGroup missionGroup = DataManager.instance.dataMissionGroup;

        List <DataMissionGroup.DataCampaign> dataCampaigns = missionGroup.GetCampaigns(difficulty);

        foreach (DataMissionGroup.DataCampaign dataCampaign in dataCampaigns)
        {
            Campaign campaign = new Campaign(dataCampaign.stageId);
            _chaptersElite.list.Add(campaign);

            foreach (DataMission dataMission in dataCampaign.missions)
            {
                Model_Mission modelMission = new Model_Mission(dataMission.magicId);
                campaign.list.Add(modelMission);
            }
        }
    }
    public void ShowStar(Vector3 translate)
    {
        FreeStar();


        DataMission   dataMission  = _dataCampaign.missions [_selectTileIndex];
        Model_Mission modelMission = InstancePlayer.instance.model_User.model_level.GetMission(dataMission.magicId);

        string animName = "no_star";

        if (modelMission.starCount == 1)
        {
            animName = "01";
        }
        if (modelMission.starCount == 2)
        {
            animName = "02";
        }
        if (modelMission.starCount == 3)
        {
            animName = "03";
        }


        Vector3 tileCenter = GetTileCenter(_selectTileIndex);

        tileCenter.y += 70;
        tileCenter.z  = -1;
        tileCenter   += translate;

        string spineName = AppConfig.FOLDER_PROFAB_CAMPAIGN + "Star";

        _skeletonStar = ResourceHelper.Load(spineName);
        _skeletonStar.transform.position = tileCenter;

        SkeletonAnimation anim = _skeletonStar.GetComponentInChildren <SkeletonAnimation> ();

        anim.state.SetAnimation(0, animName, false);
    }
    public static RESULT CheckMultyFight(int missionMagicId, int times)
    {
        Model_Mission modelMission = InstancePlayer.instance.model_User.model_level.GetMission(missionMagicId);
        DataMission   dataMission  = DataManager.instance.dataMissionGroup.GetMission(missionMagicId);

        if (modelMission.remainFightNum < times)
        {
            return(RESULT.LACK_TIMES);
        }

        if (modelMission.starCount < 3)
        {
            return(RESULT.LACK_STAR);
        }

        int totalEnergyCost = dataMission.EnergyCost * times;

        if (InstancePlayer.instance.model_User.model_Energy.energy < totalEnergyCost)
        {
            return(RESULT.LACK_ENERGY);
        }

        return(RESULT.OK);
    }