Exemple #1
0
    // 玩家二攻击,玩家一受伤
    public void OnPlayerTwoAttack()
    {
        int damage = Random.Range(minDamage, maxDamage);

        playerTwo.Attack();
        playerOne.Damage(damage);
    }
        // PLayer attack action
        void attackAction(string name)
        {
            if (!isAttack && isGame)
            {
                attackAnim(gameData.Player.Attacks[name].Anim);

                PlayerAttack playerAttack = gameData.Player.Attacks[name];

                int damage = playerAttack.Damage(gameData.Player, gameData.Enemy);
                gameData.Enemy.HP -= damage;

                if (damage > 0)
                {
                    foreach (CriticalEffect criticalEffect in playerAttack.CriticalEffects)
                    {
                        if (criticalEffect.isEffect())
                        {
                            if (!gameData.EnemyCriticalEffects.Contains(criticalEffect))
                            {
                                gameData.EnemyCriticalEffects.Add(criticalEffect);
                            }
                        }
                    }
                }

                attackInfo(damage, name);

                updateStats();

                timerCanAttack.Start();
                timerEnemyAttack.Start();
            }
        }
Exemple #3
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.layer == LayerMask.NameToLayer("Enemy"))
     {
         if (attackedEnemies.Contains(collision.gameObject))
         {
             return;
         }
         attackedEnemies.Add(collision.gameObject);
         float damage = this.damage + (power ? boost : 0);
         damage = damage + Random.Range(-floatRange, floatRange);
         attack.Damage(collision.gameObject, damage, direction);
     }
 }
Exemple #4
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.layer != LayerMask.NameToLayer("Enemy"))
        {
            return;
        }
        if (enemies.Contains(other.gameObject))
        {
            return;
        }
        enemies.Enqueue(other.gameObject);
        StartCoroutine(ValidTarget());
        float direction = other.transform.position.x > transform.position.x ? 1f : -1f;
        float damage    = baseDamage + Random.Range(-floatArea, floatArea);

        attack.Damage(other.gameObject, damage, direction);
    }
Exemple #5
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.layer == LayerMask.NameToLayer("Enemy"))
     {
         if (attackedEnemies.Contains(collision.gameObject))
         {
             return;
         }
         attackedEnemies.Add(collision.gameObject);
         float damage = this.damage + Random.Range(-floatRange, floatRange);
         attack.Damage(collision.gameObject, damage, isReturning ? -direction : direction);
     }
     else if (isReturning && collision.gameObject.layer == LayerMask.NameToLayer("Player"))
     {
         PoolManager.GetInstance().ReturnDartPool(gameObject);
     }
 }