Пример #1
0
    void Start()
    {
        Button tt = t.GetComponent <Button>();

        //t = this.gameObject.GetComponent<button>();
        if (exit1)
        {
            tt.onClick.AddListener(exit);
        }
        else
        {
            tt.onClick.AddListener(start);
        }
    }
    public void resetButton(button b)
    {
        int chance = Random.Range(0, 100);

        if (chance < 35)
        {
            b.plantID = 0;
        }
        else if (chance < 70)
        {
            b.plantID = 1;
        }
        else if (chance < 85)
        {
            b.plantID = 2;
        }
        else
        {
            b.plantID = 3;
        }
        b.GetComponent <Image>().sprite        = plantIcons[b.plantID];
        b.GetComponent <Image>().enabled       = true;
        b.GetComponent <Button>().interactable = true;
    }
 public void killButton(button b)
 {
     b.GetComponent <Image>().enabled       = false;
     b.GetComponent <Button>().interactable = true;
 }
Пример #4
0
    void Update()
    {
        /* --- VARS --- */

        if (isFiring && !isCooling)
        {
            temperature += Time.deltaTime;
        }
        else
        {
            temperature -= Time.deltaTime * 1.5f;
        }
        if (temperature < 0f)
        {
            isCooling   = false;
            temperature = 0f;
        }
        isFiring = fireButton.GetComponent <button>().buttonPressed || Input.GetAxis("Jump") == 1;
        if (temperature >= maxFiretime)
        {
            isCooling = true;
        }
        heatOMeter.value = temperature / maxFiretime;

        heatAim.GetComponent <colorTint>().tint = isCooling;

        float s     = steering.value - steering.maxValue / 2f;
        float moveX = Math.Sign(s) * Math.Sign(Mathf.Floor(Math.Abs(s)));

        if (!steering.GetComponent <button>().buttonPressed)
        {
            steering.value += steering.maxValue / 2f - steering.value;
        }

        /* --- MOVEMENT --- */

        float   deltaX   = moveX * speed + Input.GetAxis("Horizontal") * speed;
        Vector3 movement = new Vector3(deltaX, 0, speedForv);

        movement *= Time.deltaTime;
        _charController.Move(movement);

        /* --- FIRING --- */

        if (isFiring && !flg && !isCooling)
        {
            // SceneManager.LoadScene(0);
            spawntime = Time.time;
            flg       = true;
            var shot = GameObject.Instantiate(bullet, transform.position + new Vector3(laserBias, 0f, 0f), transform.rotation);
            shot.GetComponent <bullet>().ship = gameObject;
        }
        if (flg && Time.time - spawntime > sleep / (1f + temperature / maxFiretime * 0.5f))
        {
            flg = false;
        }

        /* --- HEALTH --- */

        if (health < 0f)
        {
            health = 0f;
        }
        healthBar.value = health;

        if (health <= 0f)
        {
            SceneManager.LoadScene(0);
        }
    }