Example #1
0
        public override void ApplyDamage(float amount)
        {
            SoundEffectManager.PlayEffect("impact", 0.1f);
            PainStaticMaker.AddDamage(amount);

            //heatbeat
            if ((_currentHealth / _maxHealth) < 0.3 && SoundEffectManager.GetSoundState("heartbeat") != SoundState.Playing)
            {
                SoundEffectManager.PlaySound("heartbeat");
            }
            base.ApplyDamage(amount);
        }
Example #2
0
        internal static void ObjectiveWasCollected()
        {
            SoundEffectManager.PlayEffect("item-collect", 1.0f);

            _mainInstance._numObjectsCollected++;
            Program.Objects.MainPlayer.GoToFullHealth();
            if (_mainInstance._numObjectsCollected >= _mainInstance._numToCollect)
            {
                _mainInstance._bossActive = true;
            }
            else
            {
                spawnNewObjective();
            }
        }
Example #3
0
        public void Shoot(Vector2 location, Vector2 direction)
        {
            if (_roundsLeftInClip == 0 && _reloadTimer.isFinished && _shootTimer.isFinished)
            {
                Reload();
            }
            else if (_roundsLeftInClip > 0 && _reloadTimer.isFinished && _shootTimer.isFinished)
            {
                //play weapon fire sound
                if (_weaponType.FireSound != null)
                {
                    SoundEffectManager.PlayEffect(_weaponType.FireSound, SOUND_VOLUME);
                }

                direction += Utilities.randomNormalizedVector() * _weaponType.Inaccuracy;

                direction.Normalize();

                //start shooting the particles at the left side of the spread
                Vector2 currentSpreadSweepDirection = Vector2.Transform(direction, _halfSpreadRotationMatrix);

                //initial rotation if an even number of projectiles
                if (_weaponType.FiresPerRound % 2 == 0)
                {
                    Vector2.Transform(ref currentSpreadSweepDirection, ref _spreadRotationStepMatrix, out currentSpreadSweepDirection);
                }

                //Special case of one particle
                if (_weaponType.FiresPerRound == 1)
                {
                    currentSpreadSweepDirection = direction;
                }

                for (int i = 0; i < _weaponType.FiresPerRound; i++)
                {
                    //shoot the projectiles

                    if (_weaponType.IsRaycasted)   //use raycasting

                    /*
                     * return -1: ignore this fixture and continue
                     * return 0: terminate the ray cast
                     * return fraction: clip the ray to this point
                     * return 1: don't clip the ray and continue
                     */
                    {
                        Vector2 pt      = Vector2.Zero;
                        float   minFrac = float.MaxValue;

                        //Gets the position of the closest fixture on the ray path.
                        Program.Objects.PhysicsWorld.RayCast((fixture, point, normal, fraction) => {
                            //check for a valid fixture
                            if (fixture == null)
                            {
                                return(-1);
                            }

                            //check if its an enemy or a wall (and if it's closer than the previous result)
                            if ((fixture.Body.UserData as Enemy != null || fixture.Body.UserData as MapTile != null) && fraction < minFrac)
                            {
                                pt      = point;
                                minFrac = fraction;
                                return(1);
                            }
                            return(-1);
                        }, location, location + currentSpreadSweepDirection * _weaponType.Range);

                        //create a particle at the place where the ray was stopped
                        if (pt != Vector2.Zero)
                        {
                            Program.Objects.Projectiles.Add(new Projectile(pt, Vector2.Zero, _weaponType.ProjectileType));
                        }
                    }
                    else   //use projectiles
                    {
                        Program.Objects.Projectiles.Add(new Projectile(location + direction * (_weaponOwner.PhysicalEntitySize / 1.8f + _weaponType.ProjectileType.Radius), currentSpreadSweepDirection, _weaponType.ProjectileType));
                    }

                    //rotate the direction to shoot the next particle in
                    Vector2.Transform(ref currentSpreadSweepDirection, ref _spreadRotationStepMatrix, out currentSpreadSweepDirection);
                }
                _roundsLeftInClip--;
                _shootTimer.Reset();
            }
        }