Esempio n. 1
0
    public void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Fish")
        {
            // only spawn chomp sound in if there are no other chomp sounds
            if (GameObject.FindGameObjectsWithTag("Chomp").Length == 0)
            {
                spawnChompSound.SpawnObject();
            }

            if (CatchesFish())
            {
                stopMoving = true;
                fishBitingEvent(gameObject,
                                () =>
                {
                    other.gameObject.transform.SetParent(targetParent);
                    valueOfFish.pointToAdd = valueOfFish.GetValue(other.gameObject.name);
                }
                                );
                //make you a child of the hook

                //might also want to disable movement script
            }
        }
    }
Esempio n. 2
0
    public bool EndedCasting()
    {
        if (!isBeingHeldDown)
        {
            return false;
        }

		// stop powerup sound and play casting sound
		spawnCastSound.SpawnObject ();
		powerupSound.Stop ();

        float percent = percentageCasting();
        float force = percent * castForce;
        var instance = Instantiate(lure, spawnPos.position, Quaternion.identity);

        spawnPos.GetComponent<KeepLineAttachedTo>().to = instance.transform;

        hookInstance = instance;
        hookInstance.gameObject.tag = "Hook";
        var catchFish = hookInstance.GetComponent<CatchFish>();
        catchFish.fishBitingEvent += (sender, catchFishFunc) =>
        {
            fishBitingEvent(sender, catchFishFunc);
        };

        var rigid = instance.GetComponent<Rigidbody>();
        rigid.AddForce(force * Vector3.Normalize(transform.forward +
            Vector3.up * Mathf.Sin((castAngle / 180.0f) * Mathf.PI)));

        isBeingHeldDown = false;
        castedEvent.Invoke();

        return true;

    }
Esempio n. 3
0
    public void AddPoint()
    {
        int point = valueOfFish.pointToAdd;

        valueOfFish.pointToAdd = 0;

        score += point;
        if (scoreDisplay)
        {
            scoreDisplay.text = score.ToString() + "/" + goalThreshold.threshhold;
        }
        collectFishSound.Play();
        textParticlePrefab.GetComponentInChildren <Text> ().text = "+" + point;
        textParticleSpawner.SpawnObject();
    }