示例#1
0
    private void OnTriggerEnter(Collider other)
    {
        HarpoonScript h = other.GetComponent <HarpoonScript>();

        if (h)
        {
            if (h.harpoonFlying)
            {
                Debug.Log("Harpoon hit!!!");
                // do stuff
            }
        }
    }
示例#2
0
    //[SerializeField] AudioClip damageSoundClip;
    //[SerializeField] AudioClip deathSoundClip;
    //[SerializeField] AudioClip harpoonLaunchClip;
    //[SerializeField] AudioClip harpoonReelClip;
    //[SerializeField] AudioClip shipDingClip;

    // Start is called before the first frame update
    void Start()
    {
        // velocity = new Vector3(0, 0, 0);
        body = this.GetComponent <Rigidbody>();

        laserText          = laserTextObject.GetComponent <Text>();
        laserHeatText      = laserHeatTextObject.GetComponent <Text>();
        torpedoText        = torpedoTextObject.GetComponent <Text>();
        torpedoCountText   = torpedoCountTextObject.GetComponent <Text>();
        hullText           = hullTextObject.GetComponent <Text>();
        hullPercentageText = hullPercentageTextObject.GetComponent <Text>();
        harpoonText        = harpoonTextObject.GetComponent <Text>();

        laserShotTimer       = 0;
        laserHeat            = 0;
        laserIsOverheated    = false;
        laserBarrelAlternate = false;

        health = maxHealth;

        torpedoCount = torpedoLimit;

        harpoonBody = harpoon.GetComponent <Rigidbody>();

        harpoonAttachmentPoint    = gameObject.transform.InverseTransformPoint(harpoon.transform.position);
        harpoonAttachmentRotation = Quaternion.Inverse(gameObject.transform.rotation) * harpoon.transform.rotation;

        harpoonRopeJoint = harpoon.GetComponent <ConfigurableJoint>();

        harpoonScript = harpoon.GetComponent <HarpoonScript>();

        harpoonRopeLength = harpoonRopeMaxLength;

        harpoonRopeRenderer = gameObject.GetComponent <LineRenderer>();

        deathScreenFadeImage = deathScreenFadeObject.GetComponent <Image>();

        harpoonReeling = false;

        ////AudioSource[] audioSources = gameObject.GetComponents<AudioSource>();
        ////damageAudioSource = audioSources[0];
        //damageAudioSource = gameObject.AddComponent<AudioSource>();
        //damageAudioSource.clip = damageSoundClip;
        //damageAudioSource.loop = false;

        //deathAudioSource = gameObject.AddComponent<AudioSource>();
        //deathAudioSource.clip = deathSoundClip;
        //deathAudioSource.loop = false;


        ////harpoonLaunchAudioSource = audioSources[1];
        //harpoonLaunchAudioSource = gameObject.AddComponent<AudioSource>();
        //harpoonLaunchAudioSource.clip = harpoonLaunchClip;
        //harpoonLaunchAudioSource.loop = false;

        //// harpoonReelAudioSource = audioSources[2];
        //harpoonReelAudioSource = gameObject.AddComponent<AudioSource>();
        //harpoonReelAudioSource.clip = harpoonReelClip;
        //harpoonReelAudioSource.loop = true;

        //shipDingAudioSource = gameObject.AddComponent<AudioSource>();
        //shipDingAudioSource.clip = shipDingClip;
        //shipDingAudioSource.loop = false;

        ReloadHarpoon();
    }