public void OnAttackChess(int attackChess, int beAttackChess) { InputManager.ClearSelectChess(); ChessEntity attack = ChessManager.FindEntityByID(attackChess); ChessEntity beAttack = ChessManager.FindEntityByID(beAttackChess); if (attack == null || beAttack == null) { return; } Vector3 selfPos = attack.transform.localPosition; Vector3 beAttackpos = new Vector3(ChessEntity.ChessInterval * (int)beAttack.chessObj.chess_index_x, 0, ChessEntity.ChessInterval * (int)beAttack.chessObj.chess_index_z); // 刚开始不能直接移动到要攻击的棋子旁边 Vector3 pos = (beAttackpos - selfPos).normalized; pos *= Vector3.Distance(beAttackpos, selfPos) - ChessEntity.ChessInterval; pos += selfPos; attack.MoveTo(pos); // 开始释放技能 attack.Target = beAttack; beAttack.Target = attack; attack.UseNormalSkill(); currentAttackChess = attack; fightMainUIPanel.SetStateInfoString("战斗中..."); }