Example #1
0
 public SceneManager(Camera3D camera, SpriteBatch spriteBatch, string mapName = null, bool activatePause = false, int numberOfLives = 5)
 {
     Camera = camera;
     SpriteBatch = spriteBatch;
     Items = new List<I3DElement>();
     Hud = new HUD();
     NumberOfLives = numberOfLives;
     StatusCharacter = new Stack<Character>();
     if (mapName != null)
         AddMap(mapName);
     ActivatePause = activatePause;
 }
Example #2
0
        public void FollowsCharacters(Camera3D camera, IEnumerable<I3DElement> characters)
        {
            if (!characters.Any())
                return;

            float minX = float.MaxValue, maxX = float.MinValue;
            float minY = float.MaxValue, maxY = float.MinValue;
            foreach (Character character in characters)
            {
                if (!character.IsDead)
                {
                    if (character.Position.X < minX)
                        minX = character.Position.X;
                    if (character.Position.X > maxX)
                        maxX = character.Position.X;
                    if (character.Position.Y > maxY && character.Position.Y < 25)
                        maxY = character.Position.Y;
                }
            }
            Target = new Vector3((maxX + minX) / 2, (maxY - 1) / 2, characters.First().Position.Z - 0.3f);

            Position = new Vector3(Target.X, Position.Y, (characters.Count() == 1) ? Position.Z :
                                   (-(float)((maxX - Target.X + maxY - Target.Y) / Math.Tan(MathHelper.PiOver4 / 2)) + Target.Z - 4) < -50 ? -50 : -(float)((maxX - Target.X + maxY - Target.Y) / Math.Tan(MathHelper.PiOver4 / 2)) + Target.Z - 4 );
        }
Example #3
0
        public void Draw(SpriteBatch spriteBatch, Camera3D camera)
        {
            ParticleSystemManager.DrawAllParticleSystems();

            ParticleSystemManager.SetWorldViewProjectionMatricesForAllParticleSystems(Matrix.Identity,
                camera.ViewMatrix, Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45),
                spriteBatch.GraphicsDevice.DisplayMode.AspectRatio, 1f, 100f));

            spriteBatch.GraphicsDevice.DepthStencilState = DepthStencilState.Default;
        }
Example #4
0
 public void Update(GameTime gameTime, Camera3D camera)
 {
     ParticleSystemManager.SetCameraPositionForAllParticleSystems(camera.Position);
     ParticleSystemManager.UpdateAllParticleSystems((float)gameTime.ElapsedGameTime.TotalSeconds);
 }