Robert had put a double seige on the castle. That meant that the ones outside will have to stay outside and the ones inside were trapped inside.
And with this he was successful in trapping both, the former and current kings of Aartals inside. His terms and conditions were ready and his force was strong since the soldiers of Aartals didn't even get time to get ready for combat.
But the thing that made him shock at the time he least expected was that Gwen knew for a long time that he was from Jidir and that he is the Crown prince of the kingdom. Although he was caught off guard due to this, he had to go back to doing hi own job before the soldiers of Aartals figure out their plans and kill all the Jidir soldiers.
Count York had took his position on the nearby mountain hill from where he could clearly see the defenses and also the seiged castle.