Files
evilsatellites/EvilSatellites/Screens/GameScreen.cs
T

58 lines
2.0 KiB
C#
Raw Normal View History

2021-04-10 14:08:20 +02:00
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using SynthySound;
using System.Linq;
using EvilSatellites.Objects;
namespace EvilSatellites.Screens
{
public class GameScreen : IScreen
{
public ScreenManager Manager { get; set; }
public ScreenState State { get; set; }
public List<IGameObject> Objects = new List<IGameObject>();
private float Theta = 0;
public void Activate()
{
State = ScreenState.Active;
Player player = new Player(this);
Objects.Add(player);
return;
}
public void Deactivate()
{
State = ScreenState.Hidden;
return;
}
public void Update(GameTime gameTime)
{
foreach (var obj in Objects)
{
obj.Update(gameTime);
if (obj.Type == ObjectType.Player)
{
// obj.TranslateForward();
Manager.Sound.ListenerPosition = new System.Numerics.Vector3(obj.Position.X, obj.Position.Y, obj.Position.Z);
Manager.Sound.ListenerOrientationForward = System.Numerics.Vector3.Normalize(new System.Numerics.Vector3(obj.Rotation.Forward.X, obj.Rotation.Forward.Y, obj.Rotation.Forward.Z));
Manager.Sound.ListenerOrientationUpwards = System.Numerics.Vector3.Normalize(new System.Numerics.Vector3(obj.Rotation.Up.X, obj.Rotation.Up.Y, obj.Rotation.Up.Z));
Manager.Listener.Position = obj.Position;
Manager.Listener.Forward = obj.Rotation.Forward;
Manager.Listener.Up = obj.Rotation.Up;
// Console.WriteLine(Manager.Sound.ListenerOrientationForward);
// Console.WriteLine(Manager.Sound.ListenerOrientationUpwards);
}
}
return;
}
public void HandleInput(GameTime gameTime, KeyboardState inputs)
{
}
}
}