Пример #1
0
def walkState(self):
	# get forward force
	forward_force = self.getForwardForce()
	speedAnim = 1.0#abs(self.gamepad.getJoyAxis1Value())

	if (self.tester.detectLadderBottom()):
		start_ladderFromTop(self)
		return

	# If detect enemy damage
	if (self.tester.detectEnemyDamage()):
		start_hitState(self)
		return

	# If detect water
	if (self.tester.detectWater()):
		# stop orientation
		self.orientManager.stopOrientation(self)
		# start swim state
		start_swimState(self)
	# else we can move or wait
	elif ( self.respectGroundRule(end_walkState(self)) ):
		if (self.tester.switchLevel()):
			# cancel state
			return
		# if arrow key is pressed
		if (forward_force != 0.0):
			# use walk movement
			if walkForce(self, forward_force):
				# stop orientation
				self.orientManager.stopOrientation(self)
				# go to idle state
				self.switchState(PlayerState.RUN_STATE)
			else:
				# play walk animation
				self.rig.playWalk(speedAnim)
				# play step sound
				self.audio.playStepSound(self.rig.getActionFrame(1), [4, 13])
				# active orientation movement
				self.orientManager.orient_player(self)
		else:
			# stop orientation
			self.orientManager.stopOrientation(self)
			# go to idle state
			self.switchState(PlayerState.IDLE_STATE)
	# go to fall
	else:
		# go to fall state
		start_fallState(self)
Пример #2
0
def walkState(self):
    # get forward force
    forward_force = self.getForwardForce()
    speedAnim = 1.0  #abs(self.gamepad.getJoyAxis1Value())

    if (self.tester.detectLadderBottom()):
        start_ladderFromTop(self)
        return

    # If detect enemy damage
    if (self.tester.detectEnemyDamage()):
        start_hitState(self)
        return

    # If detect water
    if (self.tester.detectWater()):
        # stop orientation
        self.orientManager.stopOrientation(self)
        # start swim state
        start_swimState(self)
    # else we can move or wait
    elif (self.respectGroundRule(end_walkState(self))):
        if (self.tester.switchLevel()):
            # cancel state
            return
        # if arrow key is pressed
        if (forward_force != 0.0):
            # use walk movement
            if walkForce(self, forward_force):
                # stop orientation
                self.orientManager.stopOrientation(self)
                # go to idle state
                self.switchState(PlayerState.RUN_STATE)
            else:
                # play walk animation
                self.rig.playWalk(speedAnim)
                # play step sound
                self.audio.playStepSound(self.rig.getActionFrame(1), [4, 13])
                # active orientation movement
                self.orientManager.orient_player(self)
        else:
            # stop orientation
            self.orientManager.stopOrientation(self)
            # go to idle state
            self.switchState(PlayerState.IDLE_STATE)
    # go to fall
    else:
        # go to fall state
        start_fallState(self)
Пример #3
0
def fallState(self):
	# If detect water
	if (self.tester.detectWater()):
		# reset
		self.fallTime = 0.0
		# stop orientation
		self.orientManager.stopOrientation(self)
		# start water
		start_swimState(self)
		# cancel method
		return

	# If detect black hole
	if (self.tester.detectBlackHole() ):
		respawnToGround(self)
		return

	# if touch the ground
	ground, point, normal = self.tester.groundRay()
	if (ground and self.fallTime > 0.3):
		print("touch the ground")
		# set grounded
		self.grounded = True
		# reset fall time
		self.fallTime = 0.0
		# go to land state
		self.switchState(PlayerState.LAND_STATE)
	else:
		# if detect the ledge and ledgeCanceled not true
		if (self.tester.detectLedge() and not self.ledgeCanceled):
			# do ledge
			self.fallTime = 0.0
			# go to ledge state
			#start_beginGrapLedgeState(self)
			self.switchState(PlayerState.START_GRAPLEDGE_STATE)
		else:
			# pla yfall anim
			self.rig.playFallDown()
			# fall control
			fallControl(self)
			# incrmeent tim
			self.fallTime += 0.1
Пример #4
0
def fallState(self):
    # If detect water
    if (self.tester.detectWater()):
        # reset
        self.fallTime = 0.0
        # stop orientation
        self.orientManager.stopOrientation(self)
        # start water
        start_swimState(self)
        # cancel method
        return

    # if touch the ground
    ground, point, normal = self.tester.groundRay()
    if (ground and self.fallTime > 0.3):
        # set grounded
        self.grounded = True
        # reset fall time
        self.fallTime = 0.0
        # go to land state
        # play land
        self.rig.playLowLand()
        self.switchState(PlayerState.LAND_STATE)
    else:
        # if detect the ledge and ledgeCanceled not true
        if (self.tester.detectLedge() and not self.ledgeCanceled):
            # do ledge
            self.fallTime = 0.0
            # go to ledge state
            start_beginGrapLedgeState(self)
        else:
            if (self.linearVelocity[2] < 0.0):
                # play fall anim
                self.rig.playFallDown()
            # fall control
            fallControl(self)
            # incrmeent tim
            self.fallTime += 0.1
