public List <MonsterInfo> CrawlCreate() { List <MonsterInfo> newMonster = new List <MonsterInfo>(); for (int i = 0; i < crawlCreators.Count; i++) { MonsterCrawlCreator creator = crawlCreators[i]; if (creator.monster == null) { CellInfo startCell = CellModel.Instance.GetCellByPos(creator.posX, creator.posY); if (!startCell.isBlank && startCell.config.cell_type == (int)CellType.terrain) { continue; } MonsterInfo monster = new MonsterInfo(); monster.configId = creator.createId; monster.SetConfig(monster.configId); monster.posX = creator.posX; monster.posY = creator.posY; allMonsters[creator.posY][creator.posX] = monster; creator.monster = monster; monster.InitReleaseList(); startCell.SetConfig((int)monster.releaseList[0].id); monster.Hold(); monster.InitRoadCrawl(); newMonster.Add(monster); } } return(newMonster); }
public static List <CellInfo> ChangeList() { List <List <CellInfo> > allCells = CellModel.Instance.allCells; List <CellInfo> changeCells = new List <CellInfo>(); int i; for (i = (allCells.Count - 1); i >= 0; i--) { List <CellInfo> xCells = allCells[i]; for (int j = (xCells.Count - 1); j >= 0; j--) { CellInfo cellInfo = xCells[j]; if (cellInfo.isBlank == false && cellInfo.changer > 0) { int newId = GetChangeId(cellInfo.config.id); cellInfo.changer = newId + (cellInfo.changer - cellInfo.configId); cellInfo.SetConfig(newId); changeCells.Add(cellInfo); cellInfo.originalConfigId = newId; } } } return(changeCells); }
public List <CellInfo> QuitCell(CellInfo cellInfo) { List <CellInfo> controlCells = new List <CellInfo>(); SkillEntityInfo skillEntityInfo = GetSkillEntityByCell(cellInfo); if (skillEntityInfo != null) { skillEntityInfo.fightingType = SkillFightingType.idel; for (int i = 0; i < skillEntityInfo.controlCells.Count; i++) { CellInfo controlCell = skillEntityInfo.controlCells[i]; if (skillEntityInfo.seed.config_cell_item.cell_type == (int)CellType.radiate) { if (controlCell.isBlank == false && controlCell.config.cell_type == (int)CellType.five && !CoverModel.Instance.StopSkill(controlCell.posX, controlCell.posY) && !MonsterModel.Instance.StopSkill(controlCell.posX, controlCell.posY)) { controlCell.SetConfig(controlCell.originalConfigId); } } controlCell.bombMark = false; controlCells.Add(controlCell); } } return(controlCells); }
private void SkillEffect(SkillEntityInfo skillEntityInfo) { bool isBomb = (skillEntityInfo.seed.config_cell_item.cell_type == (int)CellType.bomb || skillEntityInfo.seed.config_cell_item.cell_type == (int)CellType.line_bomb_r || skillEntityInfo.seed.config_cell_item.cell_type == (int)CellType.three_bomb_r); bool isRadiate = (skillEntityInfo.seed.config_cell_item.cell_type == (int)CellType.radiate); for (int i = 0; i < skillEntityInfo.controlCells.Count; i++) { CellInfo controlCell = skillEntityInfo.controlCells[i]; if (isBomb) { controlCell.bombMark = true; } if (isRadiate && !CoverModel.Instance.StopSkill(controlCell.posX, controlCell.posY) && !MonsterModel.Instance.StopSkill(controlCell.posX, controlCell.posY)) { if (controlCell.isBlank == false && controlCell.config.cell_type == (int)CellType.five) { controlCell.SetConfig(skillEntityInfo.seed.config_cell_item.hide_id); } } } }
public void InitCrawl() { List <MonsterInfo> allCrawlMonsters = new List <MonsterInfo>(); List <MonsterInfo> roadCrawlMonsters = new List <MonsterInfo>(); List <MonsterInfo> randomCrawlMonsters = new List <MonsterInfo>(); int i; for (i = 0; i < allMonsters.Count; i++) { for (int j = 0; j < allMonsters[i].Count; j++) { MonsterInfo monsterInfo = allMonsters[i][j]; if (monsterInfo.IsNull() == false && monsterInfo.config.monster_type == (int)MonsterType.crawl) { allCrawlMonsters.Add(monsterInfo); if (monsterInfo.IsRoadCrawl()) { roadCrawlMonsters.Add(monsterInfo); } else { randomCrawlMonsters.Add(monsterInfo); } } } } for (i = 0; i < allCrawlMonsters.Count; i++) { MonsterInfo crawlInfo = allCrawlMonsters[i]; CellInfo startCell = CellModel.Instance.GetCellByPos(crawlInfo.posX, crawlInfo.posY); crawlInfo.InitReleaseList(); startCell.SetConfig((int)crawlInfo.releaseList[0].id); } for (i = 0; i < roadCrawlMonsters.Count; i++) { MonsterInfo monsterInfo = roadCrawlMonsters[i]; monsterInfo.InitRoadCrawl(); } }
private void Crawl() { rootAction = new OrderAction(); if (!isDeductStep) { MonsterModel.Instance.Crawl(); List <MonsterCrawlInfo> crawAnims = MonsterModel.Instance.crawAnims; rootAction = new OrderAction(); ParallelAction paralle = new ParallelAction(); for (int i = 0; i < crawAnims.Count; i++) { MonsterCrawlInfo crawAnim = crawAnims[i]; OrderAction orderAction = new OrderAction(); paralle.AddNode(orderAction); FightMonsterItem monsterItem = monsterLayer.GetItemByRunId(crawAnim.monster.runId); for (int j = 0; j < crawAnim.pathCells.Count; j++) { CellInfo pathCell = crawAnim.pathCells[j]; Vector2 toPos = PosUtil.GetFightCellPos(pathCell.posX, pathCell.posY); float zrotate = 0; if (j > 0) { Vector2 fromPos = PosUtil.GetFightCellPos(crawAnim.pathCells[j - 1].posX, crawAnim.pathCells[j - 1].posY); zrotate = PosUtil.VectorAngle(new Vector2(fromPos.x, fromPos.y), new Vector2(toPos.x, toPos.y)); } else { Vector2 anchoredPos = ((RectTransform)monsterItem.transform).anchoredPosition; zrotate = PosUtil.VectorAngle(new Vector2(anchoredPos.x, anchoredPos.y), new Vector2(toPos.x, toPos.y)); } orderAction.AddNode(new RotationActor((RectTransform)monsterItem.transform, zrotate)); float speed = 600; orderAction.AddNode(new MoveActor((RectTransform)monsterItem.transform, new Vector3(toPos.x, toPos.y, 0), speed)); if (pathCell.isBlank == false) { FightCellItem cellItem = GetItemByRunId(pathCell.runId); pathCell.SetConfig((int)crawAnim.monster.releaseList[0].id); pathCell.changer = 0; orderAction.AddNode(new ChangeCellActor(cellItem, pathCell)); } } if (crawAnim.roadEnd) { orderAction.AddNode(new ScaleActor((RectTransform)monsterItem.transform, new Vector3(0, 0, 0), 0.3f)); orderAction.AddNode(new ChangeMonsterActor(monsterItem, crawAnim.monster)); } } rootAction.AddNode(paralle); } ExecuteAction(FightStadus.crawl); }
public void InitFight() { FightModel.Instance.InitFightInfo(); CellInfo.start_x = crtBattle.start_x; MonsterModel.Instance.Destroy(); FloorModel.Instance.Destroy(); CellModel.Instance.Destroy(); WallModel.Instance.Destroy(); CoverModel.Instance.Destroy(); InvadeModel.Instance.Destroy(); int i; for (i = 0; i < crtBattle.battle_height; i++) { List <MonsterInfo> yMonsters = new List <MonsterInfo>(); List <FloorInfo> yFloors = new List <FloorInfo>(); List <CellInfo> yCells = new List <CellInfo>(); List <List <WallInfo> > yWalls = new List <List <WallInfo> >(); List <CoverInfo> yCovers = new List <CoverInfo>(); MonsterModel.Instance.allMonsters.Add(yMonsters); FloorModel.Instance.allFloors.Add(yFloors); CellModel.Instance.allCells.Add(yCells); WallModel.Instance.allWalls.Add(yWalls); CoverModel.Instance.allCovers.Add(yCovers); for (int j = 0; j < crtBattle.battle_width; j++) { BattleCellInfo battleCellInfo = crtBattle.allCells[i][j]; MonsterInfo monsterInfo = new MonsterInfo(); monsterInfo.configId = battleCellInfo.monster_id; monsterInfo.SetConfig(battleCellInfo.monster_id); monsterInfo.posX = j; monsterInfo.posY = i; yMonsters.Add(monsterInfo); FloorInfo floorInfo = new FloorInfo(); floorInfo.SetConfig(battleCellInfo.floor_id); floorInfo.posX = j; floorInfo.posY = i; yFloors.Add(floorInfo); CellInfo cellInfo = new CellInfo(); cellInfo.SetConfig(battleCellInfo.cell_id); cellInfo.posX = j; cellInfo.posY = i; yCells.Add(cellInfo); if (cellInfo.isBlank == false && cellInfo.config.cell_type == (int)CellType.changer) { cellInfo.changer = cellInfo.config.icon; cellInfo.SetConfig(cellInfo.config.hide_id); cellInfo.originalConfigId = cellInfo.config.hide_id; } if (cellInfo.config != null) { if (cellInfo.config.cell_type == (int)CellType.invade || cellInfo.config.id == 10007) { InvadeModel.Instance.AddInvade(cellInfo); } } CoverInfo coverInfo = new CoverInfo(); coverInfo.SetConfig(battleCellInfo.cover_id); coverInfo.posX = j; coverInfo.posY = i; yCovers.Add(coverInfo); List <WallInfo> xWalls = new List <WallInfo>(); for (int n = 0; n < 3; n++) { WallInfo wallInfo = new WallInfo(); wallInfo.SetConfig(battleCellInfo.walls[n]); wallInfo.posX = j; wallInfo.posY = i; wallInfo.posN = n; xWalls.Add(wallInfo); } yWalls.Add(xWalls); } } MonsterModel.Instance.RandomPos(); MonsterModel.Instance.HoldAll(); HideModel.Instance.LoadHider(); }
private void OnClickSelectHander(GameObject go) { PropTouchItem itemCtr = go.GetComponent <PropTouchItem>(); if (itemCtr.valid) { CellInfo cellInfo = CellModel.Instance.GetCellByPos(itemCtr.control_x, itemCtr.control_y); switch (crtPropId) { case 10002: CellModel.Instance.anims = new List <List <CellAnimInfo> >(); List <CellAnimInfo> stepMoves = new List <CellAnimInfo>(); CellModel.Instance.anims.Add(stepMoves); if (cellInfo != null) { cellInfo.isLink = true; CellModel.Instance.lineCells.Add(cellInfo); cellInfo.isBlank = true; CellModel.Instance.AddAnim(cellInfo, CellAnimType.clear); FightModule.crtFightStadus = FightStadus.prop_clear; PromptModel.Instance.Pop(LanguageUtil.GetTxt(11410)); } Show(0); PropModel.Instance.crtProp.Use(); PropModel.Instance.ChangePropStadus(PropStadus.unSelect); break; case 10003: if (selectDepth == 1) { //change depth0Cell.SetConfig(itemCtr.control_id); depth0Cell.changer = 0; List <CellInfo> changeCells = new List <CellInfo>(); changeCells.Add(depth0Cell); PromptModel.Instance.Pop(LanguageUtil.GetTxt(11411)); PropModel.Instance.PropChangeCellsEvent(changeCells); Show(0); PropModel.Instance.crtProp.Use(); PropModel.Instance.ChangePropStadus(PropStadus.unSelect); return; } if (selectDepth == 0) { depth0Cell = cellInfo; tipText.text = LanguageUtil.GetTxt(11412); tipBg.rectTransform.sizeDelta = new Vector2(tipText.preferredWidth + 80, tipBg.rectTransform.sizeDelta.y); CreatBrushs(cellInfo); } break; case 10005: if (selectDepth == 1) { CellModel.Instance.anims = new List <List <CellAnimInfo> >(); stepMoves = new List <CellAnimInfo>(); CellModel.Instance.anims.Add(stepMoves); CellModel.Instance.SwitchPos(depth0Cell, cellInfo); depth0Cell.SwitchPos(cellInfo); List <CellInfo> changeCells = new List <CellInfo>(); changeCells.Add(depth0Cell); changeCells.Add(cellInfo); PromptModel.Instance.Pop(LanguageUtil.GetTxt(11413)); PropModel.Instance.PropChangeCellsEvent(changeCells); Show(0); PropModel.Instance.crtProp.Use(); PropModel.Instance.ChangePropStadus(PropStadus.unSelect); return; } if (selectDepth == 0) { List <CellInfo> neighbors = CellModel.Instance.GetNeighbors(cellInfo); bool hasSwitch = ShowSwitchList(neighbors, cellInfo); if (hasSwitch == true) { tipText.text = LanguageUtil.GetTxt(11414); tipBg.rectTransform.sizeDelta = new Vector2(tipText.preferredWidth + 80, tipBg.rectTransform.sizeDelta.y); depth0Cell = cellInfo; } else { PromptModel.Instance.Pop(LanguageUtil.GetTxt(11415)); ShowList(); } } break; } } else { PromptModel.Instance.Pop(LanguageUtil.GetTxt(11415)); } }
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); }
public List <CellInfo> OutCell(CellInfo cellInfo) { List <CellInfo> controlCells = new List <CellInfo>(); if (cellInfo.isLink == false) //退出技能格 { if (crt_entity != null) { int crtentitytype = crt_entity.seed.config_cell_item.cell_type; if (crt_entity.cell.runId == cellInfo.runId) { crt_entity.fightingType = SkillFightingType.idel; if (crtentitytype == (int)CellType.radiate) { for (int i = 0; i < crt_entity.controlCells.Count; i++) { CellInfo controlCell = crt_entity.controlCells[i]; if (controlCell.isBlank == false) { bool occupy = false; for (int n = (CellModel.Instance.lineCells.Count - 1); n >= 0; n--) { CellInfo checkCell = CellModel.Instance.lineCells[n]; SkillEntityInfo checkEntityInfo = GetSkillEntityByCell(checkCell); if (checkEntityInfo != null) { int checkEntityType = checkEntityInfo.seed.config_cell_item.cell_type; if (checkEntityType == (int)CellType.radiate) { bool have = checkEntityInfo.controlCells.Contains(controlCell); if (have) { occupy = true; break; } } } } if (occupy == false) { controlCell.SetConfig(controlCell.originalConfigId); } } controlCells.Add(controlCell); } crt_entity = null; } else if (crtentitytype == (int)CellType.bomb || crtentitytype == (int)CellType.line_bomb_r || crtentitytype == (int)CellType.three_bomb_r) { for (int i = 0; i < crt_entity.controlCells.Count; i++) { CellInfo controlCell = crt_entity.controlCells[i]; controlCell.bombMark = false; controlCells.Add(controlCell); } crt_entity = null; } } } } if (crt_entity != null) { int crtentitytype = crt_entity.seed.config_cell_item.cell_type; if (crtentitytype == (int)CellType.bomb || crtentitytype == (int)CellType.line_bomb_r || crtentitytype == (int)CellType.three_bomb_r) { for (int i = 0; i < crt_entity.controlCells.Count; i++) { CellInfo controlCell = crt_entity.controlCells[i]; controlCell.bombMark = false; CellInfo find = controlCells.Find( //使用匿名函数 delegate(CellInfo cell) { return(cell.runId == controlCell.runId); }); if (find == null) { controlCells.Add(controlCell); } } } } return(controlCells); }