void ShowText(ChessControl chess) { int hp = chess.GetHp(); Team team = chess.GetTeam(); string teamWord = team == Team.RedTeam ? "红队" : "蓝队"; teamText.text = "队伍:" + teamWord; heroName.text = $"英雄:{chess.HeroInfo.name}"; hpText.text = "血量:" + hp.ToString(); atkText.text = $"攻击:{chess.HeroInfo.atk}"; skillText.text = $"技能名称:{chess.HeroInfo.skillName}\n技能描述:{chess.HeroInfo.skillText}"; showText.SetActive(true); }
/// <summary> /// 读取棋子队伍信息 并完成初始化 /// </summary> private void ReadConfigTeamData() { foreach (var teamConfig in ConfigMgr.Ins.ConfigChessTeam) { // 索引对应坐标的格子 GridControl gridItem = gridInit.mapGrid[teamConfig.posX][teamConfig.posY]; var localPoint = gridItem.transform.position; // 初始化棋子 并设定坐标 ChessControl chessItem = Instantiate(chessPrefab); chessItem.transform.SetParent(transform, false); chessItem.transform.localPosition = localPoint; // 设定信息 chessItem.SetChessInfo(teamConfig); // 把棋子绑定 gridItem.ContentChess = chessItem; } }
public bool MovingChess(GridControl grid) { // 移动棋子 activeGrid.CancelTouch(saveGrid); ChessControl chessItem = activeGrid.ContentChess; chessItem.transform.position = grid.transform.position; activeGrid.ContentChess = null; grid.ContentChess = chessItem; // 寻找途中有无棋子 有且不同队可以扣血 Direction direction = saveGrid[grid]; GridControl gridTmp = activeGrid.neighbors[(int)direction]; bool jumped = false; while (gridTmp != grid) { jumped = true; if (gridTmp.CheckChess()) { if (!gridTmp.ContentChess.CompareTeam(chessItem.GetTeam())) { gridTmp.ContentChess.ReduceHP(); } } gridTmp = gridTmp.neighbors[(int)direction]; } if (jumped) { saveGrid = grid.RepeatedJump(activeGrid); } activeGrid = grid; return(jumped); }
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>()); }
public TwoBattleChessView() : base() { this._control = new TwoBattleChessControl(this.Chessboard); }