Пример #1
0
 public void AddHealth(int amount)
 {
     if (currentHealth < startingHealth)
     {
         currentHealth += amount;
     }
     healthText.UpdateHealthDisplay(currentHealth);
 }
Пример #2
0
    // Start is called before the first frame update
    void Start()
    {
        rigidbody          = GetComponent <Rigidbody2D>();
        spriteRenderer     = GetComponent <SpriteRenderer>();
        gameController     = FindObjectOfType <GameController>();
        cameraPos          = Camera.main.transform.position;
        transform.position = spawnLocation - new Vector3(2, 0, 0);
        leftEdgeCollider   = GameObject.FindGameObjectWithTag("LeftEdgeCollider");
        healthText         = FindObjectOfType <HealthText>();
        pickupParticles    = gameObject.transform.Find("Pickup Particles").GetComponent <ParticleSystem>();

        leftEdgeCollider.SetActive(false);
        rigidbody.velocity = new Vector3(speed / 5, 0, 0);

        GetComponent <FadeObject>().TriggerFadeIn();
        currentHealth = startingHealth;
        healthText.UpdateHealthDisplay(currentHealth);
    }