public GameObject(string name, Scene scene, Vector2 position) { OnComponentAddedEvent += GameObject_OnComponentAddedEvent; Components = new Dictionary <int, IComponent>(); Name = name; Scene = scene; Tags = new List <string>(); Body = BodyFactory.CreateBody(scene.World, ConvertUnits.ToSimUnits(position), 0f, this); Body.UserData = this; Body.IsStatic = false; Position = position; Body.OnCollision += Body_OnCollision; if (scene.DrawSystem.GetType() == typeof(NormalDrawSystem)) { _drawSystem = (NormalDrawSystem)Scene.DrawSystem; _useNormalDrawSystem = true; } }
public Light(Vector2 position, Scene scene) : base("Light", scene, position) { _scene = scene; scene.Pipeline.LoadContent <Texture2D>("BasicLightEffect", scene.Content, true); Sprite = new Sprite(this, "BasicLightEffect"); try { _drawSystem = (NormalDrawSystem)_scene.DrawSystem; } catch (InvalidCastException e) { throw new InvalidCastException("Can't use Light object because it is dependent on NormalLightSystem!"); } catch (NullReferenceException d) { throw new NullReferenceException("DrawSystem cannot be null!"); } this.AddComponent("Texture", Sprite); _color = Sprite.Color; _intensity = 1f; this.Body.IsStatic = true; }