Example #1
0
        public void PlaySound(string soundName, float screenWidth, float screenHeight, Vector2?soundSource = null)
        {
            // If the music crashed, try to restart it.
            if (MusicCrashed)
            {
                MusicCrashed = false;
                PlayMusic(MusicNameWhenCrashed);
            }

            try {
                SoundEffect effect = Content.Load <SoundEffect>(soundName);
                if (soundSource == null)
                {
                    effect.Play(1f, 0f, 0f);
                }
                else
                {
                    // f(x) = -x/2000 + 1
                    Vector2 target = GameLibHelper.ToVector2(CameraService.GetTarget(screenWidth, screenHeight));
                    float   volume = -(float)Math.Sqrt((target.X - soundSource.Value.X) * (target.X - soundSource.Value.X) +
                                                       (target.Y - soundSource.Value.Y) * (target.Y - soundSource.Value.Y)) / 1000 + 1;
                    volume = Math.Max(volume, 0);

                    effect.Play(volume, 0f, 0f);
                }
            } catch (Exception) {
            }
        }
Example #2
0
        void PlaySound(Sounds s, Vec2 source = null)
        {
            var screen = (ScreenService)Services.GetService(typeof(ScreenService));

            Sound.PlaySound(SoundsHelper.GetSoundPath(s),
                            screen.GameWindowSize.X, screen.GameWindowSize.Y,
                            source != null ? (Vector2?)GameLibHelper.ToVector2(source) : null);
        }
        protected override void OnUpdate(GameTime dt)
        {
            base.OnUpdate(dt);

            ChampionServerRect.Position     = GameLibHelper.ToVector2(Champion.ServerPosition);
            ChampionSimulatedRect.Position  = GameLibHelper.ToVector2(Champion.Position);
            ChampionNoCorrection.Position   = GameLibHelper.ToVector2(Champion.NoCorrPos);
            ChampionCorrectionUsed.Position = GameLibHelper.ToVector2(Champion.ServerCorrectionUsed);
        }
Example #4
0
 public override bool IsBehind(Vector2 position)
 {
     if (Parent != null)
     {
         //TODO: use the rectangle of the current animation?
         return(GameLibHelper.ToRectangle(Champion.CreateCollisionRectangle()).Contains(
                    (int)position.X,
                    (int)position.Y));
     }
     return(false);
 }
Example #5
0
        protected void AddParticlesTrail(int particles, TimeSpan particleLifeTime, Color tint, Action <ParticleSystem> modifySystem = null)
        {
            var p = new ParticleSystem(particles, null, particleLifeTime);

            p.ParticleInitialVelocity = GameLibHelper.ToVector2(-Spell.Velocity);
            p.Tint = tint;
            if (modifySystem != null)
            {
                modifySystem(p);
            }
            AddChild(p);
        }
Example #6
0
        protected override void OnUpdate(GameTime dt)
        {
            if (ApplyUpdates)
            {
                Spell.Update(dt.ElapsedGameTime.TotalSeconds);
            }
            Position = GameLibHelper.ToVector2(Spell.Position);
            base.OnUpdate(dt);

            if (RemoveWhenDeleted && !Spell.Active)
            {
                Parent.RemoveChild(this);
            }
        }
Example #7
0
        protected override void OnUpdate(Microsoft.Xna.Framework.GameTime dt)
        {
            // Update the champion animation
            CurrentAnimation = Champion.Animation;

            Position = GameLibHelper.ToVector2(Champion.DrawnPosition);

            Champion.Update(dt);

            ChampionSprite.Effects = Champion.FacingLeft ? SpriteEffects.FlipHorizontally : SpriteEffects.None;

            LifeBar.MaxHealth = Champion.MaxHealth;
            LifeBar.Health    = Champion.Health;
            LifeBar.Visible   = Champion.Alive;
        }
Example #8
0
        void UpdateHUD(GameTime dt)
        {
            if (OurChampion != null)
            {
                // Update the health
                ChampionState.MaxLife     = OurChampion.Champion.MaxHealth;
                ChampionState.CurrentLife = OurChampion.Champion.Health;

                // Update the camera positionning
                var screen = (ScreenService)Services.GetService(typeof(ScreenService));
                Camera.CenterCameraTowards(OurChampion.Champion.GetHandsPosition(),
                                           screen.GameWindowSize.X, screen.GameWindowSize.Y,
                                           Match.World.Map.GetWidthTiles() * Tile.WIDTH,
                                           Match.World.Map.GetHeightTiles() * Tile.HEIGHT);
                GameWorld.Position = GameLibHelper.ToVector2(-Camera.WorldPosition);

                // Update the cooldowns
                ChampionState.Update(dt.ElapsedGameTime);
            }

            UpdateParallax();
        }