public void Absorb(myColors color, bool isMinion) { int green_amount = 1000; if (isMinion) { green_amount = 500; } switch (color) { case myColors.RED: red_bullets += 1; redBar.setColorBullets(red_bullets); break; case myColors.GREEN: green_bullets += green_amount; greenBar.setColorBullets(green_bullets); break; case myColors.BLUE: blue_bullets += 1; blueBar.setColorBullets(blue_bullets); break; default: break; } }
public void EnumFlagsTests() { myColors testColors = myColors.Blue | myColors.Green; var myDeclaration = VariableLiteral.GetNewLiteral(testColors); Assert.AreEqual("myColors.Green | myColors.Blue", myDeclaration); }
void Start() { //enum set curr color to default currColors = myColors.DEFAULT; currHp = maxHp; health.SetMaxHealth(maxHp); //get player sprite in children sr = GetComponentInChildren <SpriteRenderer>(); timer = 0.0f; }
private void ColorSwitch() { //change with time //timer += Time.deltaTime; //timer = timer % 20; //if (timer < 10) //{ // sr.color = Color.red; // currColors = myColors.RED; //} //else if (timer > 10 && timer < 15) //{ // sr.color = Color.blue; // currColors = myColors.BLUE; //} //else if (timer > 15 && timer < 20) //{ // sr.color = Color.green; // currColors = myColors.GREEN; //} // change with keys if (Input.GetKeyDown(KeyCode.Alpha1)) { sr.color = Color.red; currColors = myColors.RED; } if (Input.GetKeyDown(KeyCode.Alpha2)) { sr.color = Color.green; currColors = myColors.GREEN; } if (Input.GetKeyDown(KeyCode.Alpha3)) { sr.color = Color.blue; currColors = myColors.BLUE; } }
public void useAColorBullet(myColors color) { switch (color) { case myColors.RED: red_bullets -= 1; redBar.setColorBullets(red_bullets); break; case myColors.GREEN: green_bullets -= 50; greenBar.setColorBullets(green_bullets); break; case myColors.BLUE: blue_bullets -= 1; blueBar.setColorBullets(blue_bullets); break; default: break; } }
public void TakeDamage(float damage, myColors color, bool isMinion) { if (color == currColors) { // absorb bullet Absorb(color, isMinion); } else { currHp -= damage; mySprite.SetActive(true); StartCoroutine(resetColor()); health.setHealth(currHp); } if (currHp <= 0) { //play animation Debug.Log("player die"); Destroy(gameObject); } }
public void TakeDamage(float damage, myColors color) { Debug.Log("player taking damage " + color + ", current self color " + currColors); if (color == currColors) { // absorb bullet Absorb(color, false); } else { currHp -= damage; mySprite.SetActive(true); StartCoroutine(resetColor()); health.setHealth(currHp); } if (currHp <= 0) { //play animation Debug.Log("player die"); Destroy(gameObject); } }