private void CreateBattle(DataMission mission) { //CreateTestPlayerTeam (); Model_Formation model_Formation = InstancePlayer.instance.model_User.model_Formation; if (GameOffine.START_OF_OFFLINE || !InstancePlayer.instance.model_User.isLogin) { int batteUnitCount = model_Formation.GetCurrentTeamUnitCount(); if (batteUnitCount <= 0) { model_Formation.CreateLocalData(); //创建本地测试Team1数据 } if (false) { CreateTestPvp(); } } model_Formation.CreatePlayerArmy(); InstancePlayer.instance.battle = new InstanceBattle(); InstancePlayer.instance.battle.ImportFromPlayer(); if (InstancePlayer.instance.pvpUser != null) { InstancePlayer.instance.battle.ImportFromPvp(InstancePlayer.instance.pvpUser); } else { InstancePlayer.instance.battle.ImportFromLevel(mission); } InstancePlayer.instance.battle.ImportMap(); }
private void CalcWinResult() { DataMission mission = DataManager.instance.dataMissionGroup.GetMission(_multiFightRequest.missionId); int gotExp = mission.exp; int gotHonor = mission.honor; InstancePlayer.instance.model_User.UpdateHonor(gotHonor * _multiFightRequest.num); Model_HeroGroup heroGroup = InstancePlayer.instance.model_User.model_heroGroup; Model_Formation formation = InstancePlayer.instance.model_User.model_Formation; int[] HeroesId = formation.GetSelectTeamHeroesId(); for (int i = 0; i < _multiFightRequest.num; ++i) { List <Model_HeroGroup.ExpChangeResult> result = new List <Model_HeroGroup.ExpChangeResult> (); InstancePlayer.instance.multiFightHeroGotExp.Add(result); foreach (int heroId in HeroesId) { if (heroId > 0) { Model_HeroGroup.ExpChangeResult r = heroGroup.AddExp(heroId, gotExp); result.Add(r); } } } }
public void Load(string name) { if (isLoad) { return; } isLoad = true; byte[] bin = DynamicFileControl.QueryFileContent(name); string content = StringHelper.ReadFromBytes(bin); LitJson.JSONNode json = LitJson.JSON.Parse(content); dataMissions = new Dictionary <int, DataMission> (); foreach (LitJson.JSONNode subNode in json.Childs) { DataMission data = new DataMission(); data.Load(subNode); /* * Dictionary<int, DataMission> missions; * dataMissions.TryGetValue((int)data.difficulty, out missions); * if(missions == null) * { * missions = new Dictionary<int, DataMission>(); * dataMissions.Add((int)data.difficulty, missions); * } */ dataMissions.Add(data.magicId, data); } CollectChapterData(); }
public DataMission GetMission(int magicId) { DataMission mission = null; dataMissions.TryGetValue(magicId, out mission); return(mission); }
public void ShowAttackArrow() { FreeArrow(); DataMission dataMission = _dataCampaign.missions [_selectTileIndex]; for (int i = 0; i < DataMission.ARROW_COUNT_MAX; ++i) { DataConfig.CAMPAIGN_ARROW arrow = dataMission.arrows[i]; float arrowRotation = dataMission.arrowsRotation[i]; // arrowRotation = 180; if (arrow != DataConfig.CAMPAIGN_ARROW.UNKNOWN) { string spineName = GetArrowFileName(arrow); GameObject spineArrow = ResourceHelper.Load(spineName); _skeletonAnimArrows.Add(spineArrow); Spine.Slot boundingSlot = GetBoundingSlot(_selectTileIndex); Vector3 center = SpineHelper.CalcTileArrowOffset(boundingSlot, _skeletonAnim.transform, arrowRotation); spineArrow.transform.position = center + new Vector3(0, 0, -1); spineArrow.transform.Rotate(0, 0, arrowRotation); } } }
public override void Initialize() { Application.targetFrameRate = 60; SetDontDestroy(true); base.Initialize(); masterChara = new MasterChara(); masterChara.LoadSpreadSheet(CONFIG_SPREAD_SHEET, SPREAD_SHEET_SHEET_ID_CHARA); masterItem = new MasterItem(); masterItem.LoadSpreadSheet(CONFIG_SPREAD_SHEET, SPREAD_SHEET_SHEET_ID_ITEM); masterNotice = new MasterNotice(); masterNotice.LoadSpreadSheet(CONFIG_SPREAD_SHEET, SPREAD_SHEET_SHEET_ID_NOTICE); masterEquip = new MasterEquip(); masterEquip.LoadSpreadSheet(CONFIG_SPREAD_SHEET, SPREAD_SHEET_SHEET_ID_EQUIP); masterEquipType = new MasterEquipType(); masterEquipType.LoadSpreadSheet(CONFIG_SPREAD_SHEET, SPREAD_SHEET_SHEET_ID_EQUIP_TYPE); masterMission = new MasterMission(); masterMission.LoadSpreadSheet(CONFIG_SPREAD_SHEET, SPREAD_SHEET_SHEET_ID_MISSION); masterEquipSkill = new MasterEquipSkill(); masterEquipSkill.LoadSpreadSheet(CONFIG_SPREAD_SHEET, SPREAD_SHEET_SHEET_ID_EQUIP_SKILL); masterBattleSkill = new MasterBattleSkill(); masterBattleSkill.LoadSpreadSheet(CONFIG_SPREAD_SHEET, SPREAD_SHEET_SHEET_ID_BATTLE_SKILL); dataItem = new DataItem(); dataChara = new DataChara(); dataEquip = new DataEquip(); dataMission = new DataMission(); dataEquipSkill = new DataEquipSkill(); dataBattleSkill = new DataBattleSkill(); }
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); }
public Model_Mission GetMission(int missionMagicId) { DataConfig.MISSION_DIFFICULTY difficulty = DataMission.GetDifficulty(missionMagicId); int stageId = DataMission.GetStageId(missionMagicId); int missionId = DataMission.GetMissionId(missionMagicId); return(GetMission(difficulty, stageId, missionId)); }
/* * private void CreateTestPlayerTeam() * { * //add player test data * InstancePlayer.instance.playerArmy = new InstancePlayerArmy (); * InstancePlayer.instance.playerArmy.memberCount = 6; // test player member conunt * int memberCount = InstancePlayer.instance.playerArmy.memberCount; * * InstancePlayer.instance.playerArmy.unitId = new int[memberCount]; * InstancePlayer.instance.playerArmy.unitCount = new int[memberCount]; * InstancePlayer.instance.playerArmy.heroId = new int[memberCount]; * * for (int i = 0; i < memberCount; i++) * { * InstancePlayer.instance.playerArmy.unitId [i] = (int)RandomHelper.Range(1, 7); * InstancePlayer.instance.playerArmy.unitCount [i] = 5; * InstancePlayer.instance.playerArmy.heroId [i] = 0; * } * } */ private void CreateBattleData() { DataManager.instance.InitData(); int battleId = InstancePlayer.instance.missionMagicId; // DataConfig.MISSION_DIFFICULTY battleDifficulty = InstancePlayer.instance.battleDifficulty; DataMission mission = DataManager.instance.dataMissionGroup.GetMission(battleId); CreateBattle(mission); }
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); } }
public void UpdatetileUI(int missionMagicId) { int missionId = DataMission.GetMissionId(missionMagicId); int tileIndex = missionId - 1; if (tileIndex >= 0) { mapControl.SelectTile(tileIndex); } }
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); }
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); }
private Vector3 CreateTankIcon() { if (_tankIconRoot == null) { _tankIconRoot = new GameObject("TankIconRoot"); } _tankIconRoot.transform.position = new Vector3(); Vector3 tileCenter = GetTileCenter(_selectTileIndex); float minX = int.MaxValue; float minY = int.MaxValue; float maxX = int.MinValue; float maxY = int.MinValue; DataMission mission = _dataCampaign.missions [_selectTileIndex]; InstanceBattle battle = new InstanceBattle(); battle.ImportFromLevel(mission); InstanceTeam team = battle.enemyTeams [0]; for (int i = 0; i < team.units.Length; ++i) { int unitId = team.units [i].unitId; if (unitId > 0) { DataUnit unit = DataManager.instance.dataUnitsGroup.GetUnit(unitId); // GameObject tank = ResourceHelper.Load (AppConfig.FOLDER_PROFAB_TANK + "tankIconPrimitive"); // tank.transform.parent = _tankIconRoot.transform; Vector3 pos = tileCenter; pos.x += ((i % 3) - 1) * 27 * TANK_SIZE_SCALE; pos.y += ((i / 3) - 1) * 18 * TANK_SIZE_SCALE; pos.z = -1; // tank.GetComponent<CampaignUnitIcon> ().Init (pos, unit, -60, -60); GameObject tank = TankIconSpineAttach.Create(unit, pos, TANK_SIZE_SCALE, -60, -60); tank.transform.parent = _tankIconRoot.transform; _tankIcons [i] = tank; minX = Math.Min(minX, pos.x); minY = Math.Min(minY, pos.y); maxX = Math.Max(maxX, pos.x); maxY = Math.Max(maxY, pos.y); } } Vector3 translate = FixIconPosition(minX, minY, maxX, maxY); return(translate); }
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); }
// 更新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; }
public DataMission[] GetAllMissions() { DataMission[] allMissions = new DataMission[dataMissions.Count]; int i = 0; foreach (KeyValuePair <int, DataMission> pair in dataMissions) { allMissions[i++] = pair.Value; } return(allMissions); }
/* * public Model_Mission(DataConfig.MISSION_DIFFICULTY difficulty, int stageId, int missionId) * { * magicId = (int)(difficulty + 1) * 10000 + stageId * 100 + missionId; * * this.difficulty = difficulty; * this.stageId = stageId; * this.missionId = missionId; * * InitRemainFightNum (); * } */ public Model_Mission(int magicId) { this.magicId = magicId; difficulty = DataMission.GetDifficulty(magicId); stageId = DataMission.GetStageId(magicId); missionId = DataMission.GetMissionId(magicId); InitRemainFightNum(); _referenceMission = DataManager.instance.dataMissionGroup.GetMission(magicId); Assert.assert(_referenceMission != null); }
public void ImportFromPvp(SlgPB.PVPUser pvpUser) { InitPvpDataMap(pvpUser); mission = new DataMission(); mission.asset = DataMission.BK_NAMES [(int)RandomHelper.Range(0, DataMission.BK_NAMES.Length)]; extraTeamCount = 1; enemyTeams = new InstanceTeam[extraTeamCount]; friendTeams = new InstanceTeam[extraTeamCount]; InstanceTeam instanceTeam = new InstanceTeam(); instanceTeam.units = new InstanceUnitPvp[DataConfig.FORMATION_TOTAL_SLOT]; int memberCount = pvpUser.unitGroups.Count; for (int i = 0; i < memberCount; ++i) { SlgPB.UnitGroup group = pvpUser.unitGroups [i]; int unitId = group.unitId; int unitCount = group.num; int heroId = group.heroId; float powerScale = 1; if (unitId > 0 && unitCount > 0) { SlgPB.Hero pbHero = null; if (pbHeroesMap.ContainsKey(heroId)) { pbHero = pbHeroesMap [heroId]; } SlgPB.Unit pbUnit = null; if (pbUnitsMap.ContainsKey(unitId)) { pbUnit = pbUnitsMap [unitId]; } InstanceUnitPvp instanceUnitPvp = new InstanceUnitPvp(false, heroId, unitId, unitCount, powerScale, pbHero, pbUnit); instanceUnitPvp.Init(); int slotId = group.posId - 1; instanceTeam.units[slotId] = instanceUnitPvp; } } enemyTeams [0] = instanceTeam; }
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); }
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 void ImportFromLevel(DataMission mission) { this.mission = mission; extraTeamCount = mission.teamsId.Length; enemyTeams = new InstanceTeam[extraTeamCount]; friendTeams = new InstanceTeam[extraTeamCount]; for (int teamIndex = 0; teamIndex < extraTeamCount; ++teamIndex) { int teamId = mission.teamsId[teamIndex]; if (teamId != 0) { int memberCount = mission.GetMemberCount(teamIndex); int[] unitsId = mission.GetUnitsId(teamIndex); int[] unitsCount = mission.GetUnitsCount(teamIndex); InstanceTeam instanceTeam = new InstanceTeam(); for (int i = 0; i < memberCount; ++i) { int unitId = unitsId[i]; int unitCount = unitsCount[i]; int heroId = 0; float powerScale = mission.powerScale; if (unitId > 0 && unitCount > 0) { InstanceUnit instanceUnit = new InstanceUnit(false, heroId, unitId, unitCount, powerScale); instanceTeam.units[i] = instanceUnit; instanceUnit.Init(); } } if (teamId > 0) { enemyTeams[teamIndex] = instanceTeam; } else { friendTeams[teamIndex] = instanceTeam; } } } }
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; }
void UpdatePlayerInfo() { if (InstancePlayer.instance.pvpUser == null) //pve { int missoinId = InstancePlayer.instance.missionMagicId; DataMission mission = DataManager.instance.dataMissionGroup.GetMission(missoinId); _enemyName.text = mission.name; } else //pvp { SlgPB.PVPUser pvp = InstancePlayer.instance.pvpUser; _enemyName.text = pvp.userName; _enemyLevel.text = DataManager.instance.dataLeaderGroup.GetLevel(pvp.honor).ToString(); } Model_User modelUser = InstancePlayer.instance.model_User; _playerLevel.text = modelUser.honorLevel.ToString(); _playerName.text = modelUser.userName; }
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); }
public void UpdatePageUI(int missionMagicId) { FreeMapControl(); DataConfig.MISSION_DIFFICULTY difficulty = DataMission.GetDifficulty(missionMagicId); int stageId = DataMission.GetStageId(missionMagicId); int missionId = DataMission.GetMissionId(missionMagicId); // TODO 强制战役背景资源 ID 为1 // stageId = 1; DataMissionGroup.DataCampaign campaign = DataManager.instance.dataMissionGroup.GetCampaign(difficulty, stageId); mapControl = new CampaignMapControl(campaign, missionId - 1); int tileIndex = missionId - 1; if (tileIndex >= 0) { mapControl.SelectTile(tileIndex); } }
void InintGridData() { _missonList.Clear(); if (_itemData != null) { if (_itemData.itemData.missionId1 != 0) { DataMission mission = DataManager.instance.dataMissionGroup.GetMission(_itemData.itemData.missionId1); _missonList.Add(mission); } if (_itemData.itemData.missionId2 != 0) { DataMission mission = DataManager.instance.dataMissionGroup.GetMission(_itemData.itemData.missionId2); _missonList.Add(mission); } if (_itemData.itemData.missionId3 != 0) { DataMission mission = DataManager.instance.dataMissionGroup.GetMission(_itemData.itemData.missionId3); _missonList.Add(mission); } } }
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); }
public void Init(DataMission data) { _missionData = data; }