public int CompareTo(object obj) { SkillEntityInfo target = obj as SkillEntityInfo; if (target == null) { throw new NotImplementedException(); } int thisValue; if (this.IsHump()) { thisValue = this.skill_x * SORT_FLAG - this.skill_y * 200 + 100; } else { thisValue = this.skill_x * SORT_FLAG - this.skill_y * 200; } int targetValue; if (target.IsHump()) { targetValue = target.skill_x * SORT_FLAG - target.skill_y * 200 + 100; } else { targetValue = target.skill_x * SORT_FLAG - target.skill_y * 200; } return(thisValue.CompareTo(targetValue)); }
public void InitFightingEntitys() { fighting_entitys = new List <SkillEntityInfo>(); List <List <CellInfo> > allCells = CellModel.Instance.allCells; for (int i = 0; i < allCells.Count; i++) { List <CellInfo> xCells = allCells[i]; for (int j = 0; j < xCells.Count; j++) { CellInfo cellInfo = xCells[j]; if (cellInfo.isBlank == false) { if (cellInfo.config.cell_type == (int)CellType.radiate || cellInfo.config.cell_type == (int)CellType.bomb) { SkillEntityInfo entity = new SkillEntityInfo(); entity.seed = CreateTempSeed(cellInfo.config.id); ThrowSkillEntity(entity, cellInfo); } if (cellInfo.config.cell_type == (int)CellType.line_bomb || cellInfo.config.cell_type == (int)CellType.line_bomb_r || cellInfo.config.cell_type == (int)CellType.three_bomb || cellInfo.config.cell_type == (int)CellType.three_bomb_r) { SkillEntityInfo entity = new SkillEntityInfo(); entity.seed = CreateSpecialSeed(cellInfo.config.id); ThrowSkillEntity(entity, cellInfo); } } } } }
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); } } } }
private void UpdateControlCells(SkillEntityInfo skillEntityInfo, bool isDeduct = false) { skillEntityInfo.controlCells = new List <CellInfo>(); if (skillEntityInfo.skill_x == skillEntityInfo.cell.posX && skillEntityInfo.skill_y == skillEntityInfo.cell.posY) { skillEntityInfo.controlCells.Add(skillEntityInfo.cell); } RecursiveControl(skillEntityInfo, skillEntityInfo.controlCells); if (isDeduct == 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 && checkEntityInfo != skillEntityInfo) { int checkEntityType = checkEntityInfo.seed.config_cell_item.cell_type; if (checkEntityType == (int)CellType.bomb || checkEntityType == (int)CellType.line_bomb || checkEntityType == (int)CellType.line_bomb_r || checkEntityType == (int)CellType.three_bomb || checkEntityType == (int)CellType.three_bomb_r) { if (checkEntityType == (int)CellType.line_bomb || checkEntityType == (int)CellType.line_bomb_r || checkEntityType == (int)CellType.three_bomb || checkEntityType == (int)CellType.three_bomb_r) { skillEntityInfo.controlCells.Add(checkEntityInfo.cell); } RecursiveControl(checkEntityInfo, skillEntityInfo.controlCells); } } } } }
private void AddControl(CellInfo getCell, SkillEntityInfo skillEntityInfo, List <CellInfo> controlCells) { if (getCell != null && controlCells.Contains(getCell) == false) { controlCells.Add(getCell); if (getCell.isBlank == false && (skillEntityInfo.cell.config.cell_type == (int)CellType.bomb || skillEntityInfo.cell.config.cell_type == (int)CellType.line_bomb || skillEntityInfo.cell.config.cell_type == (int)CellType.line_bomb_r || skillEntityInfo.cell.config.cell_type == (int)CellType.three_bomb || skillEntityInfo.cell.config.cell_type == (int)CellType.three_bomb_r) && (getCell.config.cell_type == (int)CellType.bomb || getCell.config.cell_type == (int)CellType.line_bomb || getCell.config.cell_type == (int)CellType.line_bomb_r || getCell.config.cell_type == (int)CellType.three_bomb || getCell.config.cell_type == (int)CellType.three_bomb_r)) { if (!CoverModel.Instance.StopSkill(getCell.posX, getCell.posY) && !MonsterModel.Instance.StopSkill(getCell.posX, getCell.posY)) { SkillEntityInfo bombEntity = GetSkillEntityByCell(getCell); if (bombEntity.runId != crt_entity.runId) { if (bombEntity.cell.isLink == false) { bombEntity.skill_x = getCell.posX; bombEntity.skill_y = getCell.posY; } RecursiveControl(bombEntity, controlCells); } } } } }
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 RecursiveControl(SkillEntityInfo skillEntityInfo, List <CellInfo> controlCells) { bool isHump = skillEntityInfo.cell.IsHump(skillEntityInfo.skill_x); if (skillEntityInfo.seed.open_holes == null) { if (skillEntityInfo.cell.config.cell_type == (int)CellType.line_bomb || skillEntityInfo.cell.config.cell_type == (int)CellType.line_bomb_r) { int rotate = skillEntityInfo.cell.config.rotate; if (skillEntityInfo.cell.rotate >= 0) { rotate = skillEntityInfo.cell.rotate; } List <CellInfo> dir1Cells = CellModel.Instance.GetDirCells(skillEntityInfo.cell, (CellDirType)PosMgr.GetDirWithRotate(CellDirType.up, rotate), 3); List <CellInfo> dir2Cells = CellModel.Instance.GetDirCells(skillEntityInfo.cell, (CellDirType)PosMgr.GetDirWithRotate(CellDirType.down, rotate), 3); dir1Cells.InsertRange(dir1Cells.Count, dir2Cells); for (int i = 0; i < dir1Cells.Count; i++) { CellInfo getCell = dir1Cells[i]; AddControl(getCell, skillEntityInfo, controlCells); } } if (skillEntityInfo.cell.config.cell_type == (int)CellType.three_bomb || skillEntityInfo.cell.config.cell_type == (int)CellType.three_bomb_r) { int rotate = skillEntityInfo.cell.config.rotate; if (skillEntityInfo.cell.rotate >= 0) { rotate = skillEntityInfo.cell.rotate; } List <CellInfo> dir1Cells = CellModel.Instance.GetDirCells(skillEntityInfo.cell, (CellDirType)PosMgr.GetDirWithRotate(CellDirType.left_up, rotate), 2); List <CellInfo> dir2Cells = CellModel.Instance.GetDirCells(skillEntityInfo.cell, (CellDirType)PosMgr.GetDirWithRotate(CellDirType.down, rotate), 2); List <CellInfo> dir3Cells = CellModel.Instance.GetDirCells(skillEntityInfo.cell, (CellDirType)PosMgr.GetDirWithRotate(CellDirType.right_up, rotate), 2); dir1Cells.InsertRange(dir1Cells.Count, dir2Cells); dir1Cells.InsertRange(dir1Cells.Count, dir3Cells); for (int i = 0; i < dir1Cells.Count; i++) { CellInfo getCell = dir1Cells[i]; AddControl(getCell, skillEntityInfo, controlCells); } } } else { for (int i = 0; i < skillEntityInfo.seed.open_holes.Count; i++) { int holeIndex = skillEntityInfo.seed.open_holes[i]; Vector2 holePos = SkillTempletModel.Instance.GetHolePos(holeIndex + 1, isHump, skillEntityInfo.seed.dir); int getx = (int)(skillEntityInfo.skill_x + holePos.x); int gety = (int)(skillEntityInfo.skill_y - holePos.y); CellInfo getCell = CellModel.Instance.GetCellByPos(getx, gety); AddControl(getCell, skillEntityInfo, controlCells); } } }
private SkillEntityInfo GetSkillEntityByCell(CellInfo cellInfo) { for (int i = 0; i < fighting_entitys.Count; i++) { SkillEntityInfo skillEntityInfo = fighting_entitys[i]; if (skillEntityInfo.cell.runId == cellInfo.runId) { return(skillEntityInfo); } } return(null); }
public List <CellInfo> DeductSkill() { SkillEnd(); if (fighting_entitys.Count > 0) { fighting_entitys.Sort(); SkillEntityInfo skill = fighting_entitys[0]; fighting_entitys.RemoveAt(0); crt_entity = skill; skill.skill_x = skill.cell.posX; skill.skill_y = skill.cell.posY; UpdateControlCells(skill, true); return(skill.controlCells); } return(new List <CellInfo>()); }
public void SkillEnd() { for (int i = fighting_entitys.Count - 1; i >= 0; i--) { SkillEntityInfo skill = fighting_entitys[i]; if (skill.fightingType == SkillFightingType.active) { fighting_entitys.RemoveAt(i); } else { if (skill.cell.isBlank) { fighting_entitys.RemoveAt(i); } } } crt_entity = null; }
public List <CellInfo> GetBombCells(CellInfo cellInfo) { List <CellInfo> bombCells = new List <CellInfo>(); for (int i = 0; i < fighting_entitys.Count; i++) { SkillEntityInfo skillEntityInfo = fighting_entitys[i]; int entitytype = skillEntityInfo.seed.config_cell_item.cell_type; if (skillEntityInfo.skill_x == cellInfo.posX && skillEntityInfo.skill_y == cellInfo.posY && (entitytype == (int)CellType.bomb || entitytype == (int)CellType.line_bomb_r || entitytype == (int)CellType.three_bomb_r)) { bombCells = skillEntityInfo.controlCells; if (bombCells.Count != 0) { break; } } } return(bombCells); }
//复制 public SkillEntityInfo Copy() { SkillEntityInfo skillEntityInfo = new SkillEntityInfo(); skillEntityInfo.runId = runId; skillEntityInfo.seed = seed; skillEntityInfo.skill_x = skill_x; skillEntityInfo.skill_y = skill_y; skillEntityInfo.fightingType = fightingType; skillEntityInfo.cell = cell.Copy(); skillEntityInfo.controlCells = new List <CellInfo>(); for (int i = 0; i < controlCells.Count; i++) { skillEntityInfo.controlCells.Add(controlCells[i].Copy()); } return(skillEntityInfo); }
//取出可投放的新技能 public List <SkillEntityInfo> GetNewSkillEntitys() { List <SkillEntityInfo> newEntitys = new List <SkillEntityInfo>(); for (int i = 0; i < seeds.Count; i++) { SkillSeedInfo seed = seeds[i]; if (seed.fobid) { continue; } if (seed.progress >= 0.99f) { seed.progressTemp = seed.progress = 0; SkillEntityInfo entity = new SkillEntityInfo(); entity.seed = seed; entity.fightingType = SkillFightingType.wait; newEntitys.Add(entity); } } return(newEntitys); }
private void PlayPutAutoSkill() { rootAction = new OrderAction(); WaitActor waitActor = new WaitActor(200); rootAction.AddNode(waitActor); List <SkillEntityInfo> skillEntitys = SkillModel.Instance.GetNewSkillEntitys(); fightUI.ShowSkill(); if (lastTouchCell != null && skillEntitys.Count > 0) { ParallelAction parallelAction = new ParallelAction(); int holdIndex = 0; bool lastIsHump = lastTouchCell.IsHump(); for (int i = 0; i < skillEntitys.Count; i++) { OrderAction skillOrder = new OrderAction(); SkillEntityInfo skillEntity = skillEntitys[i]; Vector2 addPos = new Vector2(); for (int h = holdIndex; h < 19; h++) { Vector2 holePos = FightConst.GetHoleByLevel(h, lastIsHump); Vector2 checkPos = new Vector2(lastTouchCell.posX + holePos.x, lastTouchCell.posY - holePos.y); CellInfo checkCell = CellModel.Instance.GetCellByPos((int)checkPos.x, (int)checkPos.y); if (checkCell != null && checkCell.isBlank) { addPos = checkPos; holdIndex = h + 1; break; } } CellInfo addItem = CellModel.Instance.AddItem(skillEntity.seed.config_cell_item.id, (int)addPos.x, (int)addPos.y); SkillModel.Instance.ThrowSkillEntity(skillEntity, addItem); GameObject itemObj = CreateCellItem(addItem); itemObj.transform.SetParent(effectLayer.transform, false); Vector2 toPos = PosUtil.GetFightCellPos(addItem.posX, addItem.posY); PosUtil.SetCellPos(itemObj.transform, skillEntity.seed.seed_x, skillEntity.seed.seed_y, 1.0f); rootAction.AddNode(new PlaySoundActor("Useskill")); rootAction.AddNode(new ShowEffectActor(itemObj.transform, "effect_skill_fly")); rootAction.AddNode(new MoveActor((RectTransform)itemObj.transform, new Vector3(toPos.x, toPos.y, 0), 1200)); skillOrder.AddNode(new SetLayerActor(itemObj.transform, transform)); skillOrder.AddNode(new PlaySoundActor("PutAutoSkill")); skillOrder.AddNode(new ClearEffectActor(itemObj.transform, "effect_skill_fly")); skillOrder.AddNode(new ScaleActor((RectTransform)itemObj.transform, new Vector3(1.2f, 1.2f, 0), 0.2f)); skillOrder.AddNode(new ScaleActor((RectTransform)itemObj.transform, new Vector3(1, 1, 0), 0.1f)); parallelAction.AddNode(skillOrder); } rootAction.AddNode(parallelAction); } waitActor = new WaitActor(200); rootAction.AddNode(waitActor); ExecuteAction(FightStadus.auto_skill); }
private void Backup() { allFloorsBackup = FloorModel.Instance.allFloors; allCellsBackup = CellModel.Instance.allCells; allWallsBackup = WallModel.Instance.allWalls; allCoversBackup = CoverModel.Instance.allCovers; allMonstersBackup = MonsterModel.Instance.allMonsters; lineCellsBackup = CellModel.Instance.lineCells; rollbackCellBackup = CellModel.Instance.rollbackCell; fighting_entitysBackup = SkillModel.Instance.fighting_entitys; FloorModel.Instance.allFloors = new List <List <FloorInfo> >(); CellModel.Instance.allCells = new List <List <CellInfo> >(); WallModel.Instance.allWalls = new List <List <List <WallInfo> > >(); CoverModel.Instance.allCovers = new List <List <CoverInfo> >(); MonsterModel.Instance.allMonsters = new List <List <MonsterInfo> >(); SkillModel.Instance.fighting_entitys = new List <SkillEntityInfo>(); List <List <CellInfo> > allCells = allCellsBackup; int i; for (i = 0; i < allCells.Count; i++) { 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>(); List <MonsterInfo> yMonsters = new List <MonsterInfo>(); FloorModel.Instance.allFloors.Add(yFloors); CellModel.Instance.allCells.Add(yCells); WallModel.Instance.allWalls.Add(yWalls); CoverModel.Instance.allCovers.Add(yCovers); MonsterModel.Instance.allMonsters.Add(yMonsters); List <CellInfo> xCells = allCells[i]; for (int j = 0; j < xCells.Count; j++) { CellInfo cellInfo = xCells[j]; yCells.Add(cellInfo.Copy()); FloorInfo floorInfo = allFloorsBackup[cellInfo.posY][cellInfo.posX]; yFloors.Add(floorInfo.Copy()); CoverInfo coverInfo = allCoversBackup[cellInfo.posY][cellInfo.posX]; yCovers.Add(coverInfo.Copy()); MonsterInfo monsterInfo = allMonstersBackup[cellInfo.posY][cellInfo.posX]; yMonsters.Add(monsterInfo.Copy()); List <WallInfo> xWalls = new List <WallInfo>(); yWalls.Add(xWalls); for (int n = 0; n < 3; n++) { WallInfo wallInfo = allWallsBackup[cellInfo.posY][cellInfo.posX][n]; xWalls.Add(wallInfo.Copy()); } } } CellModel.Instance.lineCells = new List <CellInfo>(); for (i = 0; i < lineCellsBackup.Count; i++) { CellInfo cellInfo = lineCellsBackup[i]; CellModel.Instance.lineCells.Add(CellModel.Instance.allCells[cellInfo.posY][cellInfo.posX]); } if (rollbackCellBackup == null) { CellModel.Instance.rollbackCell = null; } else { CellModel.Instance.rollbackCell = CellModel.Instance.allCells[rollbackCellBackup.posY][rollbackCellBackup.posX]; } for (i = 0; i < fighting_entitysBackup.Count; i++) { SkillEntityInfo fighting_entity = fighting_entitysBackup[i]; SkillEntityInfo fighting_entityCopy = fighting_entity.Copy(); fighting_entityCopy.cell = CellModel.Instance.allCells[fighting_entityCopy.cell.posY][fighting_entityCopy.cell.posX]; for (int j = 0; j < fighting_entityCopy.controlCells.Count; j++) { CellInfo controlCell = fighting_entityCopy.controlCells[j]; fighting_entityCopy.controlCells[j] = CellModel.Instance.allCells[controlCell.posY][controlCell.posX]; } SkillModel.Instance.fighting_entitys.Add(fighting_entityCopy); } }
//投放一个技能 public void ThrowSkillEntity(SkillEntityInfo entity, CellInfo cell) { entity.fightingType = SkillFightingType.idel; entity.cell = cell; fighting_entitys.Add(entity); }
public List <CellInfo> EnterCell(CellInfo cellInfo) { SkillEntityInfo skillEntityInfo = GetSkillEntityByCell(cellInfo); if (skillEntityInfo == null) { if (crt_entity != null) { if (crt_entity.seed.config_cell_item.cell_type == (int)CellType.bomb) { //改变炸弹中心 crt_entity.skill_x = cellInfo.posX; crt_entity.skill_y = cellInfo.posY; } } else { for (int i = (CellModel.Instance.lineCells.Count - 1); i >= 0; i--) { CellInfo checkCell = CellModel.Instance.lineCells[i]; SkillEntityInfo checkEntityInfo = GetSkillEntityByCell(checkCell); if (checkEntityInfo != null) { int checkEntityType = checkEntityInfo.seed.config_cell_item.cell_type; if (checkEntityType == (int)CellType.bomb) { crt_entity = checkEntityInfo; crt_entity.skill_x = cellInfo.posX; crt_entity.skill_y = cellInfo.posY; break; } if (checkEntityType == (int)CellType.line_bomb_r || checkEntityType == (int)CellType.three_bomb_r) { crt_entity = checkEntityInfo; crt_entity.skill_x = checkCell.posX; crt_entity.skill_y = checkCell.posY; break; } } } } } else { if (crt_entity != null) { PromptModel.Instance.Pop(""); } crt_entity = skillEntityInfo; crt_entity.fightingType = SkillFightingType.active; crt_entity.skill_x = cellInfo.posX; crt_entity.skill_y = cellInfo.posY; } if (crt_entity == null) { return(new List <CellInfo>()); } else { UpdateControlCells(crt_entity); SkillEffect(crt_entity); return(crt_entity.controlCells); } }
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); }