示例#1
0
    /// <summary>
    ///
    /// shoot method to play particle and audio
    /// also send a raycast out to the target - using TargetScript
    /// if target is not null, target to take damage
    /// </summary>
    void Shoot()
    {
        gunParticle.Play();
        gunAudio.Play();

        RaycastHit hit;

        if (Physics.Raycast(transform.position, transform.forward, out hit, range))
        {
            JavaTarget1 target  = hit.transform.GetComponent <JavaTarget1>();
            MarkovChain target2 = hit.transform.GetComponent <MarkovChain>();

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

            if (target2 != null)
            {
                target2.DamageToTarget2(damage);
            }
        }
    }
示例#2
0
 void Awake()
 {
     Target = gameObject.GetComponentInChildren <JavaTarget1>();
 }