public List <TIVInfo> GetConditions() { if (condition == null || condition == "") { return(null); } string[] items = condition.Split(','); List <TIVInfo> tIVInfos = new List <TIVInfo>(); for (int i = 0; i < items.Length; i++) { string item = items[i]; string[] tivs = item.Split('|'); TIVInfo tIVInfo = new TIVInfo(); tIVInfo.type = Convert.ToInt32(tivs[0]); if (tivs.Length > 1) { tIVInfo.id = Convert.ToInt32(tivs[1]); } if (tivs.Length > 2) { tIVInfo.value = float.Parse(tivs[2]); } tIVInfos.Add(tIVInfo); } return(tIVInfos); }
public bool CollectTask(bool isTemp) { bool taskAllComplete = true; for (int i = 0; i < FightModel.Instance.fightInfo.task.Count; i++) { TIVInfo task = FightModel.Instance.fightInfo.task[i]; int collectCount = CollectModel.Instance.profileCollect.GetCount((int)task.id); if (isTemp) { collectCount = collectCount + CollectModel.Instance.tempCollect.GetCount((int)task.id); } int leftCount = (int)task.value - collectCount; if (leftCount <= 0) { leftCount = 0; } else { taskAllComplete = false; } ShowTaskProgress((int)task.id, leftCount, isTemp); } return(taskAllComplete); }
public void LoadHider() { allHiders = new List <HiderInfo> (); List <TIVInfo> tasks = FightModel.Instance.fightInfo.task; int hiderCount = 0; int i; for (i = 0; i < tasks.Count; i++) { TIVInfo task = tasks[i]; if (task.id == 40106) { hiderCount = (int)task.value; break; } } List <Vector2> allFloorPos = FloorModel.Instance.GetAllFloorPos(); for (i = 0; i < hiderCount; i++) { if (allFloorPos.Count > 0) { int randomIndex = UnityEngine.Random.Range(0, allFloorPos.Count); Vector2 floorPos = allFloorPos [randomIndex]; allFloorPos.RemoveAt(randomIndex); HiderInfo hider = new HiderInfo(); hider.configId = 40106; hider.posX = (int)floorPos.x; hider.posY = (int)floorPos.y; allHiders.Add(hider); } } }
private void CreateTaskItem(int index, TIVInfo tiv) { GameObject item = list.NewItem(); TaskTipItem itemCtr = item.GetComponent <TaskTipItem>(); itemCtr.icon = (int)tiv.id; item.name = "task_" + tiv.id; itemCtr.count = (int)tiv.value; }
public void ChapterReward(config_chapter_item itemConfig) { for (int i = 0; i < chapters.Count; i++) { ChapterInfo chapter = chapters[i]; if (chapter.id == itemConfig.id) { chapter.reward = true; List <TIVInfo> rewards = itemConfig.GetRewardList(); for (int j = 0; j < rewards.Count; j++) { TIVInfo reward = rewards[j]; WealthInfo wealthInfo = PlayerModel.Instance.GetWealth(reward.id); wealthInfo.count += (int)reward.value; PromptModel.Instance.Pop("+" + reward.value, true, reward.id); } PlayerModel.Instance.SaveWealths(); SaveChapter(); if (StarRewardEvent != null) { StarRewardEvent(itemConfig); } return; } } ChapterInfo chapterNew = new ChapterInfo(); chapterNew.id = itemConfig.id; chapterNew.reward = true; chapters.Add(chapterNew); List <TIVInfo> rewardsNew = itemConfig.GetRewardList(); for (int j = 0; j < rewardsNew.Count; j++) { TIVInfo reward = rewardsNew[j]; WealthInfo wealthInfo = PlayerModel.Instance.GetWealth(reward.id); wealthInfo.count += (int)reward.value; PromptModel.Instance.Pop("+" + reward.value, true, reward.id); } PlayerModel.Instance.SaveWealths(); SaveChapter(); if (StarRewardEvent != null) { StarRewardEvent(itemConfig); } }
private bool ConditionCompare(TIVInfo condition, int gameValue) { switch (condition.type) { case (int)GuildConditionType.equal: return((int)condition.value == gameValue); case (int)GuildConditionType.more_then: return((int)condition.value > gameValue); case (int)GuildConditionType.less_then: return((int)condition.value < gameValue); } return(false); }
private void InitView() { int buyCount = PlayerModel.Instance.exchangeInfo.count; buyText.text = "" + buyCount; config_wealth_item buyItem = GameMgr.resourceMgr.config_wealth.GetItemByType(PlayerModel.Instance.exchangeInfo.type); buyCoinIcon.gameObject.SetActive(false); buyEnergyIcon.gameObject.SetActive(false); switch (PlayerModel.Instance.exchangeInfo.type) { case (int)WealthTypeEnum.Coin: buyCoinIcon.gameObject.SetActive(true); break; case (int)WealthTypeEnum.Energy: buyEnergyIcon.gameObject.SetActive(true); break; } //buyIcon.overrideSprite = GameMgr.resourceMgr.GetSprite("dependencies.ab", "" + buyItem.icon); TIVInfo cost = buyItem.GetPriceList()[0]; config_wealth_item costItem = (config_wealth_item)GameMgr.resourceMgr.config_wealth.GetItem((int)cost.id); //costIcon.overrideSprite = GameMgr.resourceMgr.GetSprite("dependencies.ab", "" + costItem.icon); int costCount = (int)Mathf.Ceil(buyCount * cost.value); costText.text = "" + costCount; WealthInfo costInfo = PlayerModel.Instance.GetWealth(costItem.id); if (costInfo.count >= costCount) { costText.color = Color.green; } else { costText.color = Color.red; } }
public List <TIVInfo> GetReleaseList() { List <TIVInfo> releases = new List <TIVInfo>(); string[] strs = release.Split(new char[] { ',' }); for (int i = 0; i < strs.Length; i++) { string str = strs[i]; string[] str2s = str.Split(new char[] { '|' }); TIVInfo tiv = new TIVInfo(); tiv.id = int.Parse(str2s[0]); tiv.value = float.Parse(str2s[1]); releases.Add(tiv); } return(releases); }
private void OnOk(GameObject go) { config_wealth_item buyItem = GameMgr.resourceMgr.config_wealth.GetItemByType(PlayerModel.Instance.exchangeInfo.type); int buyCount = PlayerModel.Instance.exchangeInfo.count; WealthInfo buyInfo = PlayerModel.Instance.GetWealth(buyItem.id); TIVInfo cost = buyItem.GetPriceList()[0]; config_wealth_item costItem = (config_wealth_item)GameMgr.resourceMgr.config_wealth.GetItem((int)cost.id); int costCount = (int)Mathf.Ceil(buyCount * cost.value); WealthInfo costInfo = PlayerModel.Instance.GetWealth(costItem.id); if (costInfo.count >= costCount) { buyInfo.count += buyCount; costInfo.count -= costCount; PlayerModel.Instance.SaveWealths(); if (PlayerModel.Instance.exchangeInfo.sucFun != null) { GameMgr.moduleMgr.RemoveUIModule(ModuleEnum.EXCHANGE); PlayerModel.Instance.exchangeInfo.sucFun(); PlayerModel.Instance.exchangeInfo.sucFun = null; } else { PromptModel.Instance.Pop(" +" + buyCount, true, PlayerModel.Instance.exchangeInfo.type); } } else { PromptModel.Instance.Pop(LanguageUtil.GetTxt(11901), false, (int)WealthTypeEnum.Gem); GameMgr.moduleMgr.AddUIModule(ModuleEnum.WEALTH); } }
public void CompleteSave() { config_guild_item nextItem = FindNextItem(guidingItem); if (nextItem == null) { if (!guildInfo.completeRoots.Contains(guidingItem.root_id)) { if (guidingItem.complete_tip != null && guidingItem.complete_tip != "") { PromptModel.Instance.Pop(LanguageUtil.GetTxt(Convert.ToInt32(guidingItem.complete_tip))); } List <TIVInfo> conditions = guidingItem.GetConditions(); if (conditions != null) { for (int i = 0; i < conditions.Count; i++) { TIVInfo condition = conditions[i]; if (condition.id == (int)GuildIDType.play_map) { guidingItem.SetCompleteTemp(true); return; } } } guildInfo.completeRoots.Add(guidingItem.root_id); Save(); } } else { } }
private bool ConditionCheck(config_guild_item item) { List <TIVInfo> conditions = item.GetConditions(); bool isReach = true; for (int i = 0; i < conditions.Count; i++) { TIVInfo condition = conditions[i]; switch ((int)condition.id) { case (int)GuildIDType.crt_star_num: int gameValue = MapModel.Instance.starInfo.crtStar; bool conditionCompare = ConditionCompare(condition, gameValue); if (conditionCompare == false) { return(false); } break; case (int)GuildIDType.guild_complete: if (guildInfo.completeRoots.IndexOf((int)condition.value) == -1) { return(false); } break; case (int)GuildIDType.pass_map: MapInfo map = MapModel.Instance.GetMapInfo((int)condition.value); if (map == null) { return(false); } if (map.star <= 0) { return(false); } break; case (int)GuildIDType.play_map: if (BattleModel.Instance.play_mapId != (int)condition.value) { return(false); } break; case (int)GuildIDType.ready_map: if (BattleModel.Instance.ready_map != (int)condition.value) { return(false); } break; case (int)GuildIDType.lose_map: if (BattleModel.Instance.lose_map != (int)condition.value) { return(false); } break; } } return(isReach); }
private void Filling(List <CellMoveInfo> moveAnims, FightStadus fightState = FightStadus.move, int waitmillisecond = 0) { rootAction = new OrderAction(); ParallelAction paralle = new ParallelAction(); for (int i = 0; i < moveAnims.Count; i++) { CellMoveInfo cellMoveInfo = moveAnims[i]; OrderAction orderAction = new OrderAction(); paralle.AddNode(orderAction); GameObject item = ballLayer.CreateBaseItem((int)cellMoveInfo.paths[0].x, -1); for (int j = 0; j < cellMoveInfo.paths.Count; j++) { ParallelAction paralleMove = new ParallelAction(); orderAction.AddNode(paralleMove); Vector2 pathPoint = cellMoveInfo.paths[j]; Vector2 toPos = PosMgr.GetFightCellPos((int)pathPoint.x, (int)pathPoint.y); paralleMove.AddNode(new MoveActor((RectTransform)item.transform, new Vector3(toPos.x, toPos.y, 0), 0, 0.2f)); if (j > 0) { Vector2 fromPoint = cellMoveInfo.paths[j - 1]; Vector2 fromPos = PosMgr.GetFightCellPos((int)fromPoint.x, (int)fromPoint.y); OrderAction orderRot = new OrderAction(); GameObject itembarrier = barrierLayer.GetItemByPos((int)fromPoint.x, (int)fromPoint.y); if (itembarrier != null) { if (fromPos.x > toPos.x) { orderRot.AddNode(new RoatateActor((RectTransform)itembarrier.transform, new Vector3(0, 0, -60), 0.15f)); orderRot.AddNode(new RoatateActor((RectTransform)itembarrier.transform, new Vector3(0, 0, 0), 0.05f)); paralleMove.AddNode(orderRot); paralleMove.AddNode(new RoatateActor((RectTransform)item.transform, new Vector3(0, 0, -30), 0.2f)); } if (fromPos.x < toPos.x) { orderRot.AddNode(new RoatateActor((RectTransform)itembarrier.transform, new Vector3(0, 0, 60), 0.15f)); orderRot.AddNode(new RoatateActor((RectTransform)itembarrier.transform, new Vector3(0, 0, 0), 0.05f)); paralleMove.AddNode(orderRot); paralleMove.AddNode(new RoatateActor((RectTransform)item.transform, new Vector3(0, 0, 30), 0.2f)); } } List <TIVInfo> p = new List <TIVInfo>(); TIVInfo px = new TIVInfo(); px.value = pathPoint.x; TIVInfo py = new TIVInfo(); py.value = pathPoint.y; p.Add(px); p.Add(py); if (fromPos.x > toPos.x) { paralleMove.AddNode(new FuncTIVActor(Harvest, p)); } if (fromPos.x < toPos.x) { paralleMove.AddNode(new FuncTIVActor(Harvest, p)); } } } BallBaseItem itemCtr = item.GetComponent <BallBaseItem>(); orderAction.AddNode(new PlayBallMoveEndActor(itemCtr)); } if (waitmillisecond > 0) { rootAction.AddNode(new WaitActor(waitmillisecond)); } rootAction.AddNode(paralle); ExecuteAction(fightState); }
public List <CellInfo> ReleaseList(int monsterId) { List <CellInfo> releaseList = new List <CellInfo>(); MonsterInfo monster = GetMonsterInfoByRunId(monsterId); if (monster != null && monster.releaseList.Count > 0) { TIVInfo tiv = monster.releaseList[0]; CellModel.Instance.anims = new List <List <CellAnimInfo> >(); List <CellInfo> waitList = new List <CellInfo>(); if ((int)tiv.value <= 0) { CellInfo centerCell = CellModel.Instance.GetCellByPos(monster.posX, monster.posY); CellDirType dirType = WallModel.Instance.GetGapWallDir(centerCell); if (dirType != CellDirType.no) { waitList = CellModel.Instance.GetDirCells(centerCell, dirType); } for (int i = 0; i < waitList.Count; i++) { CellInfo cellInfo = waitList[i]; if (cellInfo != null && cellInfo.isBlank == false && cellInfo.config.cell_type == (int)CellType.five) { cellInfo.SetConfig((int)tiv.id); releaseList.Add(cellInfo); } } } else { if (monster.progress > 0) { if (monster.progress >= 1) { monster.progress = 0; CellInfo centerCell = CellModel.Instance.GetCellByPos(monster.posX, monster.posY); waitList = CellModel.Instance.GetNeighbors(centerCell); for (int i = 0; i < waitList.Count; i++) { CellInfo cellInfo = waitList[i]; if (cellInfo != null && cellInfo.isBlank == false && cellInfo.config.cell_type == (int)CellType.five) { cellInfo.SetConfig((int)tiv.id); releaseList.Add(cellInfo); } } } } else if (monster.banCount >= 0) { if (monster.banCount == 0) { CellInfo domnCell = CellModel.Instance.GetCellByPos(monster.posX, monster.posY + 1); if (domnCell != null) { if (domnCell.isBlank) { domnCell.SetConfig(monster.releaseId); CellModel.Instance.RemoveFromLines(domnCell.posX, domnCell.posY); releaseList.Add(domnCell); } else { if (domnCell.config.id != monster.releaseId && domnCell.config.cell_type != (int)CellType.terrain) { config_cell_item config_cell = (config_cell_item)ResModel.Instance.config_cell.GetItem(monster.releaseId); bool inHide = false; List <int> hides = config_cell.GetHides(); for (int h = 0; h < hides.Count; h++) { if (domnCell.config.id == hides[h]) { inHide = true; } } if (inHide == false) { domnCell.SetConfig(monster.releaseId); CellModel.Instance.RemoveFromLines(domnCell.posX, domnCell.posY); releaseList.Add(domnCell); } } } } } } else { for (int i = 0; i < BattleModel.Instance.crtBattle.ShowHeight(); i++) { List <CellInfo> xCells = CellModel.Instance.allCells[i]; for (int j = 0; j < xCells.Count; j++) { CellInfo cellInfo = xCells[j]; if (cellInfo.isBlank == false && cellInfo.config.cell_type == (int)CellType.five && cellInfo.changer == 0) { if (tiv.id != cellInfo.config.id) { waitList.Add(cellInfo); } } } } int minCount = Mathf.Min((int)tiv.value, waitList.Count); for (int i = 0; i < minCount; i++) { int rangeIndex = Random.Range(0, waitList.Count); CellInfo cellInfo = waitList[rangeIndex]; cellInfo.SetConfig((int)tiv.id); waitList.RemoveAt(rangeIndex); releaseList.Add(cellInfo); } } } } return(releaseList); }