//Method to break a specific bone
    bool BreakBone(string bone, bool increase = true)
    {
        int breakLimit = maxBrokenBones;

        //arms and legs have a higher limit than other bones
        if (bone == "arms" || bone == "legs")
        {
            breakLimit *= armLegCount;
        }

        //check if bone has reached break limit
        if (brokenBones[bone] >= breakLimit)
        {
            return(false);
        }
        else
        {
            brokenBones[bone]++;
        }

        switch (bone)
        {
        case "arms":
            thisWeatherController.ChangePrecipitation(increase);
            break;

        case "legs":
            thisWeatherController.ChangeTemperature(increase);
            break;

        case "skull":

            break;

        case "neck":

            break;

        case "back":

            break;

        case "ribs":
            thisWeatherController.ChangeWind(increase);
            break;
        }

        return(true);
    }
예제 #2
0
    //Methods to break a specific bone
    //break bones that require a direction. default bone breaking method for bones without direction or increase/decrease
    void BreakBone(Bones bone, Direction dir = Direction.none)
    {
        if (!EnoughBones(bone))
        {
            return;
        }

        bool validBreak = false;

        //change weather accordingly and check for break validity
        switch (bone)
        {
        case Bones.ribs:
            validBreak = myWeatherController.ChangeWind(dir);
            // play the wind noise, cycling the toggle so it doesn't endlessly repeat
            if (windToggle == true)
            {
                wind.Play();                  // play the sound...
                //windToggle = false; // ...then make sure you don't immediately play it again
                Debug.Log("ping wind");
                if (wind.clip == null)
                {
                    Debug.Log("wind null af");
                }
            }

            /*else if (windToggle == false) {
             *      wind.Stop (); // stop the sound...
             *      windToggle = true; // and enable it to play again
             * }*/
            break;

        case Bones.skull:
            validBreak = myWeatherController.CreateLightning();
            // play the thunder noise, cycling the toggle so it doesn't play on repeat
            if (thunderToggle == true && validBreak)
            {
                thunder.Play();                  // play the sound...
                //thunderToggle = false; // ...then make sure you don't immediately play it again
            }

            /*if (thunderToggle == false) {
             *      thunder.Stop (); // stop the sound...
             *      thunderToggle = true; // and enable it to play again
             * }*/
            break;

        case Bones.neck:
            validBreak = true;
            break;
        }

        // play the bone-crunching noise, assuming it hasn't just been played
        if (cronchToggle == true && validBreak)
        {
            boneCronch.Play();              // play the sound...
        }

        //only break the bone if the break was valid
        if (validBreak)
        {
            brokenBones [(int)bone]++;
        }

        btnRibs.GetComponentInChildren <Text> ().text  = "Ribs:\t" + brokenBones [(int)Bones.ribs];
        btnSkull.GetComponentInChildren <Text> ().text = "Skull:\t" + brokenBones [(int)Bones.skull];

        int broken = 0;

        for (int i = 0; i < brokenBones.Length; i++)
        {
            broken += brokenBones [i];
        }
        currentBroken.text = "Bones Broken:\t\t" + broken;
    }