
    i^
                     2    d dl mZ ddlmZ  G d de      Zy)   )Plant   )Bulletc                   .     e Zd ZdZ fdZd Zd Z xZS )
SwordGourdu   
    养剑葫 - 发射追踪鼠标的飞剑
    
    机制：
    - 每15秒向鼠标位置发射飞剑
    - 飞剑持续追踪鼠标位置
    - 穿透敌人造成伤害
    - 存在时间10秒或飞出画面消失
    c                     t         |   ||d       d| _        d| _        d| _        d| _        d| _        d | _        d | _        y )Nsword_gourd      g      @    )	super__init__hpmax_hpcostshoot_intervalshoot_timertarget_xtarget_y)selfcolrow	__class__s      \/mnt/c/Users/DipsyHou/Desktop/workspace/PVZOnline/backend/game/objects/plants/sword_gourd.pyr   zSwordGourd.__init__   sI    c=1	!     c           	      R   | j                   | j                  ,| j                  dz   }| j                  | j                  dz  z   }n| j                   }| j                  }|| j                  | j
                  dz  z   z
  }|| j                  | j                  dz  z   z
  }||z  ||z  z   dz  }|dkD  rd}||z  |z  }||z  |z  }	nd}d}	| j                  | j
                  dz  z   }
| j                  | j                  dz  z   }t        |
|| j                  ||	dd      }d	|_        d
|_        d|_        d|_	        d|_
        d|_        d|_        d|_        d|_        d|_        d|_        | j"                  |_        |j&                  j)                  |       |j+                  d|
|||d       y)u   发射飞剑Ni  r   g      ?r   ih     flying_sword(      i'  Tg      $@Fsword_launch)typexyr   r   )r   r   r#   r$   hwr   r   piercehomingtargetmax_distance	life_timemax_life_timeis_swordis_returninghit_set_clear_timeridplant_idbulletsappend	add_event)r   
game_stater   r   dxdydistspeedvxvybxbybs                r   shootzSwordGourd.shoot   s    == DMM$9vv|Hvv
*H}}H}}H $&&1*,-$&&1*,-R"r'!c)!8Et)u$Bt)u$BBB VVdffqj VVdffqj 2r488RR@
 ! WW
!!!$ 	"  
 	r   c                      || _         || _        y)u'   设置鼠标位置（由前端调用）N)r   r   )r   r#   r$   s      r   set_mouse_positionzSwordGourd.set_mouse_positionQ   s    r   )__name__
__module____qualname____doc__r   r?   rA   __classcell__)r   s   @r   r   r      s    
4lr   r   N)baser   bulletr   r    r   r   <module>rJ      s     P Pr   