Exemplo n.º 1
0
    public void TakeDamage()
    {
        if (hitstun || dashPauseTimer > 0)
        {
            return;
        }
        //Debug.Log("ow!");
        int soulsLost = SoulWallet.LoseSouls();

        if (soulsLost < 0)
        {
            Die();
        }
        else
        {
            int soulSpawns = 1;
            if (soulsLost < 5)
            {
                soulSpawns = soulsLost;
            }
            else if (soulsLost < 30)
            {
                soulSpawns = (soulsLost / 2) + 3;
            }
            else
            {
                soulSpawns = 15;
            }
            for (int i = 0; i < soulSpawns; i++)
            {
                SoulCollectible soul = Instantiate(GameController.instance.soulPrefab);
                soul.transform.position = transform.position;
                Vector3 launchVel = new Vector3(0, 4);
                launchVel.x  = Random.Range(-6, 6);
                launchVel.y += Random.Range(0, 8);
                soul.SetLaunchVelocity(launchVel);
            }
        }
        hitstun             = true;
        _rigidbody.velocity = new Vector3(-2f * _anim.Facing, 1, 0);
        _anim.PlayHurtAnim();
    }