コード例 #1
0
	def attack(self):
		(x, y, dx, dy) = self.get_coords()
		Cannon.ATTACK_WAV.play()

		# 78은 Obstacle_Stone의 너비(w)
		bullet = Obstacle("Obstacle_Bullet", x, y, 27, 19, dx, dy)
		GameWorld.add(GameWorld.layer.obstacle, bullet, 5)
コード例 #2
0
 def SetupComponent(self, entity, component):
     """
     Gets called once all components have been registered.
     Use this to setup stuff which references other components
     """
     movsvc.MovementService.SetupComponent(self, entity, component)
     gw = self.gameWorldClient.GetGameWorld(component.sceneID)
     positionComponent = entity.GetComponent('position')
     if entity.entityID == session.charid:
         remoteNodeID = self.LookupWorldSpaceNodeID(entity.scene.sceneID)
         if remoteNodeID is None:
             remoteNodeID = -1
         component.moveModeManager = GameWorld.MoveModeManager(
             entity.entityID, component.sceneID,
             const.movement.AVATARTYPE_CLIENT_LOCALPLAYER,
             component.moveState, positionComponent,
             component.physics, component.characterController,
             GameWorld.PlayerInputMode(), remoteNodeID)
     else:
         component.moveModeManager = GameWorld.MoveModeManager(
             entity.entityID, component.sceneID,
             const.movement.AVATARTYPE_CLIENT_NPC, component.moveState,
             positionComponent,
             component.physics, component.characterController,
             GameWorld.ClientRemoteMode(), -1)
     component.InitializeCharacterControllerRefs(positionComponent)
     sm.GetService('navigation')
コード例 #3
0
 def __init__(self):
     treeManager = GameWorld.DecisionTreeManager()
     treeManager.Initialize()
     zaction.zactionCommon.__init__(self, treeManager)
     GameWorld.RegisterPythonActionProc(
         'ForceDecisionTreeToRoot',
         decisionProcs.ForceDecisionTreeToRootFunc, ('ENTID', ))
コード例 #4
0
ファイル: entityProcs.py プロジェクト: connoryang/1v1dec
 def _GetBonePosRot(self, ENTID, boneName, posProp, rotProp):
     entity = self.entityService.FindEntityByID(ENTID)
     if entity is None:
         self.LogError('GetBonePosRot: Entity with ID ', ENTID,
                       ' not found!')
         return False
     animClient = entity.GetComponent('animation')
     posComp = entity.GetComponent('position')
     if animClient is not None and posComp is not None:
         if animClient.controller is not None:
             boneTransform = animClient.controller.animationNetwork.GetBoneTransform(
                 boneName)
             if boneTransform:
                 translation, orientation = boneTransform
                 translation = geo2.QuaternionTransformVector(
                     posComp.rotation, translation)
                 translation = geo2.Vec3Add(posComp.position, translation)
                 orientation = geo2.QuaternionMultiply(
                     posComp.rotation, orientation)
                 translation = list(translation)
                 orientation = list(orientation)
                 GameWorld.AddPropertyForCurrentPythonProc(
                     {posProp: translation})
                 GameWorld.AddPropertyForCurrentPythonProc(
                     {rotProp: orientation})
                 return True
     self.LogError('GetBonePosRot: Missing critical data in entity!')
     return False
コード例 #5
0
 def Run(self, *args):
     service.Service.Run(self, *args)
     GameWorld.RegisterPythonActionProc('PerformPythonUICallback', self._PerformUICallback, ('callbackKey',))
     GameWorld.RegisterPythonActionProc('PlayEntityAudio', self._PlayEntityAudio, ('audioName', 'mls', 'TargetList'))
     GameWorld.RegisterPythonActionProc('PlayTutorialVoiceover', self._PlayTutorialVoiceOver, ('messageKey',))
     GameWorld.RegisterPythonActionProc('PushCameraWithTransition', self._PushCameraWithTransition, ('cameraName', 'behaviorNames', 'transitionSeconds', 'startHeight', 'TargetList'))
     GameWorld.RegisterPythonActionProc('PopCameraWithTransition', self._PopCameraWithTransition, ('transitionSeconds', 'retainYaw', 'retainPitch'))
