Exemple #1
0
 // Start is called before the first frame update
 void Start()
 {
     eating               = GameObject.Find("Eat Sound Effect").GetComponent <AudioSource>();
     drinking             = GameObject.Find("Drink Sound Effect").GetComponent <AudioSource>();
     cam                  = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>();
     thirdPersonLogic     = gameObject.GetComponent <RabbitLogic>();
     thirdPersonLogicLion = gameObject.GetComponent <LionLogic>();
     //get character controller
     controller = GetComponent <CharacterController>();
     AddAnimals.worldRabbit++;
     //InvokeRepeating("decreaseHunger", 1.0f, 1.0f);
 }
Exemple #2
0
    // Start is called before the first frame update. Each rabbit has the script so it runs for each one
    void Awake()
    {
        theLogic = gameObject.GetComponent <LionLogic>();


        controller = GetComponent <CharacterController>();

        //Set random initial rotation. Which way rabbit is facing
        heading = Random.Range(0, 360);
        //Changes the angle
        transform.eulerAngles = new Vector3(0, heading, 0);
        //Delays 1 sec
        StartCoroutine(NewHeading());
    }
    // Update is called once per frame
    void Update()
    {
        if (freeLookCamera.Follow.gameObject.CompareTag("lion") && freeLookCamera.Follow.gameObject != null)
        {
            lionHungerThirstValues = freeLookCamera.Follow.gameObject.GetComponent <LionLogic>();
            hungerSlide.value      = lionHungerThirstValues.hunger / 100;
            thirstSlide.value      = lionHungerThirstValues.thirst / 100;
            attraction.value       = lionHungerThirstValues.attraction / 100;
            Debug.Log(lionHungerThirstValues.hunger);
        }
        else if (freeLookCamera.Follow.gameObject.CompareTag("rabbit") && freeLookCamera.Follow.gameObject != null)
        {
            rabbitHungerThirstValues = freeLookCamera.Follow.gameObject.GetComponent <RabbitLogic>();
            hungerSlide.value        = rabbitHungerThirstValues.hunger / 100;
            thirstSlide.value        = rabbitHungerThirstValues.thirst / 100;
            attraction.value         = rabbitHungerThirstValues.attraction / 100;
        }

        time += Time.deltaTime;

        if (AddAnimals.worldRabbit >= 0)
        {
            populationRabbit.text = "Rabbits: " + AddAnimals.worldRabbit;
        }
        else
        {
            populationRabbit.text = "Rabbits: " + 0;
        }

        if (AddAnimals.worldLion >= 0)
        {
            populationLion.text = "Lions: " + AddAnimals.worldLion;
        }
        else
        {
            populationLion.text = "Lions: " + 0;
        }

        timeText.text = "" + Mathf.Round(time * 100) / 100;
    }