Beispiel #1
0
    private void Update()
    {
        if (activated)
        {
            return;
        }
        if (Bonus.BonusAccessibility(type) <= GameController.instance.Score)
        {
            image.enabled = true;
            image.color   = Color.white;
            RectTransform rect = GetComponent <RectTransform>();
            rect.anchoredPosition = new Vector2(0, -(spawned * (rect.rect.height + 10)));

            GetComponent <Animator>().SetTrigger("Animate");
            activated = true;

            foreach (var bonus in GameObject.FindObjectsOfType <BonusSpawner>())
            {
                if (bonus.SpawnActivatedBonus(type))
                {
                    break;
                }
            }

            BonusActivator.spawned++;
        }
    }
Beispiel #2
0
    private void SpawnBonus()
    {
        if (activated)
        {
            return;
        }
        GameObject bonus = bonuses[Random.Range(0, bonuses.Length)];

        if (bonus && GameController.instance.Score >= Bonus.BonusAccessibility(bonus.GetComponent <Bonus>().type))
        {
            Instantiate(bonus, transform.position, transform.rotation, transform);
            activated = true;
        }
    }
Beispiel #3
0
    public bool SpawnActivatedBonus(BonusEffect type)
    {
        if (activated && bonuses == null)
        {
            return(false);
        }
        GameObject  bonus     = bonuses[Random.Range(0, bonuses.Length)];
        BonusEffect bonusType = bonus.GetComponent <Bonus>().type;

        if (bonusType != type || bonusType == BonusEffect.Star)
        {
            return(false);
        }
        if (bonus && GameController.instance.Score >= Bonus.BonusAccessibility(bonusType))
        {
            Instantiate(bonus, transform.position, transform.rotation, transform);
            activated = true;
        }
        return(true);
    }