示例#1
0
    private void OnSceneGUI()
    {
        MeteoriteShooter meteoriteShooter = target as MeteoriteShooter;

        Handles.DrawLine(new Vector3(meteoriteShooter.ShootLeft, meteoriteShooter.ShootHeight, 0),
                         new Vector3(meteoriteShooter.ShootRight, meteoriteShooter.ShootHeight, 0));
    }
示例#2
0
    public void Fire(bool bulletNumLimit)
    {
        if (bulletNumLimit)
        {
            if (canShoot == false || bulletNum <= 0)
            {
                return;
            }
            GameObject planetObj = Instantiate(meteoPrefab, muzzle.position, muzzle.rotation);

            MeteoriteShooter shooter = planetObj.GetComponent <MeteoriteShooter>();
            Vector3          force   = (muzzle.transform.position - planet.transform.position).normalized;
            shooter.Shoot(new Vector2(force.x, force.y), shootPower);
            bulletNum -= 1;
            canShoot   = false;
        }
        else
        {
            if (canShoot == false)
            {
                return;
            }
            GameObject planetObj = Instantiate(meteoPrefab, muzzle.position, muzzle.rotation);

            MeteoriteShooter shooter = planetObj.GetComponent <MeteoriteShooter>();
            Vector3          force   = (muzzle.transform.position - planet.transform.position).normalized;
            shooter.Shoot(new Vector2(force.x, force.y), shootPower);
            bulletNum -= 1;
            SoundMng.Instance?.PlaySE(SoundMng.SETag.Shoot);
            canShoot = false;
        }
    }