示例#1
0
 def __init__(self, hours=0, minutes=0, seconds=0):
     Entity.__init__(self,
                     0)  # For this demo, the clock need not have mass.
     Intervaled.__init__(self, Clock.INTERVAL, Milli())
     self.hours = hours
     self.minutes = minutes
     self.seconds = seconds
示例#2
0
    def __init__(self, scene, pos, dest, router):
        Entity.__init__(self)
        self._destroyed = False
        self._closing = False
        self._target_reached = False

        self._scene = scene
        self._map = scene.getMap()

        self._path = None

        self._dying_t = 0
        self._spin = 0

        self.moveTo(pos)

        self._scale = 1.0
        self._graphics = R.loadObject("enemy.obj","diffuse")
        self._orient_m= T.identity_matrix()

        self._xform_m = N.dot(T.rotation_matrix(math.pi/2,(0,0,1)),T.scale_matrix(self._scale))

        bounds = self._graphics.getObj().getBounds()

        router.requestJob(pos, dest, Enemy.OnRouteObtained, self)

        Entity.setBounds(self,bounds * self._scale)
        self._destroyed = False
        self._old_time = 0

        self._old_pos = None # At t-1
        self._old_pos2 = None # At t-2

        self._hc = HeadingController()
示例#3
0
    def __init__(self, map, position):

        print "New player"

        Entity.__init__(self)
        self._lock = None
        self._phys = Verlet(position)
        self._phys.setDamping((0.02, 0.02, 0.0002))
        self._phys.setGravity((0, 0, -0.00006))

        self._on_floor = False
        self._speed = 0

        self._map = map
        self._heading = 0
        self.reset()

        r = self._radius = 0.1

        self.setBounds(((-r, -r, -r), (r, r, r)))  # entity stuff
        Entity.moveTo(self, position)  # keep the entity updated

        self._scaling = T.scale_matrix(self._radius)

        self._last_pos = N.array((0, 0, 0), dtype="f")

        self._graphics = R.loadObject("sphere.obj", "diffuse")
示例#4
0
 def __init__(self,
              x,
              y,
              name,
              color="#000000",
              image_file=None,
              flip=False,
              force_background=False,
              jump_sound=None):
     Entity.__init__(self)
     self.name = name
     self.color = color
     self.xvel = 0
     self.yvel = 0
     self.onGround = False
     self.onStairs = False
     self.onBar = False
     self.on_goal = False
     self.image = draw_player(self.color, image_file, flip,
                              force_background)
     self.rect = Rect(x, y, constants.TILE_X - 2, constants.TILE_Y)
     if jump_sound is None:
         self.jump_sound = None
     else:
         self.jump_sound = pygame.mixer.Sound(jump_sound)
         self.jump_sound.set_volume(1.0)
示例#5
0
    def __init__(self, pos=Vector(0, 0), rot=0.0):
        """Creates a new Ship

        Args:
            pos: the position of the ship
            rot: the rotation of the ship

        Returns:
            a new Ship instance
        """

        # Get the initial direction of the ship using the rotation
        direction = Vector(cos(radians(rot)), sin(radians(rot)))

        # Initially, the ship isn't moving
        self._movement = Vector.zero()

        # Initialize bullet list
        self.bullets = []
        self._last_shoot = self._shoot_delay
        self._last_teleport = self._teleport_delay
        self.teleport_up = True
        self.effect_player = EffectPlayer.instance()
        Entity.__init__(self, (20, 0, -30, 20, -30, -20), direction,
                        lin_speed=1.0, rot_speed=2.0, pos=pos, rot=rot,
                        scale=0.5)
示例#6
0
    def __init__(self, scene, pos):
        Entity.__init__(self)
        self._destroyed = False
        self._closing = False

        self._scene = scene

        self.moveTo(pos)

        self._graphics = R.loadObject("targetpt.obj","diffuse")
        self._beacon = R.loadObject("beacon.obj","glow")

        self._anim_m = T.identity_matrix()
        self._rot= T.quaternion_about_axis(0, (0,0,1))
        self._rot_speed = T.quaternion_about_axis(0.01, (0,0,1))

        self._scale = 0.15

        self.moveTo(self.getPosition() + (0,0,-0.3))

        self._scale_m = T.scale_matrix(self._scale)

        bounds = self._graphics.getObj().getBounds() * self._scale

        Entity.setBounds(self,bounds)
