void Start() { pantalla = GameObject.Find("pantalla").GetComponent <Canvas>(); qText = GameObject.Find("Question").GetComponent <Text>(); anim = GetComponent <Animator>(); instance = this; JPduration = jpd; pantalla.enabled = false; preguntas = new List <string>(); respuestas = new List <bool>(); processTextFile(); isAsking = false; type = Random.Range(0, 10); if (type > 5) { anim.SetBool("Life", true); } else { anim.SetBool("JetPack", true); } }
}//static public WeaponDefinition GetWeaponDefinition public void ShipDestroyed(Enemy e) { //Potentially generate a PowerUp if (Random.value <= e.powerUpDropChance) { //Random.value generates a value between 0 & 1, though never == 1 //If the e.powerUpDropChance is 0.50f, a PowerUp will be generated 50% of the time //For testing, its now set to 1f. //Choose which PowerUp to pick. //Pick one from the posibilities in powerUpFrequency int ndx = Random.Range(0, powerUpFrequency.Length); WeaponType puType = powerUpFrequency[ndx]; //Spawn a PowerUp GameObject go = Instantiate(prefabPowerUp) as GameObject; Power_Up pu = go.GetComponent<Power_Up>(); //Set it to the proper WeaponType pu.SetType(puType); //Set it to the position of the destroyed ship pu.transform.position = e.transform.position; }//if }//public void ShipDestroyed
void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.CompareTag("Player")) { instance = this; LoadQuestion(); } }
}//public float shieldLevel /************************************************************************************************* *** Methods *************************************************************************************************/ public void AbsorbPowerUp(GameObject go) { Power_Up pu = go.GetComponent<Power_Up>(); switch (pu.type) { case WeaponType.shield: shieldLevel++; break; default: //If its any Weapon PowerUp //Check the current weapon type if (pu.type == weapons[0].type) { //Then increase the number of weapons of this type Weapon w = GetEmptyWeaponSlot(); //Find an available weapon if (w != null) //Set it to pu.type w.SetType(pu.type); } else { //If this is a different weapon ClearWeapons(); weapons[0].SetType(pu.type); }//if else break; }//switch pu.AbsorbedBy(gameObject); }//public void AbsorbPowerUp