IEnumerator Start() { while (true) { AbilityStar star = Instantiate(starPrefab) as AbilityStar; star.transform.position = transform.position - new Vector3(0f, 0f, transform.position.z); int val = Random.Range(0, 3); Debug.Log("Random star " + val); if (val == 0) { star.ability = star.energyWhip; star.abilityCard = star.energyWhipCard; star.transform.position += new Vector3(0f, 5f, 0f); } else if (val == 1) { star.ability = star.spark; star.abilityCard = star.sparkCard; star.transform.position += new Vector3(-3f, 3f, 0f); } else if (val == 2) { star.ability = star.flameThrower; star.abilityCard = star.flameThrowerCard; star.transform.position += new Vector3(3f, 3f, 0f); } yield return(new WaitForSeconds(3f)); } }
public void OnTriggerEnter2D(Collider2D other) { if (kirby.CurrentState.ToString() == Kirby.State.Inhaling.ToString()) { if (other.gameObject.tag == "enemy") { kirby.enemyCollisionCallback(other.gameObject); } else if (other.gameObject.tag == "abilitystar") { AbilityStar star = other.gameObject.GetComponent <AbilityStar>(); kirby.InhaleAbility(star.ability, star.abilityCard); } } }
private void LoseAbility() { if (ability != null) { AbilityStar star = Instantiate(abilityStarPrefab) as AbilityStar; star.ability = ability; star.abilityCard = abilityCard; ability = null; persistantAbility = null; star.transform.position = transform.position; if (enemyOther != null && enemyOther.transform.position.x < transform.position.x) { star.goRight = true; } abilityCard = null; GameObject.Find("Ability").GetComponent <SpriteRenderer>().sprite = defaultAbilityCard; } }