示例#7
0
    def __init__(self, poi_type, red, black):
        Entity.__init__(self, poi_type, red, black)
        self.width = 90
        self.height = 90
        self.offsetRed = self.height / 2
        self.offsetBlack = self.width / 2

        self.conceal()
示例#8
0
    def __init__(self, poi_type, red, black):
        Entity.__init__(self, poi_type, red, black)
        self.width = 90
        self.height = 90
        self.offsetRed = self.height/2
        self.offsetBlack = self.width/2

        self.conceal()
示例#9
0
 def __init__(self, mass, position, velocity):
     Entity.__init__(self, mass)
     Positioned.__init__(self, position)
     Moving.__init__(self, velocity)
     self.radius = mass / 2
     self.color = (127, 127, 0)
     self.accumulatedTime = 0
     self.environment = None
     self.halt = False
示例#10
0
 def __init__(self, door_type, red, black, red_link, black_link):
     Entity.__init__(self, door_type, red, black)
     self.red_link = red_link
     self.black_link = black_link
     self.key = "door-{}-{}-{}-{}".format(red, black, red_link, black_link)
     self.width = 100
     self.height = 100
     self.set_offset()
     self.close()
示例#11
0
 def __init__(self, door_type, red, black, red_link, black_link):
     Entity.__init__(self, door_type, red, black)
     self.red_link = red_link
     self.black_link = black_link
     self.key = "door-{}-{}-{}-{}".format(red, black, red_link, black_link)
     self.width = 100
     self.height = 100
     self.set_offset()
     self.close()
示例#12
0
    def __init__(
            self,
            level_loaded: Level,
            x, y, name,
            key_up,
            key_down,
            key_right,
            key_left,
            bg_color="#000000",
            image_file=None,
            image_transform=None,
            flip=False,
            force_background=False,
            jump_sound=None,
    ):
        Entity.__init__(self)
        self.collides = True
        self.has_grip = False
        self.item = False
        self.collectable = False
        self.transformed = False
        self.fly = False

        self.target_player = None
        self.path = None
        self.path_last_calc = pygame.time.get_ticks()

        self.name = name
        self.level_loaded = level_loaded

        self.key_up = key_up
        self.key_down = key_down
        self.key_right = key_right
        self.key_left = key_left

        self.key_pressed_up = False
        self.key_pressed_down = False
        self.key_pressed_left = False
        self.key_pressed_right = False

        self.bg_color = bg_color
        self.vel_x = 0
        self.vel_y = 0
        self.onGround = False
        self.onStairs = False
        self.onBar = False
        self.on_goal = False
        self.image = draw_player(level_loaded, self.bg_color, image_file, flip, force_background)
        self.image_transform = image_transform
        self.rect = Rect(x, y, level_loaded.TILE_X-2, level_loaded.TILE_Y)
        if jump_sound is None:
            self.jump_sound = None
        else:
            self.jump_sound = pygame.mixer.Sound(jump_sound)
            self.jump_sound.set_volume(1.0)
示例#13
0
 def __init__(self, name, password=None):
     Entity.__init__(self)
     self.create_ts = datetime.now()
     self.name = name
     self.seed = sum([ord(i) for i in self.id])
     self.password = password
     self.history = []
     self.current = None
     self.locked = False
     self.players_auth_ids = []
     self.stunned = False
     self.result = None
示例#14
0
 def __init__(self, timer, frameRate=FRAME_RATE, mass=0):
     Entity.__init__(self, mass)
     resolution = Milli()
     Intervaled.__init__(self, 1 / (resolution.scalor * frameRate),
                         resolution)
     self.viewer = None
     self.overlay = None
     self.sensor = None
     self.mount = None
     self.lens = None
     # The camera should always start living.
     self.birth()  # TODO: Or maybe wait when it's added to the environment?
示例#15
0
    def __init__(self, pos, particles):
        Entity.__init__(self)

        self._particles = particles

        self.moveTo(pos)

        self._graphics = R.loadObject("base.obj","diffuse")
        self._anim_m = T.identity_matrix()

        bounds = self._graphics.getObj().getBounds()

        Entity.setBounds(self,bounds)
