示例#1
0
    private void BowShoot()
    {
        getBullet();
        if (Input.GetMouseButton(0) && timer < weaponinfo.bowTime)
        {
            weaponinfo.GetComponent <SpriteRenderer>().sprite = Resources.Load("Weapon/" + weaponinfo.iconName + "_1", typeof(Sprite)) as Sprite;
            timer += Time.deltaTime * 2;
        }
        int power = Mathf.RoundToInt(timer);

        bullet.GetComponent <WeaponInfo>().damage = weaponinfo.damage * power;
        bullet.GetComponent <Bullet>().Speed      = 8 * (power + 1);
        if (Input.GetMouseButtonUp(0))
        {
            timer = 0;
            weaponinfo.GetComponent <SpriteRenderer>().sprite = Resources.Load("Weapon/" + weaponinfo.iconName, typeof(Sprite)) as Sprite;
            if (PlayerControl._player.transform.localScale.x == 1)
            {
                GameObject instbullet = Instantiate(bullet, shootPos.position, shootPos.rotation) as GameObject;
                instbullet.transform.localScale = new Vector3(1.5f, 0.5f, 1f);
                Destroy(instbullet, weaponinfo.shootDistance / 2);
            }
            else
            {
                GameObject instbullet = Instantiate(bullet, shootPos.position, shootPos.rotation) as GameObject;
                instbullet.transform.localScale          = new Vector3(-1.5f, 0.5f, 1f);
                instbullet.GetComponent <Bullet>().Speed = -instbullet.GetComponent <Bullet>().Speed;
                Destroy(instbullet, weaponinfo.shootDistance / 2);
            }
        }
    }