Ejemplo n.º 1
0
    public void Fire(Vector3 firingLocation, Vector3 direction, Vector3 fxLocation)
    {
        Debug.Log("PierceBulletEffect: Firing!");
        RaycastHit[] targets = Physics.RaycastAll(firingLocation, direction, maxDistance);
        for (int i = 0; i < targets.Length; i++)
        {
            IDamageComponent target = targets[i].collider.GetComponent <IDamageComponent>();
            if (target != null)
            {
                target.TakeDamage(damage);
            }
        }

        if (targets.Length > 0)
        {
            if (BulletHit != null)
            {
                BulletHit();
            }
        }

        Debug.Log("PierceBulletEffect: Firing line from " + firingLocation + " to " + firingLocation + direction.normalized * maxDistance);
        line.SetPosition(0, fxLocation);
        line.SetPosition(1, firingLocation + direction.normalized * maxDistance);
        StartCoroutine(StartFireEffect());
    }
        public override void Destroy()
        {
            CollisionComponent.OnCollision -= Collided;
            CollisionComponent = null;
            DamageComponent = null;

            base.Destroy();
        }
Ejemplo n.º 3
0
        public override void Destroy()
        {
            CollisionComponent.OnCollision -= Collided;
            CollisionComponent              = null;
            DamageComponent = null;

            base.Destroy();
        }
Ejemplo n.º 4
0
    protected virtual void OnHit(IDamageComponent target)
    {
        target.TakeDamage(damage);
        gameObject.SetActive(false);

        if (BulletHit != null)
        {
            BulletHit();
        }
    }
        public override void Initialize()
        {
            //Subscribe to our ICollisionComponent.
            CollisionComponent = ParentGameObject.GetComponent<ICollisionComponent>();
            CollisionComponent.OnCollision += Collided;

            //Get a reference to our damage component.
            DamageComponent = ParentGameObject.GetComponent<IDamageComponent>();

            base.Initialize();
        }
Ejemplo n.º 6
0
    private void OnTriggerEnter(Collider other)
    {
        Debug.Log("FastBulletEffect: I'm hitting something!");
        IDamageComponent target = other.gameObject.GetComponent <IDamageComponent>();

        if (target != null)
        {
            Debug.Log("FastBulletEffect: It was the IDamageComponent of " + other.name);
            OnHit(target);
        }
    }
Ejemplo n.º 7
0
    void OnCollisionEnter(Collision collision)
    {
        Debug.Log("EnemyScript: I'm colliding with something");
        IDamageComponent player = collision.gameObject.GetComponent <IDamageComponent>();

        if (player != null)
        {
            Debug.Log("EnemyScript: It was the player, attacking!");
            player.TakeDamage(attackDamage);
        }
    }
Ejemplo n.º 8
0
        public override void Initialize()
        {
            //Subscribe to our ICollisionComponent.
            CollisionComponent              = ParentGameObject.GetComponent <ICollisionComponent>();
            CollisionComponent.OnCollision += Collided;

            //Get a reference to our damage component.
            DamageComponent = ParentGameObject.GetComponent <IDamageComponent>();

            base.Initialize();
        }
 public override void Initialize()
 {
     damageComponent = ParentGameObject.GetComponent<IDamageComponent>();
     base.Initialize();
 }