示例#1
0
    /**
     * A normal member to take action of Shooting with Soldier's weapon.
     * (e.g. Soldier was wrongly placed)
     */
    public void Shoot()
    {
        if (bulletCount > 0 && shootingEnabled)
        {
            shotParticles.Play();
            if (shootSound != null)
            {
                shootSound.Play(0);
            }

            shotTrajectileAnimator.Play(shotTrajectileAnimator.name);

            RaycastHit hit;

            if (Physics.Raycast(shootPoint.transform.position, shootPoint.transform.forward, out hit, 100, layerMask))
            {
                HealthControl healthControl = hit.transform.GetComponent <HealthControl>();
                if (healthControl != null)
                {
                    healthControl.TakeDamage(damage);
                }
            }
            bulletCount--;
        }

        if (bulletCount == 0)
        {
            grabMechansm.ActionFinished();
        }
    }
示例#2
0
    void OnCollisionEnter(Collision info)
    {
        switch (info.collider.gameObject.tag)
        {
        case "Team1Projectile":
            HandleProjectileCollision(info);
            break;

        case "Team2Projectile":
            HandleProjectileCollision(info);
            break;

        case "Mothership":
            HealthControl.TakeDamage(HealthControl.MaxHealth, HealthControl.MaxShields);
            break;

        case "Obstacle":
            HealthControl.TakeDamage(HealthControl.MaxHealth, HealthControl.MaxShields);
            break;
        }
    }
示例#3
0
    //On trigger (currently only trigerred by the 2D collider
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Debug.Log(collision.name);

        HealthControl target = collision.GetComponent <HealthControl>();

        if (target != null)
        {
            target.TakeDamage(damage);
        }

        if (collision.name != "ElectricBullet(Clone)")
        {
            Destroy(gameObject);
        }
    }
示例#4
0
 /// <summary>
 /// Trigger a hit on the damage zone
 /// </summary>
 /// <param name="damage"></param>
 /// <param name="damager"></param>
 public void Hit(int damage, GameObject damager)
 {
     damage = (int)(damage * multiplier);
     healthControl.TakeDamage(damage, damager);
 }