示例#16
0
  def __init__(self, position, velocity, rayColor=None):
    Entity.__init__(self, 0) # Light rays have 0 mass. For now.
    Positioned.__init__(self, position)
    Moving.__init__(self, velocity)
    
    self.velocityModifier = None
    self.rayColor = rayColor if rayColor else (int(random() * 255), int(random() * 255), int(random() * 255))
    self.segment = None
    self.bounces = RAY_BOUNCES
    self.timeResolution = Milli()
    self.accumulatedTime = 0

    self.environment = None
示例#17
0
    def __init__(
            self,
            level_loaded: Level,
            x, y, name,
            bg_color="#000000",
            image_file=None,
            image_transform=None,
            flip=False,
            force_background=False,
            jump_sound=None
    ):
        Entity.__init__(self)
        self.collides = False
        self.has_grip = False
        self.item = False
        self.collectable = False
        self.transformed = False
        self.fly = False

        self.level_loaded = level_loaded
        self.name = name
        self.bg_color = bg_color
        self.xvel = 0
        self.yvel = 0
        self.onGround = False
        self.onStairs = False
        self.onBar = False
        self.on_goal = False
        self.image_file = image_file
        self.image_right = draw_player(
            level_loaded.TILE_X, level_loaded.TILE_Y,
            self.bg_color, image_file, True
        )
        self.image_left = draw_player(
            level_loaded.TILE_X, level_loaded.TILE_Y,
            self.bg_color, image_file, False
        )
        self.image = self.image_right
        self.image_transform = image_transform
        self.rect = Rect(x, y, level_loaded.TILE_X-2, level_loaded.TILE_Y)
        if jump_sound is None:
            self.jump_sound = None
        else:
            self.jump_sound = pygame.mixer.Sound(jump_sound)
            self.jump_sound.set_volume(1.0)
示例#18
0
  def __init__(self, texture = None, position = Point2(0, 0), depth = 55, scale = 1,
               transparency = True):
    Entity.__init__(self, "shapes/plane")
    self.prime.reparentTo(base.camera)
    self.prime.setPos(Point3(position.getX(), depth, position.getY()))
    self.prime.setScale(scale)

    # tells panda3d to not care about what order to draw the sprite in, prevents
    # z-fighting
    self.prime.setBin("unsorted", 0)

    # tells panda3d not to check if something has been drawn in front of it
    self.prime.setDepthTest(False)
    if transparency:
      self.prime.setTransparency(1)

    if texture:
      self.texture = base.loader.loadTexture(APP_PATH + "media/textures/" +
                                             texture + ".png")
      self.prime.setTexture(self.texture, 1)
示例#19
0
 def __init__(self, role, player, red, black):
     Entity.__init__(self, role, red, black)
     self.set_player(player)
     self.role = role
     self.image_name = "assets/firefighters/{}_{}.png".format(self.role, self.player.color)
示例#20
0
 def __init__(self, title, publication_date):
     Entity.__init__(self)
     self.title = title
     self.publication_date = publication_date
示例#21
0
 def __init__(self, hazard_type, red, black):
     Entity.__init__(self, hazard_type, red, black)
     self.image_name = "assets/tokens/{}.png".format(self.entity_type)
示例#22
0
 def __init__(self, hazard_type, red, black):
     Entity.__init__(self, hazard_type, red, black)
     self.image_name = "assets/tokens/{}.png".format(self.entity_type)
示例#23
0
 def __init__(self, text, id_book, id_user):
     Entity.__init__(self)
     self.text = text
     self.id_book = id_book
     self.id_user = id_user
