Exemplo n.º 1
0
    /// <summary>
    /// Is raised by the enemy when it's killed.
    /// </summary>
    /// <param name="sender">Sender.</param>
    /// <param name="e">E.</param>
    void OnCollectableCollected(Collectable sender, CollectableEventArgs e)
    {
        if (e.Points < 0)
        {
            comboMultiplier = 1;
            CurrentFails++;

            FailuresText.text = "Failures: " + CurrentFails;

            if (CurrentFails >= MaxFails)
            {
                FinishGame(true);
                return;
            }
        }
        else
        {
            UpdateComboMultiplier(e);

            points         += e.Points * comboMultiplier;     //add the player points multiplied by the combo multiplier
            pointsText.text = "Points: " + points;

            lastTimeCollected = e.CollectedTime;
        }

        sender.CollectableCollected -= OnCollectableCollected;
        Collectables.Remove(sender);

        InstantiateCollectable(e.Index);
    }
Exemplo n.º 2
0
    /// <summary>
    /// Is raised by the enemy when it's killed.
    /// </summary>
    /// <param name="sender">Sender.</param>
    /// <param name="e">E.</param>
    void OnCollectableCollected(Collectable sender, CollectableEventArgs e)
    {
        UpdateComboMultiplier(e);

        points += e.Points * comboMultiplier; //add the player points multiplied by the combo multiplier

        if (pointsText != null)
        {
            pointsText.text = string.Format("Points:{0}", points);
        }
        else
        {
            Debug.Log("No point text object is attached, can't set the text.");
        }

        lastTimeCollected            = e.CollectedTime;
        sender.CollectableCollected -= OnCollectableCollected;
    }
Exemplo n.º 3
0
    /// If the enemy is killed in combo time add a combo multiplier.
    /// The more enemies you kill in a combo the bigger the multiplier gets.
    void UpdateComboMultiplier(CollectableEventArgs e)
    {
        if (e.CollectedTime <= lastTimeCollected + comboTimerSeconds)
        {
            comboMultiplier++;
        }
        else
        {
            comboMultiplier = 1;
        }

        if (comboMultiplier > 1 && comboTextPrefab != null && canvas != null)
        {
            var comboText = Instantiate(comboTextPrefab);
            comboText.GetComponent <ComboText>().SetMultiplier(comboMultiplier);
            comboText.transform.position = Camera.main.WorldToScreenPoint(e.Position);

            comboText.transform.SetParent(canvas.transform);
        }
    }