예제 #1
0
    // Update is called once per frame
    void Update()
    {
        if (isInvincible)
        {
            Sprite.color = new Color(1, 1, 1, Mathf.RoundToInt(blink));
            if (blink < 1)
            {
                blink += Time.deltaTime * 8;
            }
            else
            {
                blink = 0;
            }
        }
        else
        {
            Sprite.color = new Color(1, 1, 1, 1);
        }

        if (canMove)
        {
            Movement();
        }

        bool shoot = Input.GetKeyDown("n") || Input.GetKeyDown(KeyCode.Space);

        if (shoot)
        {
            auds.PlayOneShot(pew);
            GameObject B = Instantiate(PB);
            B.transform.SetPositionAndRotation(gameObject.transform.position, new Quaternion());
        }

        bool bomb = Input.GetKeyDown("m") || Input.GetKeyDown("x");

        if (bomb && bombCount > 0)
        {
            auds.PlayOneShot(blam);
            bombCount--;
            GameObject BMB = Instantiate(BPB);
            BMB.transform.SetPositionAndRotation(transform.position, transform.rotation);

            GameObject RBMB = Instantiate(RBPB);
            RBMB.transform.SetPositionAndRotation(transform.position, transform.rotation);
        }

        if (playerHealth <= 0)
        {
            LS.SetActive(true);
            Destroy(gameObject);
        }
    }