Ejemplo n.º 1
0
    /// <summary>
    /// Notifies the bard when its tune hits another bard.
    /// </summary>
    /// <param name="tune">The tune that caused the damage.</param>
    /// <param name="weight">A weight for the effectiveness of the tune.</param>
    /// <param name="isDamage">Whether the weight is the amount of damage dealt by the tune.</param>
    public void CreditHit(Tune tune, float weight, bool isDamage = true)
    {
        AdaptiveAI ai = GetComponent <AdaptiveAI>();

        if (ai != null)
        {
            ai.RegisterHit(tune, weight);
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Deals damage to this player.
    /// </summary>
    /// <param name="amount">The amount of damage done. All damage is normalized (1 = instakill)</param>
    /// <param name="sourceTune">The tune that caused the damage.</param>
    /// <param name="aggressor">The player who caused the damage.</param>
    public void DealDamage(float amount, Tune sourceTune = null, PlayerID aggressor = PlayerID.None)
    {
        BaseControl control = GetComponent <BaseControl>();

        if (sourceTune != null && aggressor != control.player && amount > 0)
        {
            BubbleShield shield = GetComponentInChildren <BubbleShield>();
            if (shield != null)
            {
                shield.BlockAttack(amount);
                return;
            }
        }

        health -= amount;
        bool died = false;

        if (health <= 0)
        {
            control.ClearMomentum();
            if (control.player != PlayerID.None)
            {
                EffectManager.instance.SpawnDeathEffect(transform.position, control.GetRobeMaterial().color);
            }
            GetComponent <BaseControl>().enabled = false;
            positionOfDeath    = transform.position;
            transform.position = Vector3.up * 100f;
            died = true;
            if (roundHandler)
            {
                Assets.Scripts.Data.RoundHandler.Instance.AddDeath(control.player);
            }
            else
            {
                respawnTimer = respawnTime;
            }
        }
        if (health > 1)
        {
            health = 1f;
        }

        updateHealthBar();

        if (uiController != null)
        {
            uiController.UpdateHealth(health, died);
        }

        if (aggressor == PlayerID.None)
        {
            aggressor = control.player;
        }
        else
        {
            float weight = amount;
            if (aggressor == control.player)
            {
                weight = -weight;
            }
            LevelManager.instance.GetBardFromID(aggressor).CreditHit(sourceTune, weight, true);
        }

        if (amount > 0)
        {
            lastHitTune   = sourceTune;
            lastHitPlayer = aggressor;

            if (aggressor != control.player)
            {
                AdaptiveAI adapt = GetComponent <AdaptiveAI>();
                if (adapt != null)
                {
                    adapt.TakeDamage(amount);
                }
            }
        }
    }