コード例 #1
0
ファイル: PlayerController.cs プロジェクト: wolfrug/ldjam42
    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;
    }
コード例 #2
0
ファイル: Weapon.cs プロジェクト: AlchSet/GBZeldoid
 public void EnableAttacking()
 {
     //Debug.Log("ATTACK");
     inAttack        = true;
     hitbox.isActive = true;
     OnAttack.Invoke();
 }
コード例 #3
0
    public override void OnPointerUp(PointerEventData eventData)
    {
        AttackEvent?.Invoke();

        background.gameObject.SetActive(false);
        base.OnPointerUp(eventData);
    }
コード例 #4
0
 public void OnAttack(InputAction.CallbackContext context)
 {
     if (context.phase == InputActionPhase.Performed)
     {
         AttackEvent.Invoke();
     }
 }
コード例 #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);
        }
コード例 #6
0
 public void AddAmmo(float i)
 {
     currentAmmo += i;
     if (OnAddAmmo != null)
     {
         OnAddAmmo.Invoke();
     }
 }
コード例 #7
0
ファイル: AttackManager.cs プロジェクト: nasalomons/Sol-Djers
 void Update()
 {
     if (!pauseManager.IsPaused() && attackQueue.Count > 0)
     {
         Attack attack = attackQueue[0];
         attackQueue.Remove(attack);
         attackEvent.Invoke(attack);
     }
 }
コード例 #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);
        }
コード例 #9
0
 private void shoot()
 {
     if (Time.time > _nextFire)
     {
         if (AttackEvent != null)
         {
             AttackEvent.Invoke();
         }
         _nextFire = Time.time + _fireRate;
     }
 }
コード例 #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);
        //    }
    }
コード例 #11
0
ファイル: KnifeLight.cs プロジェクト: zlxkmc/Guild
        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);
                }
            }
        }
コード例 #12
0
    public void OnAttack(InputAction.CallbackContext context)
    {
        switch (context.phase)
        {
        case InputActionPhase.Performed:
            AttackEvent.Invoke();
            break;

        case InputActionPhase.Canceled:
            AttackCanceledEvent.Invoke();
            break;
        }
    }
コード例 #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);
            }
        }
コード例 #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
            }
        }
    }
コード例 #15
0
    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));
        }
    }
コード例 #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;
    }
コード例 #17
0
ファイル: HeroManager.cs プロジェクト: ma-chu/BattleRoyal
    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);
        }
    }
コード例 #18
0
 public void OnAttackRemoteEvent(SWNetworkMessage msg)
 {
     OnAttack.Invoke(msg);
 }
コード例 #19
0
 private void OnAttackBtnClicked(IPlayerUi playerUi)
 {
     playerUi.DisableAttackBtnForTime(AttackDelay);
     AttackEvent?.Invoke(this, playerUi.Id);
 }
コード例 #20
0
ファイル: Weapon.cs プロジェクト: AlchSet/GBZeldoid
 public void DisableAttacking()
 {
     inAttack        = false;
     hitbox.isActive = false;
     OnExitAttack.Invoke();
 }
コード例 #21
0
ファイル: Game.cs プロジェクト: Pasyagitka/OOTPiSP
 public void Damage()
 {
     this.health = GetDamage(this.health, damage);
     AttackEvent?.Invoke();
 }
コード例 #22
0
ファイル: Unit.cs プロジェクト: OOP-03376400/kpi_oop
        public void Attack(Unit target)
        {
            AttackEventArgs args = new AttackEventArgs(target, Damage);

            AttackEvent?.Invoke(this, args);
        }
コード例 #23
0
 public void OnAttack(float damage)
 {
     GetComponent <Animator>().SetTrigger("Attack");
     AttackEvent?.Invoke(damage);
 }
コード例 #24
0
        public void Attack()
        {
            float dmg = 0;

            attackEvent.Invoke(dmg);
        }
コード例 #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);
 }
コード例 #26
0
 public void PlayAttackEvent() => AttackEvent?.Invoke();
コード例 #27
0
 public void Attack(Damageable _damageable)
 {
     m_attackEvent.Invoke(_damageable);
     _damageable.Damage(m_healthDamages, m_stunDamages);
 }
コード例 #28
0
ファイル: Weapon.cs プロジェクト: Darkfafi/QuarantineGJ
 public void Attack(Vector2 direction)
 {
     AttackEvent?.Invoke(this);
 }