Example #1
0
 def update(self):
     self.cx, self.cy = self.x - (self.bg.window_left * 32) - 16, self.y - (
         self.bg.window_bottom * 32)
     self.tileX, self.tileY = (self.x - 16) // 32, (self.y - 16) // 32
     if self.turn == 1:
         self.bt.run()
     # print("monster : ", (self.y - 16) // 32, (self.x - 16) // 32, map.MapLi[self.tileY][self.tileX])
     if self.state == 0:
         self.timer = (self.timer + 1) % 1000
         if self.timer > 800:
             self.idl = 1
         else:
             self.idl = 0
     if self.state == 1:
         self.deadTimer += 1
         if self.deadTimer == 96:
             warrior = main_state.get_warrior()
             game_world.remove_object(self)
             warrior.gameWon = 1
             warrior.score += 50
             game_framework.push_state(game_over)
     if self.state == 2:
         self.atkTimer = (self.atkTimer + FRAMES_PER_ACTION *
                          ACTION_PER_TIME * game_framework.frame_time)
         if self.atkTimer < 7:  # 조정해.
             if self.atkTimer < 3:
                 self.atkPose = 1
             elif self.atkTimer < 5:
                 self.atkPose = 2
             else:
                 self.atkPose = 3
         else:
             self.atkTimer = 0
             self.atkPose = 0
             self.state = 0
Example #2
0
 def is_nearing(self):
     warrior = main_state.get_warrior()
     distance = (warrior.tileX - self.tileX)**2 + (warrior.tileY -
                                                   self.tileY)**2
     if distance == 1 and self.moving == 0:
         return BehaviorTree.SUCCESS
     else:
         return BehaviorTree.FAIL
Example #3
0
 def find_warrior(self):
     disrupt = 0
     warrior = main_state.get_warrior()
     distance = (warrior.tileX - self.tileX)**2 + (warrior.tileY -
                                                   self.tileY)**2
     if distance < 16:
         if warrior.tileX < self.tileX:
             self.dir = 0
         elif warrior.tileX > self.tileX:
             self.dir = 1
         if self.moving == 0:
             if ((warrior.tileX - self.tileX)**
                     2) > ((warrior.tileY - self.tileY)**2):
                 if warrior.tileX < self.tileX and self.bg.mapli[
                         self.tileY][self.tileX - 1] == 2:
                     for game_object in game_world.all_objects():
                         if game_object.type == 'mon':
                             check_monster_tileX, check_monster_tileY = game_object.return_loc(
                             )
                             if self.tileX - 1 == check_monster_tileX and self.tileY == check_monster_tileY:
                                 disrupt = 1
                     if disrupt == 0:
                         self.moveDir = 1  # -x
                         self.cnt = 0
                 elif warrior.tileX > self.tileX and self.bg.mapli[
                         self.tileY][self.tileX + 1] == 2:
                     for game_object in game_world.all_objects():
                         if game_object.type == 'mon':
                             check_monster_tileX, check_monster_tileY = game_object.return_loc(
                             )
                             if self.tileX + 1 == check_monster_tileX and self.tileY == check_monster_tileY:
                                 disrupt = 1
                     if disrupt == 0:
                         self.moveDir = 0  # +x
                         self.cnt = 0
             elif ((warrior.tileX -
                    self.tileX)**2) == ((warrior.tileY -
                                         self.tileY)**2):  # =
                 if warrior.tileX < self.tileX:
                     if self.bg.mapli[self.tileY][self.tileX - 1] == 2:
                         for game_object in game_world.all_objects():
                             if game_object.type == 'mon':
                                 check_monster_tileX, check_monster_tileY = game_object.return_loc(
                                 )
                                 if self.tileX - 1 == check_monster_tileX and self.tileY == check_monster_tileY:
                                     disrupt = 1
                         if disrupt == 0:
                             self.moveDir = 1  # -x
                             self.cnt = 0
                     else:
                         disrupt = 1
                 elif warrior.tileX > self.tileX:
                     if self.bg.mapli[self.tileY][self.tileX + 1] == 2:
                         for game_object in game_world.all_objects():
                             if game_object.type == 'mon':
                                 check_monster_tileX, check_monster_tileY = game_object.return_loc(
                                 )
                                 if self.tileX + 1 == check_monster_tileX and self.tileY == check_monster_tileY:
                                     disrupt = 1
                         if disrupt == 0:
                             self.moveDir = 0  # +x
                             self.cnt = 0
                     else:
                         disrupt = 1
                 if disrupt == 1:
                     disrupt = 0
                     if warrior.tileY < self.tileY and self.bg.mapli[
                             self.tileY - 1][self.tileX] == 2:
                         for game_object in game_world.all_objects():
                             if game_object.type == 'mon':
                                 check_monster_tileX, check_monster_tileY = game_object.return_loc(
                                 )
                                 if self.tileX == check_monster_tileX and self.tileY - 1 == check_monster_tileY:
                                     disrupt = 1
                         if disrupt == 0:
                             self.moveDir = 3  # -y
                             self.cnt = 0
                     elif warrior.tileY > self.tileY and self.bg.mapli[
                             self.tileY + 1][self.tileX] == 2:
                         for game_object in game_world.all_objects():
                             if game_object.type == 'mon':
                                 check_monster_tileX, check_monster_tileY = game_object.return_loc(
                                 )
                                 if self.tileX == check_monster_tileX and self.tileY + 1 == check_monster_tileY:
                                     disrupt = 1
                         if disrupt == 0:
                             self.moveDir = 2  # +y
                             self.cnt = 0
             else:
                 if warrior.tileY < self.tileY and self.bg.mapli[
                         self.tileY - 1][self.tileX] == 2:
                     for game_object in game_world.all_objects():
                         if game_object.type == 'mon':
                             check_monster_tileX, check_monster_tileY = game_object.return_loc(
                             )
                             if self.tileX == check_monster_tileX and self.tileY - 1 == check_monster_tileY:
                                 disrupt = 1
                     if disrupt == 0:
                         self.moveDir = 3  # -y
                         self.cnt = 0
                 elif warrior.tileY > self.tileY and self.bg.mapli[
                         self.tileY + 1][self.tileX] == 2:
                     for game_object in game_world.all_objects():
                         if game_object.type == 'mon':
                             check_monster_tileX, check_monster_tileY = game_object.return_loc(
                             )
                             if self.tileX == check_monster_tileX and self.tileY + 1 == check_monster_tileY:
                                 disrupt = 1
                     if disrupt == 0:
                         self.moveDir = 2  # +y
                         self.cnt = 0
         return BehaviorTree.SUCCESS
     else:
         return BehaviorTree.FAIL
     pass
Example #4
0
 def attack_warrior(self):
     warrior = main_state.get_warrior()
     warrior.get_damage(self.atkDamage)
     self.state = 2
     self.turn = 0
     return BehaviorTree.SUCCESS