コード例 #6
0
    def update(self):
        (mario_x, _) = self.mario.pos

        if (mario_x > 100 and self.state == Plant.IDLE):
            Plant.ATTACK_COUNT += Plant.FPS * GameFramework.delta_time

            if (Plant.ATTACK_COUNT >= 5):
                if (self.fidx == 0):
                    Plant.ATTACK_COUNT = 0
                    self.state = Plant.ATTACK

        if (self.state == Plant.ATTACK
                and self.fidx == len(Plant.IMAGE_RECT[self.state]) - 1):
            self.attack(mario_x)
            self.state = Plant.IDLE
        elif (self.state == Plant.DIE):
            (x, y) = self.pos
            dy = -1

            y += dy * Plant.FALLING_PPS * GameFramework.delta_time
            h = Plant.IMAGE_RECT[self.state][self.fidx][3] // 2

            self.pos = (x, y)

            if (y < -h):
                GameWorld.remove(self)
コード例 #7
0
def init():
    config=ConfigParser.RawConfigParser()
    config.read('settings.cfg')
    if not config.has_section('settings'):
        config.add_section('settings')
        config.set('settings','width',800)
        config.set('settings','height',600)
        config.set('settings','volume',100)
        config.set('settings','music',50)
        config.set('settings','difficulty',1)
    if not config.has_option('settings','width'):
        config.set('settings','width',800)
    if not config.has_option('settings','height'):
        config.set('settings','height',600)
    if not config.has_option('settings','volume'):
        config.set('settings','volume',100)
    if not config.has_option('settings','music'):
        config.set('settings','music',50)
    if not config.has_option('settings','difficulty'):
        config.set('settings','difficulty',1)
    pygame.mixer.pre_init()
    pygame.init()
    pygame.RESIZABLE = False
    pygame.NOFRAME = False
    screen = pygame.display.set_mode([config.getint('settings','width'), config.getint('settings','height')],pygame.FULLSCREEN|pygame.HWSURFACE)
    Settings.screen_width=config.getint('settings','width')
    Settings.screen_height=config.getint('settings','height')
    Settings.game_difficulty=config.getint('settings','difficulty')
    world=GameWorld(screen)
    world.setSound(config.getint('settings','volume')/100.0)
    f=open('settings.cfg','w')
    config.write(f)
    f.close()
    return (screen,world)
コード例 #8
0
def draw():
	GameWorld.draw()
	GameObject.draw_collision_box()

	font.draw(95, get_canvas_height() - 60, "X %d" % TOTAL_COIN_COUNT, FONT_COLOR)

	if (state == STATE_GAME_OVER):
		game_over_image.draw(400, 300, get_canvas_width(), get_canvas_height())
コード例 #9
0
	def attack(self):
		(x, y, dx, dy) = self.get_coords()
		if (x < 100): return
		Plant.ATTACK_WAV.play()

		# 78은 Obstacle_Stone의 너비(w)
		stone = Obstacle("Obstacle_Stone", x, y, 78, 58, dx, dy)
		GameWorld.add(GameWorld.layer.obstacle, stone, 4)
コード例 #10
0
 def ToggleFlyMode(self):
     myMovement = self.entityService.GetPlayerEntity().GetComponent('movement')
     myMovement.IsFlyMode = not myMovement.IsFlyMode
     if myMovement.IsFlyMode:
         my_mode = GameWorld.FlyMode()
         my_mode.velocity = (0.0, 0.01, 0.0)
     else:
         my_mode = GameWorld.PlayerInputMode()
     myMovement.moveModeManager.PushMoveMode(my_mode)
コード例 #11
0
def exit():
    Image.unload("Image/Title.png")
    Image.unload("IMAGE/TitleMenu.png")
    GameWorld.clear()

    global bgm

    bgm.stop()
    del bgm
