예제 #1
0
    /// <summary>
    /// Load the ammo
    /// </summary>
    public override void Load()
    {
        RifleAmmo rifleAmmo = GameResources.GetInstance().Get <RifleAmmo>();

        rifleHolder.AddChild(rifleAmmo);
        this.WeaponAmmo = rifleAmmo;
    }
예제 #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);
    }