public Chest(string name, Guid parent) : base(name, parent) { AddComponent <TransformComponent>(); AddComponent <PhysicsComponent>(); AddComponent <PickupSpawnerComponent>(); AddComponent <SpriteComponent>().Init(AssetManager.Get().Find <Texture2D>(ESpriteAssets.ChestClosed1), Vector2.Zero, new Vector2(2, 2)); //AddComponent<ShadowComponent>().Init(AssetManager.Get().Find<Texture2D>("ChestClosed1"), new Vector2(2, 2), new Vector2(0, 3)); AddComponent <LightingComponent>().Init(AssetManager.Get().Find <Texture2D>(ELightAssets.CircleLight), Vector2.Zero, new Vector2(2, 2), Color.Orange, 0.6f); RectColliderComponent chestCollider = AddComponent <RectColliderComponent>(); chestCollider.Init(AssetManager.Get().Find <Texture2D>(ESpriteAssets.ChestClosed1).Width, AssetManager.Get().Find <Texture2D>(ESpriteAssets.ChestClosed1).Height); chestCollider.Enter += (source, target) => { if (closed) { if (source.HasComponent <SpriteComponent>()) { source.GetComponent <SpriteComponent>().Sprite = AssetManager.Get().Find <Texture2D>(ESpriteAssets.ChestOpened1); } if (source.HasComponent <PickupSpawnerComponent>()) { GetComponent <PickupSpawnerComponent>().Spawn(); } closed = false; } }; //AddComponent<LightingComponent>().Init(AssetManager.Get().Find<Texture2D>("CircleLight")); }
//--------------------------------------------------------------------------- public Spike(string name, Guid parent) : base(name, parent) { IsActive = false; AddComponent <TransformComponent>(); AddComponent <PhysicsComponent>(); RectColliderComponent collider = AddComponent <RectColliderComponent>(); collider.Init(64, 64, BodyType.Static); collider.SetSensor(true); AnimationComponent animation = AddComponent <AnimationComponent>(); animation.Init(AssetManager.Get().Find <Texture2D>(ESpriteAssets.Spikes1), new Vector2(3, 3)); animation.AddSetting(0, new AnimationSetting(3, 1, false) { FPS = 10 }); animation.AddSetting(0, new AnimationSetting(3, 1, true) { FPS = 10 }); Activate(); }
public MeleeWeapon(string name, Guid parent) : base(name, parent) { PhysicsComponent physics = AddComponent <PhysicsComponent>(); physics.Init(BodyType.Dynamic, 0, 0, true); physics.IsGravityAffected = false; physics.Body.Enabled = false; RectColliderComponent collider = AddComponent <RectColliderComponent>(); collider.Init(35, 35, new Vector2(40, -30)); collider.SetSensor(true); }