Esempio n. 1
0
 void shootGFL()
 {
     animator.speed = 0.0f;
     GFL_Warning.SetActive(true);
     track.clip = charge;
     track.Play();
 }
Esempio n. 2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag == "bullet")
        {
            if (animator.GetBool("isDead") == false)
            {
                Destroy(collision.gameObject);
                health -= 10;
            }
        }

        if (health <= 0)
        {
            if (animator.GetBool("isDead") == false)
            {
                animator.SetTrigger("ded");
                GFL_Warning.SetActive(false);
                GFL.SetActive(false);
                animator.speed = 1;
                animator.SetBool("shootingLaser", false);
                animator.SetBool("shootingGFL", false);
                shop.gameObject.GetComponent <SHOP>().PTS += 70;
                track.clip   = death;
                track.pitch /= 2;
                track.volume = 0.5f;
                track.Play();
                GetComponent <BoxCollider2D>().size = new Vector2(GetComponent <BoxCollider2D>().size.x * 2, GetComponent <BoxCollider2D>().size.y / 2);
            }
            animator.SetBool("isDead", true);
            health = 0;

            print(track.isPlaying ? "Playing" : "not playing" + counter);
            counter += 1;
        }
    }
Esempio n. 3
0
    void Attack()
    {
        horizontalDirection = 0.0f;
        isWalking           = false;
        isAttacking         = true;

        float rayStartPoint;

        if (!GetComponent <SpriteRenderer>().flipX)
        {
            rayStartPoint = transform.position.x - 2;
        }
        else
        {
            rayStartPoint = transform.position.x - 2;
        }

        RaycastHit2D hit;

        Debug.DrawRay(new Vector2(rayStartPoint, transform.position.y), new Vector2(-1, 0), Color.red);
        hit = Physics2D.Raycast(new Vector2(rayStartPoint, transform.position.y), new Vector2(-1, 0), 12);

        fireTimer -= 1;

        if ((fireTimer <= 0) || (health <= 0))
        {
            if (health <= 0 && track.clip != death)
            {
                track.Stop();
            }
            animator.speed = 1;
            GFL_Warning.SetActive(false);
            GFL.SetActive(false);
            if (hit.collider != null)
            {
                if (((hit.collider.tag == "base")) || ((hit.collider.tag == "Player")))
                {
                    int randomNumber = Random.Range(0, 100);
                    if ((randomNumber <= 40) && (reloadTimer == 0))
                    {
                        animator.SetBool("shootingGFL", true);
                        animator.SetBool("shootingLaser", false);
                        reloadTimer = 1;
                    }
                    else
                    {
                        animator.SetBool("shootingGFL", false);
                        animator.SetBool("shootingLaser", true);
                        reloadTimer = 0;
                    }
                }
            }
            fireTimer = 301;
        }

        if (animator.speed == 0.0f)
        {
            chargeTime -= 1;
            if ((chargeTime <= 0) && ((chargeTime > -100)))
            {
                GFL_Warning.SetActive(false);
                GFL.SetActive(true);
                if (track.clip != beam)
                {
                    track.clip = beam;
                    track.Play();
                }
            }
            else if ((chargeTime <= -100) && ((chargeTime > -300)))
            {
                //GFL.SetActive(false);
                chargeTime = 100;
            }
        }
    }