
    iG                     :    d dl mZ ddlmZ  G d de          ZdS )   )Plant   )Bulletc                   4     e Zd ZdZ fdZd Zd Zd Z xZS )
SwordGourdu   
    养剑葫 - 发射追踪鼠标的飞剑
    
    机制：
    - 每15秒向鼠标位置发射飞剑
    - 飞剑持续追踪鼠标位置
    - 穿透敌人造成伤害
    - 存在时间10秒或飞出画面消失
    c                     t                                          ||d           d| _        d| _        d| _        d| _        d| _        d | _        d | _        d S )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__   sX    c=111	!     c                     | xj         |z  c_         | j         | j        k    rd| _         |                     |           dS dS )u   更新射击计时器r   N)r   r   shoot)r   dt
game_states      r   updatezSwordGourd.update   sO    Bt222 DJJz""""" 32r   c           	         | 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k    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                            |           |                    d|
|||d           dS )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   r   r   r   dxdydistspeedvxvybxbybs                r   r   zSwordGourd.shoot"   s    = DM$9v|Hv
*HH}H}H $&1*,-$&1*,-R"r'!c)!88Et)u$Bt)u$BBBB Vdfqj Vdfqj 2r48RR@@
 ! W
!!!$$$ 	"  
 
 	 	 	 	 	r   c                 "    || _         || _        dS )u'   设置鼠标位置（由前端调用）N)r   r   )r   r(   r)   s      r   set_mouse_positionzSwordGourd.set_mouse_positionX   s    r   )	__name__
__module____qualname____doc__r   r    r   rD   __classcell__)r   s   @r   r   r      sp         
 
 
 
 
# # #4 4 4l      r   r   N)baser   bulletr   r    r   r   <module>rM      sg               W W W W W W W W W Wr   