Пример #5
0
def fallState(self):
	# If detect water
	if (self.tester.detectWater()):
		# reset
		self.fallTime = 0.0
		# stop orientation
		self.orientManager.stopOrientation(self)
		# start water
		start_swimState(self)
		# cancel method
		return

	# if touch the ground
	ground, point, normal = self.tester.groundRay()
	if (ground and self.fallTime > 0.3):
		# set grounded
		self.grounded = True
		# reset fall time
		self.fallTime = 0.0
		# go to land state
		# play land
		self.rig.playLowLand()
		self.switchState(PlayerState.LAND_STATE)
	else:
		# if detect the ledge and ledgeCanceled not true
		if (self.tester.detectLedge() and not self.ledgeCanceled):
			# do ledge
			self.fallTime = 0.0
			# go to ledge state
			start_beginGrapLedgeState(self)
		else:
			if (self.linearVelocity[2] < 0.0):
				# play fall anim
				self.rig.playFallDown()
			# fall control
			fallControl(self)
			# incrmeent tim
			self.fallTime += 0.1
Пример #6
0
def rollState(self):
	# If detect enemy damage
	if (self.tester.detectEnemyDamage()):
		start_hitState(self)
		return

	# If detect water
	if (self.tester.detectWater()):
		# stop orientation
		self.orientManager.stopOrientation(self)
		# go to swim
		start_swimState(self)
	else:
		# if detect always the ground continue the rolling
		if (self.respectGroundRule(goToJump)):
			wall, pos, normal = self.tester.wallRay()
			if (wall):
				start_rollWall(self)
				self.switchState(PlayerState.ROLLWALL_STATE)
			else:
				# test if finish rolling
				if (self.rig.getActionFrame(1) == 11):
					# change state
					self.switchState(PlayerState.IDLE_STATE)
Пример #7
0
def rollState(self):
	# If detect enemy damage
	if (self.tester.detectEnemyDamage()):
		start_hitState(self)
		return

	# If detect water
	if (self.tester.detectWater()):
		# stop orientation
		self.orientManager.stopOrientation(self)
		# go to swim
		start_swimState(self)
	else:
		# if detect always the ground continue the rolling
		if (self.respectGroundRule(goToJump, False)):
			wall, pos, normal = self.tester.wallRay()
			if (wall):
				start_rollWall(self)
				self.switchState(PlayerState.ROLLWALL_STATE)
			else:
				# test if finish rolling
				if (self.rig.getActionFrame(1) == 11):
					# change state
					self.switchState(PlayerState.IDLE_STATE)
Пример #8
0
def runState(self):
	#playerHUD = logic.playerHUD
	# get forward force
	forward_force = self.getForwardForce()

	# If detect enemy damage
	if (self.tester.detectEnemyDamage()):
		start_hitState(self)
		return

	# If detect water
	if (self.tester.detectWater()):
		# stop orientation
		self.orientManager.stopOrientation(self)
		# start swim state
		start_swimState(self)
		# cancel method
	else:
		# if touch the ground ( else callback )
		if ( self.respectGroundRule(end_runState) ):
			# if arrow key is pressed
			if ( forward_force != 0.0 ):
				# set action hud text
				#logic.playerHUD.changeActionText('Roll')
				if (self.tester.detectPath()):
				 	start_pathFollowState(self)
				# if push to action key
				elif (self.gamepad.isActionPressed()):
				# NEXT STATE : ROLL
					# stop orientation
					self.orientManager.stopOrientation(self)
					# start roll
					start_rollState(self)
					# switch roll state
					self.switchState(PlayerState.ROLL_STATE)
				else:
					# run force
					if ( runForce(self, forward_force) ):
						# play run animation
						self.rig.playRun()
						frame = self.rig.getActionFrame(1)
						#if (frame <= 1):
							# PlayerEffect.addEffectFrame(frame, [4, 11], PlayerEffect.addGrassEffect())
						# play with step sounds
						self.audio.playStepSound(frame, [4, 11])
					else:
						# go to walk
						self.switchState(PlayerState.WALK_STATE)
					# active orientation movement
					self.orientManager.orient_player(self)
			# else not movement go idle state
			else:
				# reset hud action text
				#logic.playerHUD.resetActionText()
				# stop orientation
				self.rig.stopArmLayer()
				self.orientManager.stopOrientation(self)
				# go to idle state
				self.switchState(PlayerState.IDLE_STATE)
		# if dont touch the ground go to jump state
		else:
			# reset hud action text
			#logic.playerHUD.resetActionText()
			# stop orientation
			self.orientManager.stopOrientation(self)
			# go to idle state
			self.switchState(PlayerState.JUMP_STATE)