コード例 #12
0
 def __init__(self, entitySceneID, dynamicSpawnID, recipeTypeID, posProp,
              rotProp):
     """
     Action procs are only slightly different than RuntimeSpawner's
     Specifically, the pos/rot needs to be unpacked first.
     """
     position = GameWorld.GetPropertyForCurrentPythonProc(posProp)
     rotation = GameWorld.GetPropertyForCurrentPythonProc(rotProp)
     RuntimeSpawner.__init__(self, entitySceneID, dynamicSpawnID,
                             recipeTypeID, position, rotation)
コード例 #13
0
    def attack(self, mario_x):
        # Obstacle_Stone의 너비와 높이
        (w, h) = (78, 58)
        (x, y) = (mario_x, get_canvas_height() + h)
        (dx, dy) = (0, -1)

        Plant.ATTACK_WAV.play()

        stone = StoneObstacle("Obstacle_Stone", x, y, w, h, dx, dy)
        GameWorld.add(GameWorld.layer.obstacle, stone, 4)
コード例 #14
0
    def attack(self):
        # Obstacle_Bullet의 너비와 높이
        (w, h) = (27, 19)
        (x, y) = self.pos
        (dx, dy) = (-1, 0)
        x -= 30

        Cannon.ATTACK_WAV.play()

        bullet = BulletObstacle("Obstacle_Bullet", x, y, w, h, dx, dy)
        GameWorld.add(GameWorld.layer.obstacle, bullet, 5)
コード例 #15
0
    def update(self):
        (x, y) = self.pos
        (w, h) = self.size

        x += self.dx * Obstacle.FALLING_PPS * GameFramework.delta_time
        y += self.dy * Obstacle.FALLING_PPS * GameFramework.delta_time

        self.pos = (x, y)

        if (x < -w):
            GameWorld.remove(self)
コード例 #16
0
def update():
	global TOTAL_COIN_COUNT
	global state

	if (state == STATE_GAME_OVER): return
	if (TOTAL_COIN_COUNT == 0): GameSprite.Door.open_door()

	GameWorld.update()
	check_collision()
	change_stage()

	if (ui.dead()): end_game()
コード例 #17
0
ファイル: GameScreen.py プロジェクト: gquittet/SenseSnake
 def __init__(self, sense):
     """
     Initialize the main game screen
     :param sense The sense hat
     """
     # Initialize the game world
     self.gameWorld = GameWorld(sense)
     # Initialize the game renderer
     self.gameRenderer = GameRenderer(self.gameWorld)
     # Initialize the input handler
     self.inputHandler = InputHandler(self.gameWorld)
     self.sense = sense
コード例 #18
0
    def Run(self, *etc):
        service.Service.Run(self, *etc)
        self.entitySceneManager = GameWorld.GetEntitySceneManagerSingleton()
        self.sceneManager = GameWorld.GetSceneManagerSingleton()
        calls = []
        for entitySystem in set(self.__entitysystems__):
            calls.append((self.SetupEntitySystem, (entitySystem, )))

        try:
            uthread.parallel(calls)
        except:
            log.LogException()
コード例 #19
0
 def Run(self, *etc):
     service.Service.Run(self, *etc)
     uthread.new(self._UpdateTasklet).context = 'particleEffectClient::Run'
     procArgs = ('ENTID', 'redFile', 'boneName', 'duration', 'xOffset',
                 'yOffset', 'zOffset', 'yawOffset', 'pitchOffset',
                 'rollOffset', 'ignoreTransform', 'effectIDProp')
     GameWorld.RegisterPythonActionProc('ApplyParticleEffect',
                                        self.ApplyParticleEffect, procArgs,
                                        True)
     GameWorld.RegisterPythonActionProc('RemoveParticleEffect',
                                        self.RemoveParticleEffectProc,
                                        ('effectIDProp', ))
コード例 #20
0
ファイル: entityProcs.py プロジェクト: connoryang/1v1dec
 def Run(self, *args):
     service.Service.Run(self, *args)
     GameWorld.RegisterPythonActionProc(
         'SetEntityPosition', self._SetEntityPosition,
         ('ENTID', 'ALIGN_POSITION', 'ALIGN_ROTATION', 'MotionState'))
     GameWorld.RegisterPythonActionProc('GetEntitySceneID',
                                        self._GetEntitySceneID, ('ENTID', ))
     GameWorld.RegisterPythonActionProc(
         'GetBonePosRot', self._GetBonePosRot,
         ('ENTID', 'boneName', 'posProp', 'rotProp'))
     GameWorld.RegisterPythonActionProc('AllowPlayerMoveControl',
                                        self._AllowPlayerMoveControl,
                                        ('inControl', ))
