private IBonus InstantiateBonus(BonusCategory category)
    {
        IBonus projectile = _bonusFactory.Create(category);

        projectile.Dispose();
        return(projectile);
    }
    public IBonus TakeBonus(BonusCategory category)
    {
        if (_bonuses[category].Count <= 0)
        {
            _bonuses[category].Push(InstantiateBonus(category));
        }

        IBonus bonus = _bonuses[category].Pop();

        bonus.SetOnDisposeAction(DisposeBonus);

        return(bonus);
    }
示例#3
0
        public Bonus(Panel ActionPanel, Actor sourceActor, BonusCategory category): base(ActionPanel)
        {
            // set actor variables for the laser:
            source = sourceActor;
            this.speed = source.speed;
            m_category = category;
            SetImage("Bonus_" + (int)m_category + ".GIF");
            posX = source.posX;
            posY = source.posY;
            vX = source.vX / 2;
            vY = source.vY;

        }
示例#4
0
        public Bonus(Panel ActionPanel, Actor sourceActor)
            :
            base(ActionPanel)
        {
            // set actor variables for the laser:
            source = sourceActor;

            this.speed = source.speed;

            // weight the bonuses - less ammo bonuses
            int rnd = MyRnd.next(100);
            if (rnd < 20) // 20% chance of bonus being  
            {
                m_category = BonusCategory.laserPowerBonus;
            }
            else if (rnd < 45) // 25% chance of bonus being 
            {
                m_category = BonusCategory.healthBonus;
            }
            else if (rnd < 75) // 30% chance of bonus being 
            {
                m_category = BonusCategory.speedBonus;
            }
            else  // 25% chance of bonus being 
            {
                m_category = BonusCategory.laserSpeedBonus;
            }

            SetImage("Bonus_" + (int)m_category + ".GIF");
          
            posX = source.posX;
            posY = source.posY;
            vX = source.vX / 2;
            vY = source.vY;

        } // end constructor