示例#24
0
    def __init__(self, game, pos):

        self.inventory = []
        self.quest_list = []
        self.registered_actions = []  # use for buf and debuf

        # Rolling base stats
        self.base_strength = ut.roll(6, 3)
        self.base_dexterity = ut.roll(6, 3)
        self.base_mind = ut.roll(6, 3)
        self.base_charisma = ut.roll(6, 3)
        # As a human, adding +1 to 2 random Characteristics
        characteristics = [c.CHAR_NAME, c.STR_NAME, c.DEX_NAME, c.MIND_NAME]
        rd.shuffle(characteristics)
        setattr(self, 'base_' + characteristics[0],
                getattr(self, characteristics[0]) + 1)
        setattr(self, 'base_' + characteristics[1],
                getattr(self, characteristics[1]) + 1)

        # Now starting as an adventurer
        self.base_hit_points = ut.roll(8) + self.strength
        self.base_body_points = 20

        self.saving_throw = 14

        self.experience = 0
        self.level = 1

        Entity.__init__(self,
                        game,
                        MName.name(),
                        pos,
                        "PLAYER",
                        vision=4,
                        fighter=PlayerFighter(
                            hit_points=self.base_hit_points,
                            body_points=self.base_body_points,
                            physical_combat_bonus=1,
                            magical_combat_bonus=0))
        self.inventory_max = 100
        self.base_speed = 10
        self.wealth = 0

        self.invalidate_fog_of_war = True

        # Player needs to heal from exploration
        self.time_before_next_heal = 10  # in 10 turn, recover strength bonus health
        game.bus.register(self,
                          main_category=c.P_CAT_ENV,
                          sub_category=c.AC_ENV_MOVE,
                          function_to_call=self.exploration_heal)

        # TODO Remove the following tests in real life
        self.quest_list.append(
            KillQuest(self,
                      game.bus,
                      "BAT",
                      2,
                      "kill at least 2 bats",
                      rewards={
                          "target": self,
                          "wealth": 20,
                          "xp": 10
                      }))
        self.quest_list.append(
            KillQuest(self,
                      game.bus,
                      "ANY",
                      5,
                      "kill five enemies",
                      rewards={
                          "target": self,
                          "wealth": 15,
                          "xp": 20
                      }))
        self.quest_list.append(
            KillQuest(self,
                      game.bus,
                      "ANY",
                      1,
                      "kill whatever creature",
                      rewards={
                          "target": self,
                          "wealth": 10,
                          "xp": 15
                      }))
        self.quest_list.append(
            KillAllQuest(self,
                         game.bus,
                         game.objects,
                         rewards={
                             "target": self,
                             "wealth": 100,
                             "xp": 150
                         }))
示例#25
0
 def __init__(self, username, password, first_name, last_name, **kwargs):
     Entity.__init__(self)
     self.username = username
     self.password = password
     self.first_name = first_name
     self.last_name = last_name
示例#26
0
 def __init__(self, mass, position):
     Entity.__init__(self, mass)
     Positioned.__init__(self, position)
示例#27
0
 def __init__(self, model):
   Entity.__init__(self, model)
   self.create_collisions()
示例#28
0
    def __init__(self, scene, pos, direction, missile_type, follow):
        Entity.__init__(self)

        self._t0 = None
        self._follow = follow

        self._scene = scene

        self._map = scene.getMap()

        self.moveTo(pos)

        self._thrust = 0.01
        self._speed = 0.1

        self._destroyed = False

        self._graphics = R.loadObject(missile_type+".obj","diffuse")
        self._pos_m = T.translation_matrix(pos)


        axis = T.random_vector(3)

        self._d_rotation = T.quaternion_about_axis(0.01, axis)
        self._rotation = T.random_quaternion()

        self._dir = direction

        scale = 0.05

        self._scaling_m = T.scale_matrix(scale)

        bounds = self._graphics.getObj().getBounds() * scale

        Entity.setBounds(self,bounds)

        self._trail= ParticleGenerator("billboard","puff.jpg")
        self._trail.setEvolveTime(0.5)
        self._trail.setAcceleration(0)
        self._trail.setEasing(0.5, 0.5, 0.0, 0.05, 0.2)
        self._trail.setBrightness(0.5)

        pg = scene.getParticleManager()

        def em(t):
            while True:
                dx = 2.*random.random()-1.
                dy = 2.*random.random()-1.
                dz = 2.*random.random()-1.

                r = dx*dx+dy*dy+dz*dz

                if r < 1.0:
                    break

            return self._pos,(dx*0.2,dy*0.2,dz*0.2)

        self._trail.setEmitter(em)
        self._trail.setMode("DYNAMIC")

        pg.manageGenerator(self._trail)

        self._last_z = 0
 def __init__(self, unique_id, entity_type=EntityType.find(100), name='Unnamed entity', state=STATE_UNKNOWN, state_value=None, last_checkin=0):
     Entity.__init__(self, unique_id, entity_type, name=name, state=state, state_value=state_value, last_checkin=last_checkin)
示例#30
0
 def __init__(self, position):
   Entity.__init__(self, 0) # For this demo, the radar need not have mass.
   Positioned.__init__(self, position)
   self.angle = -0.25 * tau # Start at midnight instead of 3 o'clock.
   self.environment = None
   self.drawing = False