Пример #1
0
    // Start is called before the first frame update
    void Awake()
    {
        wolfHunting = false;
        wolf1button.onClick.AddListener(Wolf1Clicked);
        wolf2button.onClick.AddListener(Wolf2Clicked);
        wolf3button.onClick.AddListener(Wolf3Clicked);
        wolf4button.onClick.AddListener(Wolf4Clicked);
        wolf5button.onClick.AddListener(Wolf5Clicked);
        huntingButton.onClick.AddListener(huntingClicked);
        choose1.onClick.AddListener(choose1Clicked);
        choose2.onClick.AddListener(choose2Clicked);
        close.onClick.AddListener(CloseClicked);
        numberOfMeatText.text       = Meat.ToString();
        numberOfWhiteFangsText.text = WhiteFangs.ToString();
        numberOfGoldFangsText.text  = GoldFangs.ToString();

        wolfScreen.gameObject.SetActive(false);
        notenough.gameObject.SetActive(false);
        dieInfo.gameObject.SetActive(false);
        huntInfo.gameObject.SetActive(false);
        wolfScreenTitle = wolfScreen.GetComponentInChildren <Text>();
    }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        //huntingCounter += Time.deltaTime;
        //Debug.Log(huntingCounter);


        if (wolfScreen.gameObject.active && (Input.GetMouseButton(1) || Input.GetButton("Cancel")))
        {
            wolfScreen.SetActive(false);
            notenough.gameObject.SetActive(false);
        }
        numberOfMeatText.text       = Meat.ToString();
        numberOfWhiteFangsText.text = WhiteFangs.ToString();
        numberOfGoldFangsText.text  = GoldFangs.ToString();

        #region meat consumption



        consumption  = wolf1.GetComponent <Wolf>().strength + wolf2.GetComponent <Wolf>().strength + wolf3.GetComponent <Wolf>().strength + wolf4.GetComponent <Wolf>().strength + wolf5.GetComponent <Wolf>().strength;
        consumption  = consumption / 7;
        consumption *= 3;

        numerOfMeatConsumption.text = "-" + consumption.ToString() + " /20s";

        if (counter >= 20)
        {
            if (Meat > 0)
            {
                Meat -= consumption;
            }
            else
            {
                Meat = 0;
            }

            counter = 0;
        }
        else
        {
            counter += Time.deltaTime;
        }
        if (Meat <= 0)
        {
            dieCounter  -= Time.deltaTime;
            secondsTodie = (int)dieCounter;
            dieInfo.text = "Your wolves die in " + secondsTodie.ToString() + "s";
            dieInfo.gameObject.SetActive(true);

            if (secondsTodie <= 0)
            {
                Destroy(wolf1, 1);
                Destroy(wolf2, 1);
                Destroy(wolf3, 1);
                Destroy(wolf4, 1);
                Destroy(wolf5, 1);
                // GameOver();  // okno z przegraną
            }
        }
        else
        {
            dieCounter = 45.0f;
            dieInfo.gameObject.SetActive(false);
        }

        #endregion
    }