示例#1
0
    IEnumerator DeathWait()
    {
        Shadow.SetActive(false);
        Death.Play();
        gameObject.GetComponent <SpriteRenderer>().sortingOrder = 0;
        gameObject.GetComponent <CircleCollider2D>().enabled    = false;
        gameObject.GetComponent <CapsuleCollider2D>().enabled   = false;
        Debug.Log("death");
        Quest.Next_Quest();
        yield return(new WaitForSeconds(1.5f));

        soul.SetActive(true);
    }
示例#2
0
    IEnumerator DeathWait()
    {
        Shadow.SetActive(false);
        Death.Play();

        Shadow.GetComponent <SpriteRenderer>().sortingLayerName = "DiabloMap";
        gameObject.GetComponent <SpriteRenderer>().sortingOrder = -1;
        gameObject.GetComponent <CircleCollider2D>().enabled    = false;
        gameObject.GetComponent <CapsuleCollider2D>().enabled   = false;
        Debug.Log("death");
        yield return(null);
        //yield return new WaitForSeconds(6f);
        //DestoryMonster();
    }
示例#3
0
 IEnumerator DeathWait()
 {
     Shadow.SetActive(false);
     SkillFire.SetActive(false);
     GetComponent <CircleCollider2D>().isTrigger = true;
     Death.Play();
     gameObject.GetComponent <SpriteRenderer>().sortingOrder = 0;
     gameObject.GetComponent <CircleCollider2D>().enabled    = false;
     gameObject.GetComponent <CapsuleCollider2D>().enabled   = false;
     Debug.Log("death");
     Quest.Next_Quest();
     yield return(null);
     //yield return new WaitForSeconds(6f);
     //DestoryMonster();
 }
示例#4
0
 public void DeathSound()
 {
     Death.Play();//Play the death sound.
 }
示例#5
0
    void Update()
    {
        if (Health <= 0)
        {
            if (_timerInv == 2.0f)
            {
                _animator.SetTrigger("RIP");
                Death.Play();
                _isDead = true;
            }
            _timerInv            -= Time.deltaTime;
            _spriteRenderer.color = new Color(1.0f, 1.0f, 1.0f, 1.0f);

            if (_timerInv < 0)
            {
                SceneManager.LoadScene("Menu", LoadSceneMode.Single);
            }
        }
        if (Health > 0)
        {
            Health -= AntiHealth * Time.deltaTime;
            UIController.Instance.SetHealth((int)Health);
        }

        if (_inv && Health > 0)
        {
            UIController.Instance.SetHealth((int)Health);

            UIController.Instance.SetHealth((int)Health);
            _timerInv -= Time.deltaTime;
            if (_timerInv < 0)
            {
                _spriteRenderer.color = new Color(1.0f, 1.0f, 1.0f, 1.0f);
                _inv      = false;
                _timerInv = 2.0f;
            }
        }

        if (!_isDead)
        {
            float velX     = Input.GetAxisRaw("Horizontal");
            float velY     = Input.GetAxisRaw("Vertical");
            bool  isMoving = false;

            if (_knockback <= 0)
            {
                if (Mathf.Abs(velX) > float.Epsilon || Mathf.Abs(velY) > float.Epsilon)
                {
                    _spriteRenderer.flipX = velX < 0;
                    isMoving    = true;
                    Walk.volume = Random.Range(0.8f, 1.0f);
                    Walk.pitch  = Random.Range(0.8f, 1.2f);
                    if (!Walk.isPlaying)
                    {
                        Walk.Play();
                    }
                }
                _moveInput    = new Vector2(velX, velY);
                _moveVelocity = _moveInput.normalized * Speed;
            }
            _knockback -= Time.deltaTime;

            if (Input.GetButton("Fire2") && Time.time > _nextFire)
            {
                _nextFire = Time.time + FireRate;
                Fireball?.Play();
                Shoot();
                _animator.SetTrigger("Projectile");
            }

            if (Input.GetButton("Fire1") && !_isMelee)
            {
                Sword?.Play();
                _isMelee    = true;
                _meleeTimer = 0.5f;
                Melee.gameObject.SetActive(true);
            }
            if (_isMelee)
            {
                if (_meleeTimer > 0)
                {
                    if (velX > 0 || velX == 0 && _attackRight)
                    {
                        Melee.transform.localScale = new Vector3(1, 1, 1);
                        Melee.transform.Rotate(new Vector3(0, 0, -240) * MeleeSpeed * Time.deltaTime);
                        _attackRight = true;
                    }
                    else
                    {
                        Melee.transform.localScale = new Vector3(1, -1, 1);
                        Melee.transform.Rotate(new Vector3(0, 0, 240) * MeleeSpeed * Time.deltaTime);
                        _attackRight = false;
                    }
                    _meleeTimer -= Time.deltaTime;
                }
                else
                {
                    _isMelee = false;
                    if (velX > 0)
                    {
                        Melee.transform.eulerAngles = new Vector3(0, 0, 100);
                    }
                    else
                    {
                        Melee.transform.eulerAngles = new Vector3(0, 0, 70);
                    }
                    Melee.gameObject.SetActive(false);
                }
            }
            _animator.SetBool("Walk", isMoving);

            if (Input.GetKeyDown("q") && PotionData.Boost != 0)
            {
                Health += PotionData.Boost;
                Potion.Play();
                PotionData = EmptyPotionSlot;
                UpdateSprites();
            }
            if (Input.GetKeyDown("e") && ItemData != null)
            {
                Throw();
                ItemData = null;
                Click.Play();
                CameraShaker.Instance.ShakeOnce(0.2f, 0.2f, 0.3f, 0.3f);

                ItemData = EmptyItemSlot;
                UpdateSprites();
            }

            _defenceTimer -= Time.deltaTime;
            if (_defenceTimer <= 0)
            {
                Defence.gameObject.SetActive(false);
            }
        }
    }