Example #1
0
        public override void shoot()
        {
            if (refireCounter_ == 0 && CurrentAmmo_ > 0)
            {
                rotation_.Normalize();
                Vector2 bulletPos = position_ + rotation_ * 15f;
                Bullet bullet = new Bullet(drawPipeline_, collisionDetector_, bulletPos, adjustForInaccuracy(rotation_, MAX_INACCURACY));
                refireCounter_ = TIME_TO_REFIRE;
                CurrentAmmo_--;
                character_.getAmmo().update(CurrentAmmo_);

                //InputSet.getInstance().setToggle(Commando.controls.InputsEnum.RIGHT_TRIGGER);

                weaponFired_ = true;

                SoundEngine.getInstance().playCue("bang_1");
            }
            else if (refireCounter_ == 0)
            {
                InputSet.getInstance().setToggle(Commando.controls.InputsEnum.RIGHT_TRIGGER);
                if (character_ is ActuatedMainPlayer)
                {
                    character_.getActuator().perform("reload", new ActionParameters());
                }
                else
                {
                    character_.reload();
                }
            }
        }
Example #2
0
        public override void shoot()
        {
            if (refireCounter_ == 0 && CurrentAmmo_ > 0)
            {
                rotation_.Normalize();
                Vector2 bulletPos = position_ + rotation_ * gunTip_;
                float inaccuracy = MAX_BASE_INACCURACY + INACCURACY_PER_RECOIL * recoil_;
                Bullet bullet = new Bullet(drawPipeline_, collisionDetector_, bulletPos, adjustForInaccuracy(rotation_,inaccuracy));
                refireCounter_ = TIME_TO_REFIRE;
                CurrentAmmo_--;
                character_.getAmmo().update(CurrentAmmo_);

                weaponFired_ = true;
                recoil_ += RECOIL_PER_SHOT_FIRED;
                if (recoil_ > MAX_RECOIL)
                    recoil_ = MAX_RECOIL;

                SoundEngine.getInstance().playCue("gunshot");
            }
            else if (refireCounter_ == 0)
            {
                InputSet.getInstance().setToggle(Commando.controls.InputsEnum.RIGHT_TRIGGER);
                if (character_ is ActuatedMainPlayer)
                {
                    character_.getActuator().perform("reload", new ActionParameters());
                }
                else
                {
                    character_.reload();
                }
            }
        }
Example #3
0
 public override void shoot()
 {
     if (refireCounter_ == 0 && CurrentAmmo_ > 0)
     {
         rotation_.Normalize();
         Vector2 pos = position_ + rotation_ * 15f;
         Bullet bullet = new Bullet(drawPipeline_, collisionDetector_, pos, rotation_);
         refireCounter_ = TIME_TO_REFIRE;
         CurrentAmmo_--;
         character_.getAmmo().update(CurrentAmmo_);
     }
     else if (refireCounter_ == 0)
     {
         character_.reload();
     }
 }