IAttacking dealsDamage = new SimpleMeleeAttack(); //simple attack behavior reference

    void Update()
    {
        if (ArrowFlies) //activates or deactivates the movement
        {
            transform.position = Vector2.MoveTowards(transform.position,
                                                     targetPosition, velocity * Time.deltaTime);//moves an object towards the target

            //stops movement if the object is very close to the target
            if (Vector2.Distance(transform.position, targetPosition) < 0.1f)
            {
                ArrowFlies = false;//stops the movement

                //deals damage to the target
                Hero currentTarget = BattleController.currentTarget;
                dealsDamage.HeroIsDealingDamage(BattleController.currentAtacker, currentTarget);
                currentTarget.GetComponent <Animator>().SetTrigger("IsTakingDamage");
                DestroyMe();//destroys an arrow after dealing damage to the target
            }
        }
    }
Пример #2
0
    IAttacking dealsDamage = new SimpleMeleeAttack(); // referencia de comportamiento de ataque simple

    void Update()
    {
        if (ArrowFlies) // activa o desactiva el movimiento
        {
            transform.position = Vector2.MoveTowards(transform.position,
                                                     targetPosition, velocity * Time.deltaTime);// mueve un objeto hacia el objetivo

            // detiene el movimiento si el objeto está muy cerca del objetivo
            if (Vector2.Distance(transform.position, targetPosition) < 0.1f)
            {
                ArrowFlies = false;//para

                //asegura el daño recibido
                Hero currentTarget = BattleController.currentTarget;
                dealsDamage.HeroIsDealingDamage(BattleController.currentAtacker, currentTarget);
                currentTarget.GetComponent <Animator>().SetTrigger("IsTakingDamage");
                DestroyMe();// destruye una flecha después de infligir daño al objetivo
            }
        }
    }
Пример #3
0
 IAttacking dealsDamage = new SimpleMeleeAttack();//simple attack behavior reference
 public override void DealsDamage(BattleHex target)
 {
     //    //launches damage methods
     dealsDamage.HeroIsDealingDamage(this, BattleController.currentTarget);
 }
Пример #4
0
 IAttacking dealsDamage = new SimpleMeleeAttack();// referencia de comportamiento de ataque simple
 public override void DealsDamage(BattleHex target)
 {
     // // lanza métodos de daño
     dealsDamage.HeroIsDealingDamage(this, BattleController.currentTarget);
 }
Пример #5
0
 IAttacking dealsDamage = new SimpleMeleeAttack();//simple attack behavior reference
 public override void DealsDamage(BattleHex target)
 {
     dealsDamage.HeroIsDealingDamage(this, BattleController.currentTarget);
 }