Пример #9
0
def runState(self):
	#playerHUD = logic.playerHUD
	# get forward force
	forward_force = self.getForwardForce()

	# If detect enemy damage
	if (self.tester.detectEnemyDamage()):
		start_hitState(self)
		return

	# If detect water
	if (self.tester.detectWater()):
		# stop orientation
		self.orientManager.stopOrientation(self)
		# start swim state
		start_swimState(self)
		# cancel method
	else:
		# if touch the ground ( else callback )
		if ( self.respectGroundRule(end_runState) ):
			# if detect next-level
			if (self.tester.switchLevel()):
				# End run state
				end_runState(self)
				# cancel state
				return
			# if arrow key is pressed
			elif ( forward_force != 0.0 ):
				# set action hud text
				#logic.playerHUD.changeActionText('Roll')
				# if push to action key
				if (self.gamepad.isActionPressed()):
				# NEXT STATE : ROLL
					# stop orientation
					self.orientManager.stopOrientation(self)
					# start roll
					start_rollState(self)
					# switch roll state
					self.switchState(PlayerState.ROLL_STATE)
				else:
					# run force
					if ( runForce(self, forward_force) ):
						# play run animation
						self.rig.playRun()
						# Arm Hunk Animation
						if (self.armed):
							# Run with sword and shield arm
							self.rig.playRunArmArmed()
						else:
							self.rig.playRunArmBase()
						# play with step sounds
						self.audio.playStepSound(self.rig.getActionFrame(1), [4, 11])
					else:
						# go to walk
						self.switchState(PlayerState.WALK_STATE)
					# active orientation movement
					self.orientManager.orient_player(self)
			# else not movement go idle state
			else:
				# reset hud action text
				#logic.playerHUD.resetActionText()
				# stop orientation
				self.rig.stopArmLayer()
				self.orientManager.stopOrientation(self)
				# go to idle state
				self.switchState(PlayerState.IDLE_STATE)
		# if dont touch the ground go to jump state
		else:
			# reset hud action text
			#logic.playerHUD.resetActionText()
			# stop orientation
			self.orientManager.stopOrientation(self)
			# go to idle state
			self.switchState(PlayerState.JUMP_STATE)
Пример #10
0
def runState(self):
    #playerHUD = logic.playerHUD
    # get forward force
    forward_force = self.getForwardForce()

    # If detect enemy damage
    if (self.tester.detectEnemyDamage()):
        start_hitState(self)
        return

    # If detect water
    if (self.tester.detectWater()):
        # stop orientation
        self.orientManager.stopOrientation(self)
        # start swim state
        start_swimState(self)
        # cancel method
    else:
        # if touch the ground ( else callback )
        if (self.respectGroundRule(end_runState)):
            # if arrow key is pressed
            if (forward_force != 0.0):
                # set action hud text
                #logic.playerHUD.changeActionText('Roll')
                if (self.tester.detectPath()):
                    start_pathFollowState(self)
                # if push to action key
                elif (self.gamepad.isActionPressed()):
                    # NEXT STATE : ROLL
                    # stop orientation
                    self.orientManager.stopOrientation(self)
                    # start roll
                    start_rollState(self)
                    # switch roll state
                    self.switchState(PlayerState.ROLL_STATE)
                else:
                    # run force
                    if (runForce(self, forward_force)):
                        # play run animation
                        self.rig.playRun()
                        frame = self.rig.getActionFrame(1)
                        #if (frame <= 1):
                        # PlayerEffect.addEffectFrame(frame, [4, 11], PlayerEffect.addGrassEffect())
                        # play with step sounds
                        self.audio.playStepSound(frame, [4, 11])
                    else:
                        # go to walk
                        self.switchState(PlayerState.WALK_STATE)
                    # active orientation movement
                    self.orientManager.orient_player(self)
            # else not movement go idle state
            else:
                # reset hud action text
                #logic.playerHUD.resetActionText()
                # stop orientation
                self.rig.stopArmLayer()
                self.orientManager.stopOrientation(self)
                # go to idle state
                self.switchState(PlayerState.IDLE_STATE)
        # if dont touch the ground go to jump state
        else:
            # reset hud action text
            #logic.playerHUD.resetActionText()
            # stop orientation
            self.orientManager.stopOrientation(self)
            # go to idle state
            self.switchState(PlayerState.JUMP_STATE)