示例#1
0
    // Start is called before the first frame update
    void Start()
    {
        gameOver = false;

        Quaternion angle = Quaternion.Euler(0, 0, 0);

        player = GameObject.Find("ufo");
        angle  = Quaternion.Euler(0, 90, 0);
        enemy1 = Instantiate(enemyPrefab, new Vector3(35, 0, -25), angle);
        angle  = Quaternion.Euler(0, 180, 0);
        enemy2 = Instantiate(enemyPrefab, new Vector3(-25, 0, -35), angle);
        angle  = Quaternion.Euler(0, 270, 0);
        enemy3 = Instantiate(enemyPrefab, new Vector3(-35, 0, 25), angle);

        enemy1.GetComponent <Renderer>().material = enemy1Mat;
        enemy2.GetComponent <Renderer>().material = enemy2Mat;
        enemy3.GetComponent <Renderer>().material = enemy3Mat;

        textDisplay.GetComponent <Text>().text = "01:30";
        barDisplayPlayer = 1;
        healthBarPlayer.SetHealth(barDisplayPlayer);
        barDisplayEnemy1 = 1;
        healthBarEnemy1.SetHealth(barDisplayEnemy1);
        barDisplayEnemy2 = 1;
        healthBarEnemy2.SetHealth(barDisplayEnemy2);
        barDisplayEnemy3 = 1;
        healthBarEnemy3.SetHealth(barDisplayEnemy3);

        Advertisement.Initialize(gameId, testMode);
    }
示例#2
0
 public void EnemyAttack(int damage)
 {
     currentHealth -= damage;
     healthBarPlayer.SetHealth(currentHealth);
     if (currentHealth <= 0)
     {
         gameObject.SetActive(false);
     }
 }
示例#3
0
 public void Damage(int damage)
 {
     currentHealth -= damage;
     healthBar.SetHealth(currentHealth);
     if (currentHealth <= 0)
     {
         SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
     }
 }
示例#4
0
    public void TakeDamage(int damage)
    {
        if (currentHealth > 0)
        {
            currentHealth -= damage;
            healthBar.SetHealth(currentHealth);
            //animator.SetTrigger("Hurt");
            Debug.Log("aw no what is you doin baby");
        }

        if (currentHealth <= 0)
        {
            Die();
        }
    }
示例#5
0
    void Update()
    {
        healthBar.SetHealth(currentHealth.Value);
        if (IsOwner)
        {
            if (currentHealth.Value <= 0)
            {
                endScreen = GameObject.Find("EndScreen");
                endScreen.GetComponent <Canvas>().enabled = true;
            }
        }

        if (Input.GetKeyDown("space"))
        {
            TakeDamage(200);
        }
    }
示例#6
0
 void Update()
 {
     healthBar.SetHealth(currentHealth.Value);
 }
 void Update()
 {
     healthBar.SetHealth(currentHealth.Value);
     energyBar.SetHealth(currentEnergy.Value);
 }