示例#1
0
    // the bobber comes into the water
    void OnInWater()
    {
        // we launch the timer only if there is an hook attached to the bobber
        Appat actualAppat = PoissonFishing.instance.bobber.GetComponent <Bobber>().actualAppat;

        if (actualAppat != null)
        {
            // the timer has not been launched, so we launch it
            if (FishTimer.getCooldown() == 0)
            {
                TMax = Random.Range(actualAppat.minimumWaitingTime, actualAppat.maximumWaitingTime);
                Tact = TMax;
                FishTimer.start(TMax);
            }
            // the timer has been paused, we release it
            else
            {
                float tempsAttendu = FishTimer.getCooldown();
                float tempsActuel  = TMax - (tempsAttendu / Tact) * TMax;

                if (tempsActuel < Tact)
                {
                    Tact = tempsActuel;
                }

                if (Tact <= minimumFishingTime)
                {
                    Tact += minimumFishingTime;
                }

                FishTimer.start(Tact);
            }
        }
    }
示例#2
0
 public void EnleverAppat(Appat appat)
 {
     for (int i = 0; i < listeAppats.Length; i++)
     {
         if (appat == listeAppats[i])
         {
             listeInTheBox[i] = false;
         }
     }
 }
示例#3
0
 public void RespawnAppat(Appat appat)
 {
     for (int i = 0; i < listeAppats.Length; i++)
     {
         if (appat == listeAppats[i])
         {
             listeInTheBox[i] = true;
             appat.GetComponent <Rigidbody>().isKinematic = true;
             //appat.transform.parent = this.transform;
             appat.transform.position = listePositionInitialAppats[i].position;
         }
     }
 }
示例#4
0
    public void attachAppat(Appat appat)
    {
        if (actualAppat != null)
        {
            detachAppat();
        }

        actualAppat                    = appat;
        actualAppat.isAttached         = true;
        actualAppat.transform.position = GetComponentInChildren <AppatSign>().transform.position;

        GetComponentInChildren <AppatSign>().GetComponentInChildren <MeshRenderer>().enabled = false;
    }
示例#5
0
    private void OnHookFish()
    {
        // if there is already an fish, we remove before adding a new one
        if (fishInWater != null)
        {
            releaseFish();
        }

        // initialyze fishManagement values based on infos in appat.fish
        Appat appat = bobber.GetComponent <Bobber>().actualAppat;

        indexOfFishHooked            = appat.getRandomFishIndex();
        fishingManagement.difficulty = appat.typesPoisson[indexOfFishHooked].GetComponent <Poisson>().difficulty;
        poseFishing.difficultyFish   = appat.typesPoisson[indexOfFishHooked].GetComponent <Poisson>().difficulty;
        tractionSpeedMultiplicator   = appat.typesPoisson[indexOfFishHooked].GetComponent <Poisson>().tractionForce;



        // generate new fish points
        Vector3 initialBobberPosition = bobber.position;

        // if bobber to close to the berge, we put the bobber farther
        if (fishingManagement.getDistanceBerge(bobber.position.z) < minimumDistanceFromBerge)
        {
            initialBobberPosition = new Vector3(bobber.position.x, bobber.position.y, minimumDistanceFromBerge);
        }
        fishingManagement.generateFishPoints(playerPosition.position, initialBobberPosition);

        // initialyze the fish position
        Vector3 initialPosition = new Vector3(bobber.position.x, bobber.position.y - fishDepth, bobber.position.z);

        fishInWater = initFishInWater(initialPosition);

        // get distance between the bobber and the berge
        Vector3 fishInWater2D = new Vector3(fishInWater.transform.position.x, fishingManagement.waterPlane.position.y, fishInWater.transform.position.z);
        Vector3 player2D      = fishingManagement.getPlayerPositionFromBerge(playerPosition.position);

        initialDistanceBetweenBobberAndBerge = fishingManagement.getDistanceOnProjectionDirection(initialBobberPosition, player2D);

        // init the first pose
        initCurrentStep();

        fishEscapingTimer.start(fishEscapingFrequence);

        hapticDistance.enabled = true;
        hapticDistance.hand    = poseFishing.getHoldingHand();
    }
示例#6
0
 public void detachAppat()
 {
     actualAppat.releaseAppat();
     actualAppat = null;
 }