Exemplo n.º 1
0
    public IEnumerator Attack(EnemyController enemy)
    {
        Debug.Log("Player is Attacking " + enemy.gameObject.name);
        isMoving_ = true;
        ActiveEntity enemyStats = enemy.GetComponentInParent <ActiveEntity>();

        // Attempt attack!
        float attackRoll  = Random.Range(0f, 1f);
        int   damage      = playerStats_.damage_;
        int   armorPierce = playerStats_.armorPiercing_;

        // Critical hit?!
        if (enemyStats.AttemptCritical(attackRoll, playerStats_.criticalChance_))
        {
            damage     *= 2;
            armorPierce = (armorPierce + 1) * 2;
            enemyStats.AttemptDoDamage(damage, armorPierce);
            characterAnimator_.SetTrigger("Critical");
            enemy.characterAnimator_.SetTrigger("Stumble");
            player_Attack.Invoke(enemy, "Critical");
        }
        else
        {
            if (!enemyStats.AttemptDodge(attackRoll + playerStats_.attackRating_))
            {
                enemyStats.AttemptDoDamage(damage, armorPierce);
                characterAnimator_.SetTrigger("Swing");
                enemy.characterAnimator_.SetTrigger("Stumble");
                player_Attack.Invoke(enemy, "Hit");
            }
            else
            {
                characterAnimator_.SetTrigger("Swing");
                enemy.characterAnimator_.SetTrigger("Dodge");
                player_Attack.Invoke(enemy, "Dodge");
            }
        };
        if (enemyStats.health <= 0)
        {
            enemy.Die((playerObj_.transform.position - enemy.transform.position).normalized);
            PlayerManager.instance_.AddXP(enemyStats.reference_);
        }

        yield return(new WaitForSeconds(0.5f));

        EndTurn();
        isMoving_ = false;
    }
Exemplo n.º 2
0
 public void EnableAttacking()
 {
     //Debug.Log("ATTACK");
     inAttack        = true;
     hitbox.isActive = true;
     OnAttack.Invoke();
 }
Exemplo n.º 3
0
    public override void OnPointerUp(PointerEventData eventData)
    {
        AttackEvent?.Invoke();

        background.gameObject.SetActive(false);
        base.OnPointerUp(eventData);
    }
Exemplo n.º 4
0
 public void OnAttack(InputAction.CallbackContext context)
 {
     if (context.phase == InputActionPhase.Performed)
     {
         AttackEvent.Invoke();
     }
 }
Exemplo n.º 5
0
        //need to proc when attack is cut too :x
        protected virtual void OnAttackEnd()
        {
            //Debug.Log("End");

            m_animator.SetBool("Attacking", false);
            OnAttackStateEvent.Invoke(false);
            OnAttackEndEvent.Invoke(m_attackType);
        }
Exemplo n.º 6
0
 public void AddAmmo(float i)
 {
     currentAmmo += i;
     if (OnAddAmmo != null)
     {
         OnAddAmmo.Invoke();
     }
 }
Exemplo n.º 7
0
 void Update()
 {
     if (!pauseManager.IsPaused() && attackQueue.Count > 0)
     {
         Attack attack = attackQueue[0];
         attackQueue.Remove(attack);
         attackEvent.Invoke(attack);
     }
 }
Exemplo n.º 8
0
        protected virtual void OnAttackStart(AttackStruct newStruct)
        {
            //Debug.Log("Start");
            m_attackType = (AttackType)m_animator.GetInteger("AttackType");
            //Debug.Log("Attack type = " + m_attackType);
            m_currAttackStruct = newStruct;

            m_animator.SetBool("Attacking", true);
            OnAttackStateEvent.Invoke(true);
            OnAttackBeginEvent.Invoke(m_attackType);
        }
 private void shoot()
 {
     if (Time.time > _nextFire)
     {
         if (AttackEvent != null)
         {
             AttackEvent.Invoke();
         }
         _nextFire = Time.time + _fireRate;
     }
 }
Exemplo n.º 10
0
    public void Attack(MoveObject move)
    {
        print(Pokemon.name + " used " + move.name + "!");
        OnAttack.Invoke(Pokemon, move);

        //    // TODO remove null check
        //    if(move != null)
        //    {
        //        print(Pokemon.name + " used " + move.name + "!");
        //        messageController.ShowMessage(Pokemon.name + " used " + move.name + "!");
        //        enemyBattlePokemon.TakeDamage(Pokemon, move);
        //    }
    }
Exemplo n.º 11
0
        private void OnTriggerEnter2D(Collider2D collision)
        {
            Unit target = collision.gameObject.GetComponent <Unit>();

            if (target != null)
            {
                if (_attakced.Contains(target) == false)
                {
                    _attakced.Add(target);
                    onAttack.Invoke(target);
                }
            }
        }
Exemplo n.º 12
0
    public void OnAttack(InputAction.CallbackContext context)
    {
        switch (context.phase)
        {
        case InputActionPhase.Performed:
            AttackEvent.Invoke();
            break;

        case InputActionPhase.Canceled:
            AttackCanceledEvent.Invoke();
            break;
        }
    }
Exemplo n.º 13
0
        private void OnTriggerEnter2D(Collider2D co)
        {
            if (exclusionTag.Equals(co.tag))
            {
                return;
            }
            var attacked = co.gameObject.GetComponent <AttackableObject2D>();

            if (attacked)
            {
                attacked.Attacked(this);
                onAttack.Invoke(attacked);
            }
        }
