コード例 #1
0
ファイル: rAttacker.py プロジェクト: anorth/runswift-2005
def doKickWithoutGrab():
    global gIsKickTriggering

    kickType, dkd, _ = gSelectedKick

    r = Constant.STATE_EXECUTING

    if kickType == sSelKick.KT_PAW_KICK:
        r = sPawKick.perform()

    elif kickType == sSelKick.KT_DRIBBLE:
        r = sDribble.perform(dkd)

    elif kickType == sSelKick.KT_UPENN_LEFT:

        #print "non-grab upenn left"

        if gIsKickTriggering\
            or (hPWalk.isStepComplete() and sUpennKick.isUpennLeftOk()):
            gIsKickTriggering = True
            r = sUpennKick.perform(dkd, True)
        else:
            doTrackBall()

    elif kickType == sSelKick.KT_UPENN_RIGHT:

        #print "non-grab upenn right"

        if gIsKickTriggering\
            or (hPWalk.isStepComplete() and sUpennKick.isUpennRightOk()):
            gIsKickTriggering = True
            r = sUpennKick.perform(dkd, False)
        else:
            doTrackBall()

    elif kickType == sSelKick.KT_AVOID_OWN_GOAL:
        r = sAvoidOwnGoal.perform()

    # else paw kick through
    else:
        r = sPawKick.perform()

    return r
コード例 #2
0
ファイル: rSetPlay.py プロジェクト: anorth/runswift-2005
def kickOffUPenn():
    global playCounter, whenGrabbed

    if pReady.chosenFormation == 0:
        kickLeft = False
    else:
        kickLeft = True

    if pReady.isCentre(Global.kickOffPos):
        if playCounter > 150:
            return False

        if whenGrabbed == 0:
            print "grabbing"
            if sGrab.perform() == Constant.STATE_FAILED:
                return False
            if sGrab.isGrabbed:
                whenGrabbed = playCounter
            return True

        print "Grabbed!"
        if sUpennKick.perform(kickLeft) == Constant.STATE_SUCCESS:
            sGrab.resetPerform()
            return False

        sFindBall.perform(True)
        return True

    elif pReady.isForward(Global.kickOffPos):
        if playCounter > 40:
            return False
        hTrack.saGoToTarget(Constant.TARGET_GOAL_X, Constant.TARGET_GOAL_Y)
        hFWHead.DecideNextAction()
    else:
        return False

    return True
コード例 #3
0
def doKickWithGrab():
    global gSelectedKick
    global gIsKickTriggering

    if not sGrab.isGrabbed:

        r = sGrab.perform()
        if r == Constant.STATE_FAILED:
            hTrack.panLow = True
            return r
        elif r == Constant.STATE_EXECUTING:
            return r
        # Grab success
        else:
            # override kick selection
            selectedKick = sSelKick.perform()

            # If the selected kick is different, then do kick reset.
            if gSelectedKick != None and selectedKick[0] != gSelectedKick[0]:
                doKickReset()
            gSelectedKick = selectedKick

            # If kick selection returns paw kick, change it to
            # grab dribble.
            # Because we can't paw kick or dribble from grab.
            kickType = gSelectedKick[0]
            if kickType == sSelKick.KT_DRIBBLE\
                or kickType == sSelKick.KT_PAW_KICK:
                gSelectedKick = (sSelKick.KT_GRAB_DRIBBLE, gSelectedKick[1],
                                 gSelectedKick[2])

            gIsKickTriggering = True

    r = Constant.STATE_EXECUTING

    if gIsKickTriggering:

        kickType, dkd, direction = gSelectedKick

        # Setting isClockwise
        isClockwise = None
        if direction == Constant.dCLOCKWISE:
            isClockwise = True
        elif direction == Constant.dANTICLOCKWISE:
            isClockwise = False

        if kickType == sSelKick.KT_GRAB_TURN_KICK:
            r = sGrabTurnKick.perform(False,\
                                      Action.DiveKickWT,\
                                      Constant.TARGET_GOAL_X,\
                                      Constant.FIELD_LENGTH)

        elif kickType == sSelKick.KT_GRAB_TURN_SHOOT:
            r = sGrabTurnKick.perform()

        elif kickType == sSelKick.KT_GRAB_DRIBBLE_GOAL:
            r = sGrabDribble.performToTargetGoal()

        elif kickType == sSelKick.KT_GRAB_DRIBBLE:
            r = sGrabDribble.performToDKD(dkd)

        elif kickType == sSelKick.KT_TURN_KICK:
            r = sTurnKick.perform(dkd, isClockwise=isClockwise)

        elif kickType == sSelKick.KT_UPENN_LEFT:
            #print "grab upeen left"
            r = sUpennKick.perform(dkd, True)

        elif kickType == sSelKick.KT_UPENN_RIGHT:
            #print "grab upeen right"
            r = sUpennKick.perform(dkd, False)

        else:
            print "rAttacker.py : No appropriate kick for grab chosen???"
            r = Constant.STATE_FAILED

    return r
