Exemplo n.º 1
0
func (a *BlowFlag) Do(obj gameObjectsBase.Activer) {
	if obj.ReadyAttack() {
		p := obj.GetAttackPoint()
		if p != nil && !a.field.OutOfRange(int(p.X), int(p.Y)) {
			for _, actor := range a.field.GetActors(int(p.X), int(p.Y)) {
				r := actor.GetRectangle()
				if r.In(p) {
					obj.SetTarget(actor)
					break
				}
			}
			// obj.ClearAttackPoint()
		}
		if target, exists := obj.GetTarget(); exists || p != nil {
			msg := obj.Attack()
			obj.ZeroCooldown()
			if msg != nil {
				notifier.GameNotifier.NotifyAboutAttack(obj, target, msg)
			}
		}
		// if target, exists := obj.GetTarget(); exists && target.GetID() != obj.GetID() {
		//     msg := obj.Attack()
		//     obj.ZeroCooldown()
		//     if msg != nil {
		//         notifier.GameNotifier.NotifyAboutAttack(obj, target, msg)
		//     }
		// }
	} else {
		obj.IncCooldownCounter()
	}
}
Exemplo n.º 2
0
func (k *KillWallFlag) Do(obj gameObjectsBase.Activer) {
	if pt := obj.GetAttackPoint(); pt != nil {
		x, y := int(math.Ceil(pt.X)), int(math.Ceil(pt.Y))
		if !k.field.IsBlocked(x, y) {
			k.field.SetCell(x, y, consts.GRASS_SYMBOL)
		}
	}
}