<commit_before>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class LifeBar : MonoBehaviour {

    public GameObject Life;
    public GameObject Hunger;
    public Color BarColor;

    private AudioSource sonCri;
    private AudioSource sonManger;
    private int timeMaxFaim = 3600;
    private int currentTimeFaim = 0;
	private GameObject Judy;
	private ActionsNew actions;
    private GameObject forms;

    // Use this for initialization
    void Start () {
        AudioSource[] sons = GetComponents<AudioSource>();
        sonCri = sons[0];
        sonManger = sons[1];
		Judy = GameObject.FindWithTag ("Player");
        forms = GameObject.Find("Forms");
		actions = Judy.GetComponent ("ActionsNew") as ActionsNew;
        Life.transform.Find("Mask").Find("Sprite").GetComponent<Image>().color = Color.red;
	}

    // Update is called once per frame (60 frames)
    void FixedUpdate () {
        //*****************PERTE DE VIE******************//
        //Si Judy a sa barre de vie à 0 : Mort
        if (Life.GetComponent<Scrollbar>().size <= 0f) {
            Judy.GetComponent<MovementController>().setDeath(true);
            actions.Death();
        }

        //Si Judy chute 
       if (Judy.GetComponent<Rigidbody>().velocity.y < 0 && Judy.GetComponent<Rigidbody>().velocity.magnitude > 100f)
        {
            Life.GetComponent<Scrollbar>().size -= 0.005f; 
        }

        //Si la barre de faim est vide
        if(Hunger.GetComponent<Scrollbar>().size == 0f)
        {
            if(currentTimeFaim == timeMaxFaim)
            {
                Life.GetComponent<Scrollbar>().size -= 0.1f; //valeur en pourcent (0.1f = 10%)
                currentTimeFaim = 0;
            }
            currentTimeFaim++;
        }

    }

    public float getSizeLifeBar()
    {
        return Life.GetComponent<Scrollbar>().size;
    }

    public void setSizeLifeBar(float size)
    {
        Life.GetComponent<Scrollbar>().size = size;
    }

    //*****************RECUPERATION DE VIE******************//
    public void Eat(float lifeBack)
    {
		sonManger.Play ();
        if (Hunger.GetComponent<Scrollbar>().size >= 1f)
        {
            Life.GetComponent<Scrollbar>().size += lifeBack;
        } else
        {
            Hunger.GetComponent<Scrollbar>().size += lifeBack;
        }
    }

    //*****************SE FAIT ATTAQUER******************//
    public void TakeDamages(float lifeLoosed)
    {
        GameObject playerRoot = GameObject.Find("Player");
        sonCri.Play();
        actions.Damage();
        //si forme puma, 50% de degats en plus
        if (playerRoot.GetComponent<FormsController>().getCurrentForm() == (int)Forms.id_puma)
        {
            Life.GetComponent<Scrollbar>().size -= lifeLoosed + lifeLoosed *0.5f;
        }
        else if (playerRoot.GetComponent<FormsController>().getCurrentForm() == (int)Forms.id_human)
        {
            Life.GetComponent<Scrollbar>().size -= lifeLoosed;
        } //si forme ours, 25% de degats en moins
        else if (playerRoot.GetComponent<FormsController>().getCurrentForm() == (int)Forms.id_bear)
        {
            Life.GetComponent<Scrollbar>().size -= lifeLoosed - lifeLoosed*0.25f;
        }
    }
}
<commit_msg>Pour que les transformations subissent des dommages.<commit_after>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class LifeBar : MonoBehaviour {

    public GameObject Life;
    public GameObject Hunger;
    public Color BarColor;

    private AudioSource sonCri;
    private AudioSource sonManger;
    private int timeMaxFaim = 3600;
    private int currentTimeFaim = 0;
	private GameObject Judy;
	private ActionsNew actions;
    private GameObject forms;

    // Use this for initialization
    void Start () {
        AudioSource[] sons = GetComponents<AudioSource>();
        sonCri = sons[0];
        sonManger = sons[1];
		Judy = GameObject.FindWithTag ("Player");
        forms = GameObject.Find("Forms");
		actions = Judy.GetComponent ("ActionsNew") as ActionsNew;
        Life.transform.Find("Mask").Find("Sprite").GetComponent<Image>().color = Color.red;
	}

    // Update is called once per frame (60 frames)
    void FixedUpdate () {
        //*****************PERTE DE VIE******************//
        //Si Judy a sa barre de vie à 0 : Mort
        if (Life.GetComponent<Scrollbar>().size <= 0f) {
            Judy.GetComponent<MovementController>().setDeath(true);
            actions.Death();
        }

        //Si Judy chute 
       if (Judy.GetComponent<Rigidbody>().velocity.y < 0 && Judy.GetComponent<Rigidbody>().velocity.magnitude > 100f)
        {
            Life.GetComponent<Scrollbar>().size -= 0.005f; 
        }

        //Si la barre de faim est vide
        if(Hunger.GetComponent<Scrollbar>().size == 0f)
        {
            if(currentTimeFaim == timeMaxFaim)
            {
                Life.GetComponent<Scrollbar>().size -= 0.1f; //valeur en pourcent (0.1f = 10%)
                currentTimeFaim = 0;
            }
            currentTimeFaim++;
        }

    }

    public float getSizeLifeBar()
    {
        return Life.GetComponent<Scrollbar>().size;
    }

    public void setSizeLifeBar(float size)
    {
        Life.GetComponent<Scrollbar>().size = size;
    }

    //*****************RECUPERATION DE VIE******************//
    public void Eat(float lifeBack)
    {
		sonManger.Play ();
        if (Hunger.GetComponent<Scrollbar>().size >= 1f)
        {
            Life.GetComponent<Scrollbar>().size += lifeBack;
        } else
        {
            Hunger.GetComponent<Scrollbar>().size += lifeBack;
        }
    }

    //*****************SE FAIT ATTAQUER******************//
    public void TakeDamages(float lifeLoosed)
    {
        GameObject playerRoot = GameObject.Find("Player");
        sonCri.Play();
        //si forme puma, 50% de degats en plus
        if (playerRoot.GetComponent<FormsController>().getCurrentForm() == (int)Forms.id_puma) {
            Life.GetComponent<Scrollbar>().size -= lifeLoosed + lifeLoosed *0.5f;
        }
        else if (playerRoot.GetComponent<FormsController>().getCurrentForm() == (int)Forms.id_human) {
            actions.Damage();
            Life.GetComponent<Scrollbar>().size -= lifeLoosed;
        } //si forme ours, 25% de degats en moins
        else if (playerRoot.GetComponent<FormsController>().getCurrentForm() == (int)Forms.id_bear) {
            Life.GetComponent<Scrollbar>().size -= lifeLoosed - lifeLoosed*0.25f;
        }
    }
}

{'fraction_non_alphanumeric': 0.14952279957582185, 'fraction_numerical': 0.011210422663232843, 'mean_word_length': 2.4101239669421486, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1663220', 'n_tokens_mistral': 2026, 'n_tokens_neox': 1916, 'n_words': 412}