def __init__(self,radiu,unit,index): super().__init__(radiu,unit,index) self.coolDown=1.0#技能冷却时间 self.cdLeft=1.0#当前技能的剩余冷却时间 self.damageKind=Damage.NORMAL_DAMAGE() self.damageNum=10 self.timeBefore=0.2
def __init__(self,radiu,unit,index): #子类别客制化属性 self.coolDown=1.0#技能冷却时间 self.cdLeft=1.0#当前技能的剩余冷却时间 self.damageKind=Damage.NORMAL_DAMAGE() self.damageNum=10 self.timeBefore=0.2 #固有代码 self.kind=Skill.ACTIVE() self.attack=True#是否是角色的基本攻击 self.range=unit.AI.NEAR_RANGE(radiu)#攻击范围 self.unit=unit self.index=index#技能在角色身上的欄位索引
def trigger(self,list): skill = list[0] traget = list[1] if skill.attack: for pair in self.unit.LastSortList: if pair.value <= self.range + pair.key.radiu: if (not (self.unit.manager.getUnit(pair.key.id).ownerid == self.unit.ownerid)) and (not ( self.unit.manager.getUnit(pair.key.id).no == traget.no)):#異類即是仇敵 positiveDirection = self.unit.direct targetDirection = self.unit.manager.getUnit(pair.key.id).circle.center - self.unit.circle.center targetAngle = Vector2.angleBetween(positiveDirection,targetDirection) if (targetAngle <= 90): targetNum = pair.key.id self.unit.causeDamage(targetNum,Damage.NORMAL_DAMAGE(),10) self.unit.SkillTo(self, traget.no)