コード例 #4
0
ファイル: rAttacker.py プロジェクト: anorth/runswift-2005
def doKickWithGrab():
    global gSelectedKick

    if not sGrab.isGrabbed:
        # If the ball is in the edge, do more get behind.
        if hWhere.ballOnEdge():
            r = sGrab.perform(sFindBall.GET_BEHIND_PRIORITY)
        else:
            r = sGrab.perform()

        if r == Constant.STATE_FAILED:
            hTrack.panLow = True
            return r
        elif r == Constant.STATE_EXECUTING:
            return r
        # Grab success
        else:
            # override kick selection
            selectedKick = sSelKick.perform()
            #print "kick reselected"
            # If the selected kick is different, then do kick reset.
            if gSelectedKick != None and selectedKick[0] != gSelectedKick[0]:
                doKickReset()
            gSelectedKick = selectedKick

            # If kick selection returns paw kick, change it to
            # grab dribble.
            # Because we can't paw kick or dribble from grab.
            kickType = gSelectedKick[0]
            if kickType == sSelKick.KT_DRIBBLE\
                or kickType == sSelKick.KT_PAW_KICK\
                or kickType == sSelKick.KT_AVOID_OWN_GOAL:
                gSelectedKick = (sSelKick.KT_GRAB_DRIBBLE, gSelectedKick[1],
                                 gSelectedKick[2])

    r = Constant.STATE_EXECUTING

    if sGrab.isGrabbed:

        if not sGrab.isBallUnderChin():
            return Constant.STATE_FAILED

        kickType, dkd, direction = gSelectedKick

        # Find a global co-ordinate on the dkd
        tx, ty = hMath.getPointRelative(Global.ballX, Global.ballY, dkd, 200)

        # Setting isClockwise
        isClockwise = None
        if direction == Constant.dCLOCKWISE:
            isClockwise = True
        elif direction == Constant.dANTICLOCKWISE:
            isClockwise = False

        if kickType == sSelKick.KT_GRAB_TURN_KICK:
            r = sGrabTurnKick.perform(False, Action.HeadTapWT, tx, ty)
            #r = sGrabDribble.performToDKD(dkd, 0)

        elif kickType == sSelKick.KT_GRAB_TURN_SHOOT:
            r = sGrabTurnKick.perform()

        elif kickType == sSelKick.KT_GRAB_DRIBBLE_GOAL:
            r = sGrabDribble.performToTargetGoal()

        elif kickType == sSelKick.KT_GRAB_DRIBBLE_STOP:
            r = sGrabDribble.performToDKD(dkd,
                                          minTimeToDribble=2500,
                                          dontKick=True)

        elif kickType == sSelKick.KT_GRAB_DRIBBLE:
            r = sGrabDribble.performToDKD(dkd)

        elif kickType == sSelKick.KT_TURN_KICK:
            r = sTurnKick.perform(dkd, isClockwise=isClockwise)

        elif kickType == sSelKick.KT_UPENN_LEFT:
            #print "grab upeen left"
            r = sUpennKick.perform(dkd, True)

        elif kickType == sSelKick.KT_UPENN_RIGHT:
            #print "grab upeen right"
            r = sUpennKick.perform(dkd, False)

        else:
            print "rAttacker.py : No appropriate kick for grab chosen??? ", kickType
            r = Constant.STATE_FAILED

    return r