Exemplo n.º 14
0
    protected void FixedUpdate()
    {
        if (!GameManager.gameOver)          // If the game isn't over
        {
            if (_timer <= 0)                // If target is null and attack timer is done
            {
                _target = CheckForTarget(); // Try to set target
                if (_target != null)
                {
                    OnAttack.Invoke();
                    _timer = _timeOut;
                }
            }

            else if (_timer > 0)          // If the attack timer isn't done
            {
                _timer -= Time.deltaTime; // Decrease attack timer by the difference between the last and the current frame
            }
        }
    }
    protected override void Attack()
    {
        // check if player is already attacking
        bool isAttacking = animHandler.IsStateByTag("Attack"); // REFACTOR: Use BusyState instead

        if (!canInitiateAttack(isAttacking))
        {
            return;
        }
        CalculateAttackComboIndex(isAttacking);
        AttackEvent.Invoke();
        if (CurrentBusyState == BusyState.ATTACK || CurrentBusyState == BusyState.NONE)
        {
            if (busyRoutine != null)
            {
                StopCoroutine(busyRoutine);
            }
            busyRoutine = StartCoroutine(processAction(attackCombo[AttackComboIndex], BusyState.ATTACK));
        }
    }
Exemplo n.º 16
0
    protected virtual IEnumerator Attack()
    {
        WaitForSeconds Wait = new WaitForSeconds(AttackDelay);

        yield return(Wait);

        IDamageable closestDamageable = null;
        float       closestDistance   = float.MaxValue;

        while (Damageables.Count > 0)
        {
            for (int i = 0; i < Damageables.Count; i++)
            {
                Transform damageableTransform = Damageables[i].GetTransform();
                float     distance            = Vector3.Distance(transform.position, damageableTransform.position);

                if (distance < closestDistance)
                {
                    closestDistance   = distance;
                    closestDamageable = Damageables[i];
                }
            }

            if (closestDamageable != null)
            {
                OnAttack?.Invoke(closestDamageable);
                closestDamageable.TakeDamage(Damage);
            }

            closestDamageable = null;
            closestDistance   = float.MaxValue;

            yield return(Wait);

            Damageables.RemoveAll(DisabledDamageables);
        }

        AttackCoroutine = null;
    }
Exemplo n.º 17
0
    protected virtual void OnExchange2()
    {
        if (decision == Decision.Attack)
        {
            AttackEvent?.Invoke();
        }

        if ((preCoeffs[1].exchangeResult == ExchangeResult.GetHit) && !m_dead)    // если не помер после первого удара
        {
            GetHitEvent?.Invoke(2);                                               // то принимаем второй
            if (_HP.TakeDamage(/*damage2*/ gotDamage))
            {
                InvokeDeathEvent();
            }
        }

        if (((decision == Decision.ChangeSwordShield) || (decision == Decision.ChangeSwordSword) || (decision == Decision.ChangeTwoHandedSword)) &&
            !m_dead)
        {
            ChangeEvent?.Invoke();
        }
        else
        {
            if (preCoeffs[1].exchangeResult == ExchangeResult.Parry)
            {
                ParryEvent?.Invoke(2);
            }
            if (preCoeffs[1].exchangeResult == ExchangeResult.Block)
            {
                BlockEvent?.Invoke(2);
            }
        }

        if (preCoeffs[1].exchangeResult == ExchangeResult.Evade)
        {
            EvadeEvent?.Invoke(2);
        }
    }
Exemplo n.º 18
0
 public void OnAttackRemoteEvent(SWNetworkMessage msg)
 {
     OnAttack.Invoke(msg);
 }
Exemplo n.º 19
0
 private void OnAttackBtnClicked(IPlayerUi playerUi)
 {
     playerUi.DisableAttackBtnForTime(AttackDelay);
     AttackEvent?.Invoke(this, playerUi.Id);
 }
Exemplo n.º 20
0
 public void DisableAttacking()
 {
     inAttack        = false;
     hitbox.isActive = false;
     OnExitAttack.Invoke();
 }
Exemplo n.º 21
0
 public void Damage()
 {
     this.health = GetDamage(this.health, damage);
     AttackEvent?.Invoke();
 }
Exemplo n.º 22
0
        public void Attack(Unit target)
        {
            AttackEventArgs args = new AttackEventArgs(target, Damage);

            AttackEvent?.Invoke(this, args);
        }
Exemplo n.º 23
0
 public void OnAttack(float damage)
 {
     GetComponent <Animator>().SetTrigger("Attack");
     AttackEvent?.Invoke(damage);
 }
Exemplo n.º 24
0
        public void Attack()
        {
            float dmg = 0;

            attackEvent.Invoke(dmg);
        }
Exemplo n.º 25
0
 // Calls PreAttack, Attack, and PostAttack events so they go in order
 public void AttackOrder(AttackEventArgs attackEventArgs)
 {
     PreAttackEvent?.Invoke(attackEventArgs);
     AttackEvent?.Invoke(attackEventArgs);
     PostAttackEvent?.Invoke(attackEventArgs);
 }
Exemplo n.º 26
0
 public void PlayAttackEvent() => AttackEvent?.Invoke();
Exemplo n.º 27
0
 public void Attack(Damageable _damageable)
 {
     m_attackEvent.Invoke(_damageable);
     _damageable.Damage(m_healthDamages, m_stunDamages);
 }
Exemplo n.º 28
0
 public void Attack(Vector2 direction)
 {
     AttackEvent?.Invoke(this);
 }