/*
     * The sealion attempts to catch a given fish
     *
     * @param fish The fish the sealion is catching
     */
    private IEnumerator TryCatchFishCoroutine(Fish fish)
    {
        // How likely we are to catch fish is dependent on what size the fish is
        // Determine that now
        float        catchRate;
        float        weight;
        FishGenePair sizeGenePair = fish.GetGenome()[FishGenome.GeneType.Size];

        switch (sizeGenePair.momGene)
        {
        case FishGenome.X when sizeGenePair.dadGene == FishGenome.X:
            catchRate = femaleCatchRate;
            weight    = 2f;   //4
            Debug.Log("bbCatchR=" + catchRate + "; weight=" + weight);
            break;

        case FishGenome.X when sizeGenePair.dadGene == FishGenome.Y:
            catchRate = maleCatchRate;
            weight    = 9f;   //15
            Debug.Log("BBCatchR=" + catchRate + "; weight=" + weight);
            break;

        default:
            catchRate = maleCatchRate;
            weight    = 6f;   //9
            break;
        }
        Debug.Log("SeaLionCatch: MaleCR=" + maleCatchRate + "FemCR=" + femaleCatchRate);

        // Figure out whether the fish will be caught or not
        bool caught = Random.Range(0f, 1f) <= catchRate;

        // Handle fish being caught
        if (caught)
        {
            // Tell the fish that it is being caught
            fish.StartCatch();

            // Trigger Water Splash effect on fish
            fish.waterSplash.Play();
            fish.swimSpeed            = 0;
            fish.fishRenderer.enabled = false;
            yield return(new WaitForSeconds(2));

            // Actually catch the fish
            fish.Catch();
            caughtFish.Add(fish);
        }
        // Fish escaped -- just wait for end of action
        else
        {
            yield return(new WaitForSeconds(timePerApplyEffect));
        }
    }
Exemplo n.º 2
0
    /**
     * Display attempt to catch fish
     */
    private IEnumerator TryCatchFishCoroutine(Fish fish)
    {
        // how likely we are to catch fish is dependent on what size the fish is
        // determine that now
        float        catchRate;
        FishGenePair sizeGenePair = fish.GetGenome()[FishGenome.GeneType.Size];

        if (sizeGenePair.momGene == FishGenome.b && sizeGenePair.dadGene == FishGenome.b)
        {
            catchRate = currentSmallCatchRate;
        }
        else if (sizeGenePair.momGene == FishGenome.B && sizeGenePair.dadGene == FishGenome.B)
        {
            catchRate = currentMediumCatchRate;
        }
        else
        {
            catchRate = currentLargeCatchRate;
        }

        // figure out whether the fish will be caught or not
        bool caught = Random.Range(0f, 1f) <= catchRate;

        // do setup for catch attempt line visualizer
        catchAttemptFish = fish;

        Destroy(catchAttemptLine.material);
        catchAttemptLine.material = caught ? hitLineMaterial : missLineMaterial;

        catchAttemptLine.enabled = true;

        // handle fish being caught
        if (caught)
        {
            // tell the fish that it is being caught
            fish.StartCatch();

            // make the fish flash  for a bit
            SkinnedMeshRenderer fishRenderer = fish.GetComponentInChildren <SkinnedMeshRenderer>();
            for (int i = 0; i < numFlashesPerCatch; i++)
            {
                Material oldMaterial = fishRenderer.material;
                fishRenderer.material = flashMaterial;
                yield return(new WaitForSeconds((float)timePerApplyEffect / numFlashesPerCatch / 2f));

                Destroy(fishRenderer.material);
                fishRenderer.material = oldMaterial;
                yield return(new WaitForSeconds((float)timePerApplyEffect / numFlashesPerCatch / 2f));
            }

            // actually catch the fish
            fish.Catch();
            caughtFish.Add(fish);
        }
        // fish escaped -- just wait for end of action
        else
        {
            yield return(new WaitForSeconds(timePerApplyEffect));
        }

        // end the catch attempt line
        catchAttemptLine.enabled = false;
    }
Exemplo n.º 3
0
    /**
     * Display attempt to catch fish
     *
     * @param fish The fish the fisherman is trying to catch
     */
    private IEnumerator TryCatchFishCoroutine(Fish fish)
    {
        // How likely we are to catch fish is dependent on what size the fish is
        // Determine that now
        float        catchRate;
        float        weight;
        FishGenePair sizeGenePair = fish.GetGenome()[FishGenome.GeneType.Size];

        switch (sizeGenePair.momGene)
        {
        case FishGenome.b when sizeGenePair.dadGene == FishGenome.b:
            catchRate = smallCatchRate;
            weight    = 2f;   //4
            //Debug.Log("bbCatchR=" + catchRate + "; weight=" + weight);
            break;

        case FishGenome.B when sizeGenePair.dadGene == FishGenome.B:
            catchRate = largeCatchRate;
            weight    = 9f;   //15
            //Debug.Log("BBCatchR=" + catchRate + "; weight=" + weight);
            break;

        default:
            catchRate = mediumCatchRate;
            weight    = 6f;   //9
            //Debug.Log("BbCatchR=" + catchRate + "; weight=" + weight);
            break;
        }
        Debug.Log("TryCatchFishCoroutine: cScr=" + smallCatchRate + "; cMcr=" + mediumCatchRate + "; cLcr=" + largeCatchRate);


        // Figure out whether the fish will be caught or not
        bool caught = Random.Range(0f, 1f) <= catchRate;

        // Do setup for catch attempt line visualizer
        catchAttemptFish = fish;

        Destroy(catchAttemptLine.material);
        catchAttemptLine.material = caught ? hitLineMaterial : missLineMaterial;

        catchAttemptLine.enabled = true;

        // Handle fish being caught
        if (caught)
        {
            // Tell the fish that it is being caught
            fish.StartCatch();

            // Trigger Water Splash effect on fish
            fish.waterSplash.Play();
            fish.swimSpeed = 0;
            yield return(new WaitForSeconds(1));

            fish.fishRenderer.enabled = false;
            yield return(new WaitForSeconds(1));

            // Actually catch the fish
            fish.Catch();
            caughtFish.Add(fish);

            // Add Appropriate Funds to Bank
            ManagerIndex.MI.MoneyManager.AddCatch(weight);

            // Increase this angler's fish caught total
            fishCaught++;
        }
        // Fish escaped -- just wait for end of action
        else
        {
            yield return(new WaitForSeconds(timePerApplyEffect));
        }

        // End the catch attempt line
        catchAttemptLine.enabled = false;
    }