0% found this document useful (0 votes)
16 views

Ejercicio1 Monobehaviour: Using Using Public Class Int Int Bool Void If True

The document contains code for three C# classes - Ejercicio1, Ejercicio2, and Ejercicio3 - that are used in the Unity game engine. Ejercicio1 checks if a player has health below 30 and more than 0 powerups, uses a powerup if so, and logs the powerup status. Ejercicio2 uses a for loop to increment a coins variable 10 times, then logs the value of coins multiplied by 2. Ejercicio3 uses a while loop to increment a variable until it is divisible by another variable, logging a message each iteration.

Uploaded by

sgrizan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Ejercicio1 Monobehaviour: Using Using Public Class Int Int Bool Void If True

The document contains code for three C# classes - Ejercicio1, Ejercicio2, and Ejercicio3 - that are used in the Unity game engine. Ejercicio1 checks if a player has health below 30 and more than 0 powerups, uses a powerup if so, and logs the powerup status. Ejercicio2 uses a for loop to increment a coins variable 10 times, then logs the value of coins multiplied by 2. Ejercicio3 uses a while loop to increment a variable until it is divisible by another variable, logging a message each iteration.

Uploaded by

sgrizan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

using UnityEngine;

using System.Collections;
public class Ejercicio1 : MonoBehaviour {
int health = 30;
int powerUps = 2;
bool isPowerUpActive;
// Use this for initialization
void Start () {
if (health <= 30 && powerUps > 0){
powerUps--;
isPowerUpActive = true;

}
Debug.Log("PowerUpActive " + isPowerUpActive + " PowerUps " + powerUps);
}

using UnityEngine;
using System.Collections;
public class Ejercicio2 : MonoBehaviour {
int life = 10;
int coins = 0;
// Use this for initialization
void Start () {
for (int i = 0; i < 10; i++) {
coins++;
}

Debug.Log ("El valor es: " + coins * 2);


}

using UnityEngine;
using System.Collections;
public class Ejercicio3 : MonoBehaviour {
int a = 2;
int b = 9;
// Use this for initialization
void Start () {
while(a % b != 0 ) {
Debug.Log("a no es divisible entre b");
a++;
}
}

You might also like