Esempio n. 1
0
    /// <summary>
    /// Throw the grenade
    /// </summary>
    /// <param name="elapsedTime">Elapsed time between the pression and the release of the button</param>
    public override void Shoot(int elapsedTime)
    {
        Vector2 direction = GetMouseDirection();

        this.Load();

        grenadeHolder.RemoveChild(WeaponAmmo);
        GetTree().GetRoot().AddChild(WeaponAmmo);
        WeaponAmmo.SetGlobalPosition(grenadeHolder.GlobalPosition);

        Grenade grenade = WeaponAmmo as Grenade;

        grenade.Launch(direction, elapsedTime * STRENGTH_FACTOR);
    }
Esempio n. 2
0
    /// <summary>
    /// Shoot the ammo
    /// </summary>
    /// <param name="elapsedTime">Time elasped between the pression and the release of the button</param>
    public override void Shoot(int elapsedTime)
    {
        Vector2 direction = GetMouseDirection();

        this.Load();

        rifleHolder.RemoveChild(WeaponAmmo);
        GetTree().GetRoot().AddChild(WeaponAmmo);
        WeaponAmmo.SetGlobalPosition(rifleHolder.GlobalPosition);

        RifleAmmo rifleAmmo = WeaponAmmo as RifleAmmo;

        rifleAmmo.Launch(direction, STRENGTH_FACTOR);
    }
    /// <summary>
    /// Shoot the rocket
    /// </summary>
    /// <param name="elapsedTime">Elapsed time between the pression and the release of the button</param>
    public override void Shoot(int elapsedTime)
    {
        Vector2 direction = GetMouseDirection();

        this.Load();

        // Remove the rocket from the launcher and set it in the scene as a child of root
        rocketHolder.RemoveChild(WeaponAmmo);
        GetTree().GetRoot().AddChild(WeaponAmmo);
        WeaponAmmo.SetGlobalPosition(rocketHolder.GlobalPosition);

        // Launch the rocket (apply force)
        Rocket rocket = WeaponAmmo as Rocket;

        rocket.Launch(direction, elapsedTime * STRENGTH_FACTOR);
    }