public bool checkMapEvent(int x, int y, short id) { GameBattleDTL.Point point = getPoint(x, y); if (point != null) { return(point.MapEvent == id); } return(false); }
int getCost(int x, int y, GameUnitMove unitMove, GameUnitCampType camp, out bool bd) { // byte baseCost = 0; // byte block = 0; // bool addMove = false; // sbyte subMove = 0; // // switch ( moveType ) // { // case GameUnitMoveType.Walk0: // baseCost = 5; // block = 7; // addMove = true; // subMove = 0; // break; // case GameUnitMoveType.Walk1: // baseCost = 6; // block = 7; // addMove = true; // subMove = 0; // break; // case GameUnitMoveType.Walk2: // baseCost = 5; // block = 7; // addMove = true; // subMove = 0; // break; // case GameUnitMoveType.Walk3: // baseCost = 6; // block = 7; // addMove = true; // subMove = 1; // break; // case GameUnitMoveType.Fly4: // baseCost = 6; // block = 7; // addMove = false; // subMove = 0; // break; // case GameUnitMoveType.Fly5: // baseCost = 7; // block = 9; // addMove = false; // subMove = 0; // break; // case GameUnitMoveType.Fly6: // baseCost = 5; // block = 9; // addMove = false; // subMove = 0; // break; // case GameUnitMoveType.Walk7: // baseCost = 6; // block = 7; // addMove = true; // subMove = -1; // break; // case GameUnitMoveType.Fly8: // baseCost = 6; // block = 7; // addMove = true; // subMove = -2; // break; // case GameUnitMoveType.Fly9: // baseCost = 6; // block = 7; // addMove = true; // subMove = -2; // break; // case GameUnitMoveType.Walk10: // baseCost = 6; // block = 7; // addMove = true; // subMove = -2; // break; // case GameUnitMoveType.None: // baseCost = 100; // block = 7; // addMove = true; // subMove = 0; // break; // } bd = false; int cost = unitMove.baseCost; GameBattleDTL dtl = GameBattleManager.instance.ActiveDTL; int index1 = dtl.Width * y + x; GameBattleDTL.Point point = dtl.Points[index1]; int subMove = point.Move + unitMove.subMove; if (subMove < 0) { subMove = 0; } if (unitMove.addMove) { cost = unitMove.baseCost + subMove; } // right int index = dtl.Width * y + x + 1; if (index >= 0 && index < dtl.Points.Length) { GameBattleUnit unit = GameBattleUnitManager.instance.getUnit(x + 1, y); if (unit != null) { if (unitMove.addMove && unit.IsAlive && unit.UnitCampType != camp) { bd = true; } } } // left index = dtl.Width * y + x - 1; if (index >= 0 && index < dtl.Points.Length) { GameBattleUnit unit = GameBattleUnitManager.instance.getUnit(x - 1, y); if (unit != null) { if (unitMove.addMove && unit.IsAlive && unit.UnitCampType != camp) { bd = true; } } } // top index = dtl.Width * (y - 1) + x; if (index >= 0 && index < dtl.Points.Length) { GameBattleUnit unit = GameBattleUnitManager.instance.getUnit(x, y - 1); if (unit != null) { if (unitMove.addMove && unit.IsAlive && unit.UnitCampType != camp) { bd = true; } } } // bottom index = dtl.Width * (y + 1) + x; if (index >= 0 && index < dtl.Points.Length) { GameBattleUnit unit = GameBattleUnitManager.instance.getUnit(x, y + 1); if (unit != null) { if (unitMove.addMove && unit.IsAlive && unit.UnitCampType != camp) { bd = true; } } } return(cost); }
void findCell(int move, GameUnitMoveType moveType, bool fly, GameUnitCampType camp) { GameUnitMove unitMove = GameUnitMoveTypeData.instance.getData(moveType); bool user = (camp == GameUnitCampType.User); GameBattleDTL dtl = GameBattleManager.instance.ActiveDTL; closeList.Add(openList[0]); while (openList.Count > 0) { List <Cell> newOpenList = new List <Cell>(); for (int i = 0; i < openList.Count; i++) { Cell cell = openList[i]; GameBattleDTL.Point point = null; // right int index = dtl.Width * cell.y + cell.x + 1; if (index >= 0 && index < dtl.Points.Length && !isClose(cell.x + 1, cell.y, camp, fly)) { point = dtl.Points[index]; bool bd = false; int cost = getCost(cell.x + 1, cell.y, unitMove, camp, out bd); if (point.Move < unitMove.block && cell.f + cost <= move) { Cell newCell = new Cell(); newCell.x = cell.x + 1; newCell.y = cell.y; newCell.f = cell.f + (bd ? cost * 2 : cost); newCell.c = cost; newCell.ca = cell.f + cost; newOpenList.Add(newCell); closeList.Add(newCell); } } // left index = dtl.Width * cell.y + cell.x - 1; if (index >= 0 && index < dtl.Points.Length && !isClose(cell.x - 1, cell.y, camp, fly)) { point = dtl.Points[index]; bool bd = false; int cost = getCost(cell.x - 1, cell.y, unitMove, camp, out bd); if (point.Move < unitMove.block && cell.f + cost <= move) { Cell newCell = new Cell(); newCell.x = cell.x - 1; newCell.y = cell.y; newCell.f = cell.f + (bd ? cost * 2 : cost); newCell.c = cost; newCell.ca = cell.f + cost; newOpenList.Add(newCell); closeList.Add(newCell); } } // top index = dtl.Width * (cell.y - 1) + cell.x; if (index >= 0 && index < dtl.Points.Length && !isClose(cell.x, cell.y - 1, camp, fly)) { point = dtl.Points[index]; bool bd = false; int cost = getCost(cell.x, cell.y - 1, unitMove, camp, out bd); if (point.Move < unitMove.block && cell.f + cost <= move) { Cell newCell = new Cell(); newCell.x = cell.x; newCell.y = cell.y - 1; newCell.f = cell.f + (bd ? cost * 2 : cost); newCell.c = cost; newCell.ca = cell.f + cost; newOpenList.Add(newCell); closeList.Add(newCell); } } // bottom index = dtl.Width * (cell.y + 1) + cell.x; if (index >= 0 && index < dtl.Points.Length && !isClose(cell.x, cell.y + 1, camp, fly)) { point = dtl.Points[index]; bool bd = false; int cost = getCost(cell.x, cell.y + 1, unitMove, camp, out bd); if (point.Move < unitMove.block && cell.f + cost <= move) { Cell newCell = new Cell(); newCell.x = cell.x; newCell.y = cell.y + 1; newCell.f = cell.f + (bd ? cost * 2 : cost); newCell.c = cost; newCell.ca = cell.f + cost; newOpenList.Add(newCell); closeList.Add(newCell); } } } openList.Clear(); openList = null; openList = newOpenList; } for (int i = 1; i < closeList.Count;) { if (isUnit(closeList[i].x, closeList[i].y)) { closeList.RemoveAt(i); } else { i++; } } for (int i = 0; i < closeList.Count; i++) { addCell(closeList[i], user); } }
public void checkMapEvent1(GameBattleUnit unit, OnEventOver over) { onEventOver = over; GameBattleDTL.Point point = getPoint(unit.PosX, unit.PosY); if (!mapEvent.ContainsKey(point.MapEvent)) { onCheckMapEvent(); return; } GameBattleMEVT evt = mapEvent[point.MapEvent]; switch (evt.EventType) { case GameBattleMapEventType.Event: { switch (evt.EventParm1) { // what ghost !? case 0: break; case 1: break; case 2: if (unit.IsEnemy) { onCheckMapEvent(); return; } break; case 4: if (GameUserData.instance.Stage == 31) { if (unit.UnitID > 1) { onCheckMapEvent(); return; } } break; case 3: case 5: { if (unit.BattleAIType != GameBattleAIType.AIMoveToPos) { onCheckMapEvent(); return; } if (!checkMapEvent(unit.AIMoveToX, unit.AIMoveToY, point.MapEvent)) { onCheckMapEvent(); return; } } break; case 6: break; } GameUserData.instance.setGameData((int)GameUserDataType.MapEvent6, unit.BattleManID); GameBattleEventManager.instance.showEvent(evt.EventParm2, 0, onCheckMapEvent1); } break; default: onCheckMapEvent1(); break; } }
public void checkMapEvent(GameBattleUnit unit, OnEventOver over) { onEventOver = over; GameBattleDTL.Point point = getPoint(unit.PosX, unit.PosY); if (!mapEvent.ContainsKey(point.MapEvent)) { onCheckMapEvent(); return; } GameBattleMEVT evt = mapEvent[point.MapEvent]; switch (evt.EventType) { case GameBattleMapEventType.Event: { switch (evt.EventParm1) { // what ghost !? case 0: break; case 1: break; case 2: break; case 3: onCheckMapEvent(); return; case 4: if (GameUserData.instance.Stage == 31) { // fix stage 30 bug. so many bugs. if (GameUserData.instance.getGameData(10) == 0) { onCheckMapEvent(); return; } if (unit.UnitID > 1) { onCheckMapEvent(); return; } if (unit.UnitID == 0 && unit.WeaponID != 14) { onCheckMapEvent(); return; } if (unit.UnitID == 0 && GameUserData.instance.Proficiency < 25 - PlayerPrefs.GetInt("review", 0)) { onCheckMapEvent(); return; } if (unit.UnitID == 1 && unit.BattleAIType == GameBattleAIType.None) { onCheckMapEvent(); return; } } break; case 5: onCheckMapEvent(); return; case 6: break; } GameUserData.instance.setGameData((int)GameUserDataType.MapEvent6, unit.BattleManID); GameBattleEventManager.instance.showEvent(evt.EventParm2, 0, onCheckMapEvent); } break; case GameBattleMapEventType.Item: { switch (evt.ItemGetType) { case GameBattleMapEventType.Item: { if (unit.canAddItem()) { unit.addItem(evt.ItemGetParm1); } else { GameUserData.instance.addItem(evt.ItemGetParm1); } GameBattleGetItemUI.instance.show(evt.ItemGetParm1, 0, null); onCheckMapEvent(); } break; case GameBattleMapEventType.Gold: { GameUserData.instance.addGold(evt.ItemGetParm1); GameBattleGetItemUI.instance.show(GameDefine.INVALID_ID, evt.ItemGetParm1, null); onCheckMapEvent(); } break; } mapEvent.Remove(point.MapEvent); } break; } for (int i = 0; i < transTreasures.childCount; ++i) { if (transTreasures.GetChild(i).gameObject.name == point.MapEvent.ToString()) { Destroy(transTreasures.transform.GetChild(i).gameObject); } } // clearTreasures(); // updateTreasures(); }