Beispiel #1
0
# test_system.py
# unit test that excercises the object manager system
from pysage import Actor, ActorManager, Message
from pysage.system import ConcreteMessageAlreadyDefined, PacketTypeError
import time
import unittest

mgr = ActorManager.get_singleton()


class TakeDamage(Message):
    properties = ['damageAmount']
    packet_type = 104


class Punk(Actor):
    pass


class RealPunk(Actor):
    subscriptions = ['TakeDamage']

    def __init__(self):
        Actor.__init__(self)
        self.damage = 0

    def handle_TakeDamage(self, msg):
        self.damage += msg.get_property('damageAmount')
        return True

Beispiel #2
0
 def handle_TenSecGroupMessage(self, msg):
     self.Count=self.Count+1
     ActorManager.get_singleton().queue_message_to_group(ActorManager.get_singleton().PYSAGE_MAIN_GROUP,MainGroupMessage(TenSecCount=self.Count, ThreeSecCount=0))
Beispiel #3
0
 def update(self):
     if time.time() - self.startTime >= 10.0:
         ActorManager.get_singleton().queue_message(TenSecGroupMessage())
         self.startTime=time.time()
Beispiel #4
0
 def send_message(self,msg):
     print "GUI sent message"
     msg.sender='gui'
     ActorManager.get_singleton().trigger(msg)
Beispiel #5
0
# sample_multigroups.py
# 
# contributed by: Jay Herrmann
# edited by: Shuo (John) Yang
import sys
sys.path.insert(0, '.\\')


import time
from pysage import Actor, ActorManager, Message
from pysage.process import enable_groups

mgr = ActorManager.get_singleton()

class MainGroupMessage(Message):
    properties = ['TenSecCount','ThreeSecCount']
    types = ['i','i']
    packet_type = 101

class ThreeSecGroupMessage(Message):
    properties = []
    packet_type = 102

class TenSecGroupMessage(Message):
    properties = []
    packet_type = 103

class MainAction(Actor):
    subscriptions = ['MainGroupMessage']
    def __init__(self):
        Actor.__init__(self)
Beispiel #6
0
 def send_message(self,msg):
     msg.sender='ui'
     ActorManager.get_singleton().trigger(msg)
Beispiel #7
0
# test_system.py
# unit test that excercises the object manager system
from pysage import Actor, ActorManager, Message
from pysage.system import ConcreteMessageAlreadyDefined, PacketTypeError
import time
import unittest

mgr = ActorManager.get_singleton()

class TakeDamage(Message):
    properties = ['damageAmount']
    packet_type = 104

class Punk(Actor):
    pass

class RealPunk(Actor):
    subscriptions = ['TakeDamage']
    def __init__(self):
        Actor.__init__(self)
        self.damage = 0
    def handle_TakeDamage(self, msg):
        self.damage += msg.get_property('damageAmount')
        return True
    
class DumbPunk(Actor):
    subscriptions = ['BombMessage']
    def __init__(self):
        Actor.__init__(self)
        self.alive = True
    def handle_BombMessage(self, msg):
Beispiel #8
0
 def update(self):
     if time.time() - self.startTime >= 10.0:
         ActorManager.get_singleton().queue_message(TenSecGroupMessage())
         self.startTime = time.time()
Beispiel #9
0
 def handle_TenSecGroupMessage(self, msg):
     self.Count = self.Count + 1
     ActorManager.get_singleton().queue_message_to_group(
         ActorManager.get_singleton().PYSAGE_MAIN_GROUP,
         MainGroupMessage(TenSecCount=self.Count, ThreeSecCount=0))
Beispiel #10
0
# sample_multigroups.py
#
# contributed by: Jay Herrmann
# edited by: Shuo (John) Yang
import sys
sys.path.insert(0, '.\\')

import time
from pysage import Actor, ActorManager, Message
from pysage.process import enable_groups

mgr = ActorManager.get_singleton()


class MainGroupMessage(Message):
    properties = ['TenSecCount', 'ThreeSecCount']
    types = ['i', 'i']
    packet_type = 101


class ThreeSecGroupMessage(Message):
    properties = []
    packet_type = 102


class TenSecGroupMessage(Message):
    properties = []
    packet_type = 103


class MainAction(Actor):