コード例 #21
0
def exit():
	global bgm, start_wav, coin_wav, plant_dead_wav

	Image.unload("IMAGE/Mario.png")
	Image.unload("IMAGE/Sprite.png")
	Image.unload("IMAGE/Background.png")
	Font.unload("FONT/koverwatch.ttf", 25)
	GameWorld.clear()

	bgm.stop()
	del bgm
	del start_wav
	del coin_wav
	del plant_dead_wav
コード例 #22
0
	def update(self):
		(x, y) = self.pos
		(w, h) = self.size
		
		x += self.dx * Obstacle.FALLING_PPS * GameFramework.delta_time
		y += self.dy * Obstacle.FALLING_PPS * GameFramework.delta_time
		
		self.pos = (x, y)
		
		if ("Stone" in self.name):
			if (y < -h):
				GameWorld.remove(self)
		elif ("Bullet" in self.name):
			if (x < -w):
				GameWorld.remove(self)
コード例 #23
0
ファイル: zactionClient.py プロジェクト: connoryang/1v1dec
 def PrepareComponent(self, sceneID, entityID, component):
     if not self.actionTickManager:
         self.LogError(
             'ActionTickManager was not present at zaction prepare component, things will now crash'
         )
     if component.treeInstance is None:
         if self.entityService.IsClientSideOnly(sceneID):
             component.treeInstance = GameWorld.ActionTreeInstance(
                 entityID, component.TreeInstanceID)
         else:
             component.treeInstance = GameWorld.ActionTreeInstanceClient(
                 entityID, component.TreeInstanceID)
     component.rootNode = self.treeManager.GetTreeNodeByID(component.rootID)
     self.entityService.entitySceneManager.PrepareComponent(
         entityID, sceneID, component.treeInstance)
コード例 #24
0
    def Run(self, *etc):
        service.Service.Run(self, *etc)
        self.SEPERATOR = ' - '
        self.DEFAULT_COMBO_OPTION = 'All'
        self.INVALID_VALUE_DEFAULT = '0'
        self.combatLog = []
        self.combatLogEntityList = [(self.DEFAULT_COMBO_OPTION,
                                     self.DEFAULT_COMBO_OPTION)]
        self.combatLogCategoryList = [(self.DEFAULT_COMBO_OPTION,
                                       self.DEFAULT_COMBO_OPTION)]
        self.comboElementVersion = 0
        self.lineNumber = 0
        self.idToNameDict = {}
        self.entityIdentifierDict = {}
        self.attributeIdentifierDict = {}

        def _GetServices():
            if boot.role == 'client':
                self.entitySvc = sm.GetService('entityClient')
            else:
                self.entitySvc = sm.GetService('entityServer')

        uthread.new(_GetServices)
        self.RegisterIdentifierCallback('property', self._GetPropertyString)
        GameWorld.RegisterPythonActionProc(
            'CombatLog', self.DoCombatLogLine,
            ('ENTID', 'ChatString', 'LogCategory'))
コード例 #25
0
    def CreateComponent(self, name, state):
        """
        Initializes the component with the provided state dict.
        If the dict is not provided you will still need to set the
        position, rotation and worldspaceID attributes explicitly in
        order for the component to behave correctly.
        
        The structure of the state dict should be as followed:
        "position" - position, 3 tuple describing (x,y,z)
        "rotation" - rotation, 4 tuple describing the rotation quaternion.
                     NOTE: Optionally, you can pass in a 3-tuple for
                           yaw/pitch/roll and this will be properly
                           converted to a quaternion.
        """
        c = GameWorld.PositionComponent()
        try:
            c.position = state['position']
        except KeyError:
            sys.exc_clear()

        try:
            r = state['rotation']
            if len(r) == 3:
                r = geo2.QuaternionRotationSetYawPitchRoll(*r)
            c.rotation = r
        except KeyError:
            sys.exc_clear()

        return c
