// Update is called once per frame void Update() { lifeTime -= Time.deltaTime; if (lifeTime <= 0) { itemController.Decrease(effect.ToString()); Destroy(this.gameObject); } }
void OnTriggerEnter2D(Collider2D coll) { if (coll.gameObject.tag.Equals("Item")) { if (this.comEfeito) { RetirarEfeito(this.auxEfeito); } this.auxEfeito = coll.gameObject.GetComponent <Object_Efeitos>().GetEfeitoAtual(); Item i = coll.GetComponent <Item> (); i.enabled = false; i.itemController.Decrease(i.effect.ToString()); this.GetComponent <Characters_Global>().Prov_PowerUp(auxEfeito.ToString(), coll.GetInstanceID().ToString()); ReceberEfeito(auxEfeito); Destroy(coll.gameObject); } }
private Object_Efeitos.Effects RandomEffect(GameObject gameObjAtual) { int aux; if (!this.random) { aux = this.effectOrder[this.currPowerUp]; } else { List <int> powerUpPool = new List <int>(); // Damage Up for (int j = 0; j < 25 * this.balanceApplier.itemDistances[1]; j++) { powerUpPool.Add(0); } // Damage Down for (int j = 0; j < 25 * this.balanceApplier.itemDistances[0]; j++) { powerUpPool.Add(1); } // Speed Up for (int j = 0; j < 25 * this.balanceApplier.itemDistances[3]; j++) { powerUpPool.Add(2); } // Damage Down for (int j = 0; j < 25 * this.balanceApplier.itemDistances[2]; j++) { powerUpPool.Add(3); } aux = powerUpPool[Random.Range(0, powerUpPool.Count)]; this.spawnedItems[aux]++; } switch (aux) { case 0: auxEffect = Object_Efeitos.Effects.DAMAGE_UP; gameObjAtual.GetComponent <SpriteRenderer>().color = colorDamageUp; gameObjAtual.GetComponent <Animator>().SetTrigger("Good"); gameObjAtual.GetComponent <SpriteRenderer>().sprite = spriteDamageUp; break; case 1: auxEffect = Object_Efeitos.Effects.DAMAGE_DOWN; gameObjAtual.GetComponent <SpriteRenderer>().color = colorDamageDown; gameObjAtual.GetComponent <Animator>().SetTrigger("Bad"); gameObjAtual.GetComponent <SpriteRenderer>().sprite = spriteDamageDown; break; case 2: auxEffect = Object_Efeitos.Effects.SPEED_UP; gameObjAtual.GetComponent <Animator>().SetTrigger("Good"); gameObjAtual.GetComponent <SpriteRenderer>().color = colorSpeedUp; gameObjAtual.GetComponent <SpriteRenderer>().sprite = spriteSpeedUp; break; case 3: auxEffect = Object_Efeitos.Effects.SPEED_DOWN; gameObjAtual.GetComponent <Animator>().SetTrigger("Bad"); gameObjAtual.GetComponent <SpriteRenderer>().color = colorSpeedDown; gameObjAtual.GetComponent <SpriteRenderer>().sprite = spriteSpeedDown; break; case 4: auxEffect = Object_Efeitos.Effects.INVERT_CONTROL; gameObjAtual.GetComponent <Animator>().SetTrigger("Bad"); gameObjAtual.GetComponent <SpriteRenderer>().color = colorInvert; gameObjAtual.GetComponent <SpriteRenderer>().sprite = spriteColorInvert; break; } gameObjAtual.GetComponent <Item>().itemController = this.itemController; gameObjAtual.GetComponent <Item>().effectId = aux; itemController.Increase(auxEffect.ToString()); Prov_SpawnItem(); Prov_Item(auxEffect.ToString(), gameObjAtual.GetComponent <Collider2D>().GetInstanceID().ToString()); return(auxEffect); }