예제 #1
0
    protected override void Update()
    {
        base.Update();

        while (mTargets.Count > 0)
        {
            EnemyController aEnemy = mTargets.Dequeue();
            aEnemy.AddDamage(Damage * Time.deltaTime);
        }
    }
예제 #2
0
    protected void OnTriggerEnter(Collider other)
    {
        EnemyController aEnemy = other.gameObject.GetComponent <EnemyController>();

        if (aEnemy != null && !aEnemy.IsDead())
        {
            aEnemy.AddDamage(Damage);
            Destroy(gameObject);
        }
    }
예제 #3
0
    // Update is called once per frame
    void OnTriggerEnter(Collider collider)
    {
        if (collider.CompareTag("Obstacle"))
        {
            Rigidbody body = collider.attachedRigidbody;
            if (body == null || body.isKinematic)
            {
                return;
            }
            Vector3 hitDir = new Vector3(transform.forward.x, 0, transform.forward.z);
            body.velocity = hitDir * 12f;
        }

        if (collider.CompareTag("Enemy"))
        {
            print("player: smash");
            EnemyController enemy = collider.gameObject.GetComponent <EnemyController>();
            enemy.AddDamage(10, enemy.transform.position - transform.position);
        }
    }