Example #1
0
    void Update()
    {
        float offsetX = Input.GetAxis("Horizontal");

        if (offsetX > 0 && trans.localPosition.x < 8.2)
        {
            trans.Translate(offsetX * 0.25f, 0, 0);
        }
        else if (offsetX < 0 && trans.localPosition.x > -8.2)
        {
            trans.Translate(offsetX * 0.25f, 0, 0);
        }

        float fire = Input.GetAxis("Vertical");

        if (fire < 0)
        {
            if (!Cooldown)
            {
                if (ws.GetBulletCount() < bull)
                {
                    ws.AddBullet();
                    Instantiate(bullet,
                                trans.position + new Vector3(0, 1f, 0),
                                Quaternion.identity);
                    Cooldown = true;
                    Invoke("ResetCooldown", 0.2f);
                }
            }
        }
    }