コード例 #26
0
 def PrepareComponent(self, sceneID, entityID, component):
     if entityID == session.charid:
         component.isClientPlayer = True
     if component.updater is None:
         component.updater = GameWorld.GWAnimation(None)
         component.updater.updateMode = 0
         component.updaterWaitingChannel = stackless.channel()
コード例 #27
0
 def _LoadActionObjectData(self, actionObjectUID):
     """
         Loads ActionObject object-level data with the given UID.
         
         In:     actionObjectUID - The UID of the action object to load
         Out:    aoData - Appended to self.actionObjectDatas
         Return: aoData - The action object data just loaded and stored 
     """
     aoDbData = self.GetActionObjectRecord(actionObjectUID)
     if aoDbData is None:
         self.LogError('Error getting ActionObject record with UID %d.' %
                       actionObjectUID)
         return
     aoData = GameWorld.ActionObjectData(actionObjectUID,
                                         str(aoDbData['Name']))
     if self._LoadExitPoints(aoData) is False:
         self.LogError(
             'Error loading exit points for ActionObject data with UID %d.'
             % actionObjectUID)
         return
     if self._LoadActionStationLocalData(aoData) is False:
         self.LogError(
             'Error loading action stations for ActionObject data with UID %d.'
             % actionObjectUID)
         return
     self.manager.AddActionObjectData(aoData)
     return aoData
コード例 #28
0
ファイル: paperDollClient.py プロジェクト: R4M80MrX/eve-1
 def RegisterComponent(self, entity, component):
     positionComponent = entity.GetComponent('position')
     if positionComponent:
         component.callback = GameWorld.PlacementObserverWrapper(
             component.doll.avatar)
         positionComponent.RegisterPlacementObserverWrapper(
             component.callback)
コード例 #29
0
 def SetPositionComponent(self, positionComponent):
     if self.emitter and positionComponent and GameWorld:
         self.positionObserver = GameWorld.PlacementObserverWrapper(
             self.emitter)
         positionComponent.RegisterPlacementObserverWrapper(
             self.positionObserver)
         return positionComponent
コード例 #30
0
ファイル: UnicursesDrawMobule.py プロジェクト: Alexqq11/hilh
 def start_new_game(self):
     self.game = GameWorld.GameWorld(self, self.game_field.width - 2,
                                     self.game_field.height - 2)
     self.game_field.enable()
     self.game_stat.enable()
     self.game_menu_interface.enable()
     self.game_initialized = True
コード例 #31
0
 def TurnOnNetDebugDrawHistory(self):
     self.CreateDebugRenderer()
     self.TurnOffNetDebugDrawHistory()
     entity = self.debugSelectionClient.GetSelectedEntity()
     if entity is None:
         return
     GameWorld.SetNetMoveDebugDrawHistory(entity.entityID, True)
コード例 #32
0
 def ProcessAnimationDictionary(self, animationDict):
     GameWorld.processAnimInfoYAML(animationDict)
コード例 #33
0
ファイル: main.py プロジェクト: trietptm/lijinchao2007
#coding:gbk
import log
import GameWorld
import time
Log = log.Log
ErrLog = log.ErrLog

now = time.localtime(time.time())
year, month, day, hour, minute, second, weekday, yearday, daylight = now

def TestSecond():
    print "second"
    

def TestMinute():
    print "Minute"
    

def TestHour():
    print "hour"
    
#GameWorld.RegisterTime(TestSecond, 2, second, 0, 0)
#GameWorld.RegisterTime(TestSecond, 2, second+1, 0, 0)
#GameWorld.RegisterTime(TestMinute, 2, second, minute, 0)
GameWorld.RegisterTime(TestMinute, 2, second+1, minute, 0)
#GameWorld.RegisterTime(TestHour, 2, second, minute, hour )
GameWorld.RegisterTime(TestHour, 2, second+1, minute, hour )
GameWorld.RegisterTime(TestHour, 2, second+3, minute, hour )
GameWorld.RegisterTime(TestHour, 2, second+4, minute, hour )
GameWorld.run()