//显示周围距离内的棋子 protected void show_move_Dis(bool state, int ditance, bool isremove) { if (!state) { foreach (Part p in show_List) { //Debug.Log("ok"); if (p != null) { p.isShowArea = false; } } show_List.Clear(); } else { if (currentPart != null) { //show_move_Dis(false,0, isremove); show_List.Clear(); show_List = Chess_manager.getShowArea(currentPart.GetComponent <Part>(), ditance, isremove); //if(arm_type == Arm_type.Naval) //{ // foreach (Part p in show_List) // { // if (p.thistype == PartType.WATER) // { // show_List.Remove(p); // } // } //} foreach (Part p in show_List) { if (p != null) { p.isShowArea = state; } } } } }
void chooseTarget() { List <Part> List_Town = new List <Part>(); Part min = null; float mindis = 99999; if (GameManager.instance.getEnemyNum() < GameManager.instance.getPlayerNum()) { List_Town = GameManager.instance.game_state.enemy_town; } else { List_Town = GameManager.instance.game_state.play_town; } foreach (Part p in List_Town) { if (p == null) { continue; } int dis = Chess_manager.GetRouteDis(currentPart.GetComponent <Part>(), p); if (mindis > dis) { mindis = dis; min = p; } } if (min != null) { show_List = Chess_manager.searchRoute(currentPart.GetComponent <Part>(), min); near_city = min.transform; if (show_List.Count > 2) { if (!show_List[now_movedis].isControl && show_List[now_movedis].thistype != PartType.WATER) { tarChess = show_List[now_movedis].GetComponent <Transform>(); } else { show_List = Chess_manager.getShowArea(currentPart.GetComponent <Part>(), now_movedis, true); //Debug.Log(show_List.Count); int standdis = Chess_manager.GetRouteDis(currentPart.GetComponent <Part>(), min); for (int i = 0; i < show_List.Count; i++) { int dis = Chess_manager.GetRouteDis(show_List[i], min); if ((show_List[i] != null && show_List[i].thistype == PartType.WATER && arm_type == Arm_type.ARMY) || (dis > standdis)) { show_List.Remove(show_List[i]); } } int index1 = (int)(Random.Range(0, 1) * (show_List.Count - 1)); if (show_List[index1].isControl || (show_List[index1].thistype == PartType.WATER && this.arm_type == Arm_type.ARMY)) { tarChess = currentPart; } else { tarChess = show_List[index1].GetComponent <Transform>(); } } } else { tarChess = currentPart; } } show_List = Chess_manager.searchRoute(currentPart.GetComponent <Part>(), tarChess.GetComponent <Part>()); }
void getnearest_chess_and_dis() { show_List.Clear(); List <ChessControl> player_arm = new List <ChessControl>(); player_arm = GameManager.player_arm; ChessControl min = null; float mindis = 99999; getnowPart(); foreach (ChessControl p in player_arm) { if (p == null) { continue; } int dis = Chess_manager.GetRouteDis(currentPart.GetComponent <Part>(), p.currentPart.GetComponent <Part>()); if (mindis > dis) { mindis = dis; min = p; } } if (min != null) { show_List = Chess_manager.searchRoute(currentPart.GetComponent <Part>(), min.currentPart.GetComponent <Part>()); near_player = min.transform; if (show_List.Count > 2) { if (!show_List[now_movedis].isControl) { tarChess = show_List[now_movedis].GetComponent <Transform>(); } else { show_List = Chess_manager.getShowArea(currentPart.GetComponent <Part>(), now_movedis, true); //Debug.Log(show_List.Count); int standdis = Chess_manager.GetRouteDis(currentPart.GetComponent <Part>(), min.currentPart.GetComponent <Part>()); for (int i = 0; i < show_List.Count; i++) { int dis = Chess_manager.GetRouteDis(show_List[i], min.currentPart.GetComponent <Part>()); if ((show_List[i] != null && show_List[i].thistype == PartType.WATER && arm_type == Arm_type.ARMY) || (dis > standdis)) { show_List.Remove(show_List[i]); } } int index1 = (int)(Random.Range(0, 1) * (show_List.Count - 1)); if (show_List[index1].isControl || (show_List[index1].thistype == PartType.WATER && this.arm_type == Arm_type.ARMY)) { tarChess = currentPart; } else { tarChess = show_List[index1].GetComponent <Transform>(); } } } else { tarChess = currentPart; } } show_List = Chess_manager.searchRoute(currentPart.GetComponent <Part>(), tarChess.GetComponent <Part>()); }