Esempio n. 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

Esempio n. 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))
Esempio n. 3
0
 def update(self):
     if time.time() - self.startTime >= 10.0:
         ActorManager.get_singleton().queue_message(TenSecGroupMessage())
         self.startTime=time.time()
Esempio n. 4
0
 def send_message(self,msg):
     print "GUI sent message"
     msg.sender='gui'
     ActorManager.get_singleton().trigger(msg)
Esempio n. 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)
Esempio n. 6
0
 def send_message(self,msg):
     msg.sender='ui'
     ActorManager.get_singleton().trigger(msg)
Esempio n. 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):
Esempio n. 8
0
 def update(self):
     if time.time() - self.startTime >= 10.0:
         ActorManager.get_singleton().queue_message(TenSecGroupMessage())
         self.startTime = time.time()
Esempio n. 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))
Esempio n. 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):