protected override void OnUpdate() { for (int i = 0; i < Collisions.Length; ++i) { CollisionComponent data = Collisions.Data[i]; if (EntityManager.Exists(data.source) && !EntityManager.HasComponent <Destroy>(data.source) && EntityManager.HasComponent <Stats>(data.source) && EntityManager.Exists(data.target) && !EntityManager.HasComponent <Destroy>(data.target) && EntityManager.HasComponent <Stats>(data.target)) { Stats sourceStats = EntityManager.GetComponentData <Stats>(data.source); Stats targetStats = EntityManager.GetComponentData <Stats>(data.target); if (sourceStats.Aggression > targetStats.Aggression) { // Eating sourceStats.Health += targetStats.Nutrition; sourceStats.TotalMeals += targetStats.Nutrition; sourceStats.LastMealTime = DateTime.Now.Ticks; PostUpdateCommands.SetComponent <Stats>(data.source, sourceStats); PostUpdateCommands.AddComponent <Destroy>(data.target, new Destroy()); } } } }
public static Entity Create(string saveData) { var loaded = JsonSerializer.Deserialize <SaveData>(saveData); var entity = new Entity().Init(entityId: loaded.EntityId, entityName: loaded.EntityName); foreach (var component in loaded.Components) { entity.AddComponent(component); } // TODO: Formalize this into a "template" concept if (entity.EntityName == "boundary sign") { entity.AddComponent(CollisionComponent.Create(true, false)); entity.AddComponent(DefenderComponent.Create(9999, 9999, 9999, 9999, 9999, logDamage: false, isInvincible: true)); entity.AddComponent(DisplayComponent.Create("res://resources/sprites/edge_blocker.png", "Trying to run away, eh? Get back to your mission!", true, 2)); }/* else if (entity.EntityName == "satellite") { * entity.AddComponent(CollisionComponent.Create(blocksMovement: true, blocksVision: true)); * entity.AddComponent(DefenderComponent.Create(baseDefense: int.MaxValue, maxHp: int.MaxValue, isInvincible: true, logDamage: false)); * entity.AddComponent(DisplayComponent.Create("res://resources/sprites/asteroid.png", "Space junk. Blocks movement and projectiles. Cannot be destroyed.", true, 2)); * }*/ return(entity); }
public void IncludesEntityGroup() { var component = CollisionComponent.Create(false, false); JsonElement deserialized = JsonSerializer.Deserialize <JsonElement>(component.Save()); Assert.Equal(CollisionComponent.ENTITY_GROUP, deserialized.GetProperty("EntityGroup").GetString()); }
public void Update(GameTime gameTime) { List <Tuple <int, CollisionComponent, PositionComponent> > c = new List <Tuple <int, CollisionComponent, PositionComponent> >(); foreach (var entity in collisions) { CollisionComponent collisionComponent = entity.Item1; PositionComponent positionComponent = entity.Item2; c.Add(new Tuple <int, CollisionComponent, PositionComponent>(entity.Entity, collisionComponent, positionComponent)); } for (int i = 0; i < c.Count; i++) { for (int j = i + 1; j < c.Count; j++) { Rectangle r1, r2; r1 = c[i].Item2.CollisionBox; r1.Offset(-r1.Width / 2, -r1.Height / 2); r1.Offset(c[i].Item3.Position); r2 = c[j].Item2.CollisionBox; r2.Offset(-r2.Width / 2, -r2.Height / 2); r2.Offset(c[j].Item3.Position); if (r1.Intersects(r2)) { ResolveCollision(c[i], c[j], r1, r2); } } } }
void InitGrass() { string content = FileTool.ReadStringByFile(Environment.CurrentDirectory + "/Map/GrassData.txt"); string[] contentArray = content.Split('\n'); for (int i = 0; i < contentArray.Length; i++) { if (contentArray[i] != "") { SyncComponent sc = new SyncComponent(); Area aera = deserializer.Deserialize <Area>(contentArray[i]); GrassComponent gc = new GrassComponent(); CollisionComponent cc = new CollisionComponent(); cc.area = aera; cc.isStatic = true; m_world.CreateEntityImmediately("Grass" + i, gc, cc, sc); //Debug.Log("Create Grass"); } } }
public void InitMap() { List <Area> list = new List <Area>(); string content = FileTool.ReadStringByFile(Environment.CurrentDirectory + "/Map/mapData.txt"); string[] contentArray = content.Split('\n'); for (int i = 0; i < contentArray.Length; i++) { if (contentArray[i] != "") { list.Add(deserializer.Deserialize <Area>(contentArray[i])); } } Debug.Log("Create map list " + list.Count); for (int i = 0; i < list.Count; i++) { CollisionComponent cc = new CollisionComponent(); cc.area = list[i]; cc.isStatic = true; SyncComponent sc = new SyncComponent(); BlockComponent bc = new BlockComponent(); m_world.CreateEntityImmediately("Block" + i, cc, sc, bc); //Debug.Log("Create map"); } }
/* * 动态更新: * 从根节点深入四叉树,检查四叉树各个节点存储的物体是否依旧属于该节点(象限)的范围之内,如果不属于,则重新插入该物体。 */ public void Refresh(QuadTree root = null) { if (root == null) { root = this; } for (int i = 0; i < m_objectListCount; i++) { CollisionComponent cc = m_objectList[i]; if (!cc.isStatic) { if (!m_body.CheckIsInnner(cc.area)) { m_objectList.RemoveAt(i); m_objectListCount--; i--; root.Insert(cc); } } } for (int i = 0; i < m_childListCount; i++) { m_childList[i].Refresh(root); } }
/* * 检索功能: * 给出一个物体对象,该函数负责将该物体可能发生碰撞的所有物体选取出来。该函数先查找物体所属的象限,该象限下的物体都是有可能发生碰撞的,然后再递归地查找子象限.. */ public List <CollisionComponent> Retrieve(CollisionComponent coll) { listCache.Clear(); //Debug.Log("m_childListCount " + m_childListCount); if (m_childListCount != 0) { bool[] indexList = GetRetrieveIndex(coll.area); for (int i = 0; i < 4; i++) { if (indexList[i]) { listCache.AddRange(m_childList[i].Retrieve(coll)); } } } listCache.AddRange(m_objectList); //Debug.Log("Retrieve " + listCache.Count + " depth " + m_depth); return(listCache); }
/// <summary> /// Creates an new Player with Controlls /// </summary> /// <param name="pixlePer"> True if pixelPerfect shall be used </param> /// <param name="GamePade"> True if GamePad the player uses a gamepad </param> /// <param name="PadJump"> Key binding to gamePad </param> /// <param name="Jump"> key binding to keybord </param> /// <param name="position"> Player start Position </param> /// <param name="name"> The name off the player</param> /// <param name="dir"> The players starting direction</param> /// <param name="index"> Playerindex For GamePad </param> /// <returns></returns> public int CreatePlayer(bool pixlePer, bool GamePade, Buttons PadJump, Keys Jump, Vector2 position, string name, Direction dir, PlayerIndex index, Color colour) { SpriteEffects flip; GamePadComponent gam; KeyBoardComponent kcb; int id = ComponentManager.Instance.CreateID(); if (dir == Direction.Left) { flip = SpriteEffects.FlipHorizontally; } else { flip = SpriteEffects.None; } if (GamePade == true) { gam = new GamePadComponent(index); gam.gamepadActions.Add(ActionsEnum.Jump, PadJump); ComponentManager.Instance.AddComponentToEntity(id, gam); } else { kcb = new KeyBoardComponent(); kcb.keyBoardActions.Add(ActionsEnum.Jump, Jump); ComponentManager.Instance.AddComponentToEntity(id, kcb); } DirectionComponent dc = new DirectionComponent(dir); DrawableComponent comp = new DrawableComponent(Game.Instance.GetContent <Texture2D>("Pic/kanin1"), flip); PositionComponent pos = new PositionComponent(position); VelocityComponent vel = new VelocityComponent(new Vector2(200F, 0), 50F); JumpComponent jump = new JumpComponent(300F, 200F); CollisionRectangleComponent CRC = new CollisionRectangleComponent(new Rectangle((int)pos.position.X, (int)pos.position.Y, comp.texture.Width, comp.texture.Height)); CollisionComponent CC = new CollisionComponent(pixlePer); PlayerComponent pc = new PlayerComponent(name); DrawableTextComponent dtc = new DrawableTextComponent(name, Color.Black, Game.Instance.GetContent <SpriteFont>("Fonts/TestFont")); HUDComponent hudc = new HUDComponent(Game.Instance.GetContent <Texture2D>("Pic/PowerUp"), new Vector2(pos.position.X, pos.position.Y)); HUDComponent hudc2 = new HUDComponent(Game.Instance.GetContent <Texture2D>("Pic/PowerUp"), Vector2.One); HealthComponent hc = new HealthComponent(3, false); //AnimationComponent ani = new AnimationComponent(100, 114, comp.texture.Width, comp.texture.Height, 0.2); comp.colour = colour; ComponentManager.Instance.AddComponentToEntity(id, vel); ComponentManager.Instance.AddComponentToEntity(id, comp); ComponentManager.Instance.AddComponentToEntity(id, pos); ComponentManager.Instance.AddComponentToEntity(id, CRC); ComponentManager.Instance.AddComponentToEntity(id, CC); ComponentManager.Instance.AddComponentToEntity(id, pc); ComponentManager.Instance.AddComponentToEntity(id, dtc); ComponentManager.Instance.AddComponentToEntity(id, hudc); ComponentManager.Instance.AddComponentToEntity(id, hc); //ComponentManager.Instance.AddComponentToEntity(id, ani); ComponentManager.Instance.AddComponentToEntity(id, dc); ComponentManager.Instance.AddComponentToEntity(id, jump); return(id); }
public static Entity NewOutOfBounds(Vector3 positionStart, Vector3 positionEnd) { Entity outOfBounds = EntityFactory.NewEntity(GameEntityFactory.OUTOFBOUNDS); CollisionComponent box = new CollisionComponent(outOfBounds, new BoxVolume(new BoundingBox(positionStart, positionEnd))); ComponentManager.Instance.AddComponentToEntity(outOfBounds, box, typeof(CollisionComponent)); return(outOfBounds); }
private void SetupTest() { go = new GameObject(); Collisions = new CollisionComponent(); otherGo = new GameObject(); otherCollider = otherGo.AddComponent <BoxCollider2D>(); }
void DebugLogic(CollisionComponent a, CollisionComponent b) { if (Filter(a, b)) { Debug.Log("Collision print a " + a.Entity.ID + " -> " + Serializer.Serialize(a.area) + "\n b " + b.Entity.ID + " ->" + Serializer.Serialize(b.area) + "\n AreaCollideSucceed " + a.area.AreaCollideSucceed(b.area) + " frame " + m_world.FrameCount); } }
public bool IsColliding(Entity entity) { if (entity == null) { return(false); } return(CollisionComponent.Intersects(entity.CollisionComponent)); }
private bool CollidesWith(CollisionComponent collision, GameObject object2) { if (collision.collidesWith.Count == 0 || collision.collidesWith.Contains(object2.GroupName)) { return(true); } return(false); }
public override void FixedUpdate(int deltaTime) { //Debug.Log(" ---------------CollisionComponent---------------"); clist.Clear(); List <EntityBase> list = GetEntityList(); for (int i = 0; i < list.Count; i++) { CollisionComponent acc = (CollisionComponent)list[i].GetComp("CollisionComponent"); acc.CollisionList.Clear(); clist.Add(acc); } //string content = ""; for (int i = 0; i < clist.Count; i++) { CollisionComponent acc = clist[i]; if (list[i].GetExistComp("MoveComponent")) { MoveComponent amc = (MoveComponent)list[i].GetComp("MoveComponent"); acc.area.position = amc.pos.ToVector(); acc.area.direction = amc.dir.ToVector(); } for (int j = i + 1; j < list.Count; j++) { CollisionComponent bcc = clist[j]; //两个静态对象之间不计算阻挡 if (acc.isStatic && bcc.isStatic) { continue; } if (list[j].GetExistComp("MoveComponent")) { MoveComponent bmc = (MoveComponent)list[j].GetComp("MoveComponent"); bcc.area.position = bmc.pos.ToVector(); bcc.area.direction = bmc.dir.ToVector(); } if (acc.area.AreaCollideSucceed(bcc.area)) { acc.CollisionList.Add(bcc.Entity); bcc.CollisionList.Add(acc.Entity); } //分开碰撞的对象 } } }
// This method is called in the handleFireWeapon method to create the bullet // that is fired from the entity. It will give the bullet all the necessary components. public void CreateBullet(InputEvent inputEvent, SpriteComponent bulletSpriteComponent, WeaponComponent weaponComponent, MoveComponent moveComponent, RenderComponent renderComponent, PositionComponent positionComponent) { // We create an new position instance for the bullet that starts from the player but should // not be the same as the players, as we found out when we did our test, otherwise the player // will follow the same way ass the bullet. var bulletPositionComponent = new PositionComponent() { Position = new Vector2(positionComponent.Position.X, positionComponent.Position.Y), ZIndex = positionComponent.ZIndex }; int bulletEntityId = EntityManager.GetEntityManager().NewEntity(); var bulletRenderComponent = new RenderComponent() { DimensionsComponent = new DimensionsComponent() { Height = 10, Width = 10 } }; var bulletMoveComponent = new MoveComponent() { AccelerationSpeed = 0, Speed = 1000, MaxVelocitySpeed = 1000, Direction = moveComponent.Direction }; var bulletComponent = new BulletComponent() { Damage = weaponComponent.Damage, ShooterEntityId = inputEvent.EntityId }; var bulletCollisionComponent = new CollisionComponent(); var animationComponent = new AnimationComponent(); ComponentManager.AddComponentToEntity(bulletPositionComponent, bulletEntityId); ComponentManager.AddComponentToEntity(bulletComponent, bulletEntityId); ComponentManager.AddComponentToEntity(bulletSpriteComponent, bulletEntityId); ComponentManager.AddComponentToEntity(bulletMoveComponent, bulletEntityId); ComponentManager.AddComponentToEntity(bulletRenderComponent, bulletEntityId); ComponentManager.AddComponentToEntity(bulletCollisionComponent, bulletEntityId); ComponentManager.AddComponentToEntity(animationComponent, bulletEntityId); var animation = new GeneralAnimation() { AnimationType = "BulletAnimation", StartOfAnimation = inputEvent.EventTime, Length = 2000, Unique = true }; NewBulletAnimation(animation, bulletEntityId); animationComponent.Animations.Add(animation); }
private void DrawCollisionRect(CollisionComponent component) { RectangleShape rect = new RectangleShape(new Vector2f(component.Size.X, component.Size.Y)); rect.Position = new Vector2f(component.Position.X, component.Position.Y); rect.FillColor = Color.Transparent; rect.OutlineThickness = 1; rect.OutlineColor = Color.White; renderTarget.Draw(rect); }
public static Entity CreateEdgeBlockerEntity() { var e = CreateEntity(Guid.NewGuid().ToString(), "boundary sign"); e.AddComponent(CollisionComponent.Create(true, false)); e.AddComponent(DefenderComponent.Create(0, 100, logDamage: false, isInvincible: true)); e.AddComponent(DisplayComponent.Create(_texEdgeBlockerPath, "Trying to run away, eh? Get back to your mission!", true, ENTITY_Z_INDEX)); return(e); }
/* * Translates a bounding sphere component to be at the same world position as a transform component. */ public static void SetInitialBoundingSpherePos(CollisionComponent collisionComponent, TransformComponent transformComponent) { Matrix translation = EngineHelper.Instance().WorldMatrix *Matrix.CreateTranslation(transformComponent.Position.X, transformComponent.Position.Y, transformComponent.Position.Z); //var boundingSphere = collisionComponent.BoundingShape; //boundingSphere = collisionComponent.BoundingShape.Transform(translation); //collisionComponent.BoundingShape = boundingSphere; collisionComponent.BoundingVolume.UpdateVolume(translation.Translation); }
public static Entity CreateSatelliteEntity() { var e = CreateEntity(Guid.NewGuid().ToString(), "satellite"); e.AddComponent(CollisionComponent.Create(blocksMovement: true, blocksVision: true)); e.AddComponent(DefenderComponent.Create(baseDefense: int.MaxValue, maxHp: int.MaxValue, isInvincible: true, logDamage: false)); e.AddComponent(DisplayComponent.Create(_texSatellitePath, "Space junk. Blocks movement and projectiles. Cannot be destroyed.", true, ENTITY_Z_INDEX)); return(e); }
public void AddCube(Transform cube) { _childsCube.Add(cube); cube.tag = "PlayerItem"; CollisionComponent collComp = cube.gameObject.AddComponent <CollisionComponent>(); collComp.ContainerComponent = this; _camera.transform.Rotate(new Vector3(0.5f, 0, 0)); }
public void TestCollision() { IEntity entity = new Entity(null, Vector2.Zero, Vector2.Zero, false); var collisionComponent = new CollisionComponent(entity); entity.Update(); Assert.IsTrue(entity.HasComponent <CollisionComponent>()); Assert.AreSame(collisionComponent, entity.GetComponent <CollisionComponent>()); Assert.AreSame(entity, entity.GetComponent <CollisionComponent>().Parent); }
public bool CheckIfCollision(CollisionComponent a, CollisionComponent b) { if (a.BBox.Intersects(b.BBox)) { return(true); } else { return(false); } }
bool CanCreate(CollisionComponent comp) { for (int i = 0; i < comp.CollisionList.Count; i++) { if (comp.CollisionList[i].GetExistComp <ItemComponent>()) { return(false); } } return(true); }
protected override void Initialize() { if (Owner != null) { collide = new CollisionComponent(ID + "Collision", bounds); collide.OnCollided += new CollisionEvent(_Collided); Owner.AttachComponent(collide); } base.Initialize(); }
public void ConstructorSetsOwnerTag() { // Used to set something collideable where the other side handles the collision // eg. this is a wall and the player will collide against it var expectedTag = "Wall"; var c = new CollisionComponent(expectedTag); Assert.That(c.OwnerTag, Is.EqualTo(expectedTag)); Assert.That(c.TargetTag, Is.Null); Assert.That(c.OnCollide, Is.Null); }
/// <summary> /// Creates this system. /// </summary> /// <param name="game"></param> public WeaponSystem(DungeonCrawlerGame game) { _game = game; //To simplfy some things, I'm keeping a reference to components I often use. _collisionComponent = _game.CollisionComponent; _equipmentComponent = _game.EquipmentComponent; _playerInfoComponent = _game.PlayerInfoComponent; _weaponComponent = _game.WeaponComponent; _weaponSpriteComponent = _game.WeaponSpriteComponent; _positionComponent = _game.PositionComponent; }
private void UpdatePos(CollisionComponent c) { ComponentManager cm = ComponentManager.Instance; Entity e = cm.GetEntityOfComponent <CollisionComponent>(c); Position2DComponent p = cm.GetEntityComponent <Position2DComponent>(e); if (p != null) { c.CollisionArea.SetX(p.Position.X); c.CollisionArea.SetY(p.Position.Y); } }
/// <summary> /// Creates this system. /// </summary> /// <param name="game"></param> public WeaponSystem(DungeonCrawlerGame game) { _game = game; //To simplfy some things, I'm keeping a reference to components I often use. _collisionComponent = _game.CollisionComponent; _equipmentComponent = _game.EquipmentComponent; _playerInfoComponent = _game.PlayerInfoComponent; _weaponComponent = _game.WeaponComponent; _weaponSpriteComponent = _game.WeaponSpriteComponent; _positionComponent = _game.PositionComponent; }
public void SerializesAndDeserializesCorrectly() { var component = CollisionComponent.Create(true, false, true, true); string saved = component.Save(); var newComponent = CollisionComponent.Create(saved); Assert.Equal(component.BlocksMovement, newComponent.BlocksMovement); Assert.Equal(component.BlocksVision, newComponent.BlocksVision); Assert.Equal(component.OnCollisionAttack, newComponent.OnCollisionAttack); Assert.Equal(component.OnCollisionSelfDestruct, newComponent.OnCollisionSelfDestruct); }
void AddCollisionEvent(Collision _collision, CollisionEvent.EVENT_TYPE _type) { CollisionComponent cc = _collision.collider.gameObject.GetComponent <CollisionComponent>(); if (cc != null) { CollisionEvent ce = GetCollisionEvent(); ce.m_Collision = _collision; ce.m_EventType = _type; ce.m_OtherComponent = cc; m_CurrentEvents.Add(ce); } }
public void CheckCollisionsAgainst(CollisionComponent other) { int collision = 0; for(int i = 0; i < prims.Count; ++i) { for(int y = 0; y < other.prims.Count; ++y) { CollResult c = prims[i].CheckAgainst(other.prims[y], tran, other.tran); if(c.collided) { if (callback != null) callback(this, other, c, collision); CollResult otherC = c; otherC.normal *= -1; if(other.callback != null) other.callback(other, this, otherC, collision++); } //Note, currently multiple callbacks can be made, each with their own index } } }
public override void Initialize() { base.Initialize(); _collision = new CollisionComponent(); _collision.Parent = EntityMock.Object; _movement = new MovementComponent(); _movement.Parent = EntityMock.Object; _position = new PositionComponent(); _position.Parent = EntityMock.Object; _movement.RegisterDependencies(_position); _movement.RegisterDependencies(_collision); _collision.RegisterDependencies(_position); _collision.RegisterDependencies(_movement); _position.Start(Container); _movement.Start(Container); _collision.Start(Container); }
public static Boolean AreColliding(CollisionComponent comp1, CollisionComponent comp2) { if (comp1 is CollisionRectangle && comp2 is CollisionRectangle) { return RectRect((CollisionRectangle)comp1, (CollisionRectangle)comp2); } else if (comp1 is CollisionRectangle && comp2 is CollisionCircle) { return RectCirc((CollisionRectangle)comp1, (CollisionCircle)comp2); } else if (comp1 is CollisionCircle && comp2 is CollisionRectangle) { // n.b. - arguments are reversed return RectCirc((CollisionRectangle)comp2, (CollisionCircle)comp1); } else if (comp1 is CollisionCircle && comp2 is CollisionCircle) { return CircCirc((CollisionCircle)comp1, (CollisionCircle)comp2); } throw new Exception("CollisionDetector.AreColliding cannot handle arguments: " + comp1 + " and " + comp2); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { AggregateFactory = new AggregateFactory(this); WeaponFactory = new WeaponFactory(this); DoorFactory = new DoorFactory(this); RoomFactory = new RoomFactory(this); CollectableFactory = new CollectibleFactory(this); WallFactory = new WallFactory(this); EnemyFactory = new EnemyFactory(this); SkillEntityFactory = new SkillEntityFactory(this); NPCFactory = new NPCFactory(this); // Initialize Components PlayerComponent = new PlayerComponent(); LocalComponent = new LocalComponent(); RemoteComponent = new RemoteComponent(); PositionComponent = new PositionComponent(); MovementComponent = new MovementComponent(); MovementSpriteComponent = new MovementSpriteComponent(); SpriteComponent = new SpriteComponent(); DoorComponent = new DoorComponent(); RoomComponent = new RoomComponent(); HUDSpriteComponent = new HUDSpriteComponent(); HUDComponent = new HUDComponent(); InventoryComponent = new InventoryComponent(); InventorySpriteComponent = new InventorySpriteComponent(); ContinueNewGameScreen = new ContinueNewGameScreen(graphics, this); EquipmentComponent = new EquipmentComponent(); WeaponComponent = new WeaponComponent(); BulletComponent = new BulletComponent(); PlayerInfoComponent = new PlayerInfoComponent(); WeaponSpriteComponent = new WeaponSpriteComponent(); StatsComponent = new StatsComponent(); EnemyAIComponent = new EnemyAIComponent(); NpcAIComponent = new NpcAIComponent(); CollectibleComponent = new CollectibleComponent(); CollisionComponent = new CollisionComponent(); TriggerComponent = new TriggerComponent(); EnemyComponent = new EnemyComponent(); NPCComponent = new NPCComponent(); //QuestComponent = new QuestComponent(); LevelManager = new LevelManager(this); SpriteAnimationComponent = new SpriteAnimationComponent(); SkillProjectileComponent = new SkillProjectileComponent(); SkillAoEComponent = new SkillAoEComponent(); SkillDeployableComponent = new SkillDeployableComponent(); SoundComponent = new SoundComponent(); ActorTextComponent = new ActorTextComponent(); TurretComponent = new TurretComponent(); TrapComponent = new TrapComponent(); ExplodingDroidComponent = new ExplodingDroidComponent(); HealingStationComponent = new HealingStationComponent(); PortableShieldComponent = new PortableShieldComponent(); PortableStoreComponent = new PortableStoreComponent(); ActiveSkillComponent = new ActiveSkillComponent(); PlayerSkillInfoComponent = new PlayerSkillInfoComponent(); Quests = new List<Quest>(); #region Initialize Effect Components AgroDropComponent = new AgroDropComponent(); AgroGainComponent = new AgroGainComponent(); BuffComponent = new BuffComponent(); ChanceToSucceedComponent = new ChanceToSucceedComponent(); ChangeVisibilityComponent = new ChangeVisibilityComponent(); CoolDownComponent = new CoolDownComponent(); DamageOverTimeComponent = new DamageOverTimeComponent(); DirectDamageComponent = new DirectDamageComponent(); DirectHealComponent = new DirectHealComponent(); FearComponent = new FearComponent(); HealOverTimeComponent = new HealOverTimeComponent(); InstantEffectComponent = new InstantEffectComponent(); KnockBackComponent = new KnockBackComponent(); TargetedKnockBackComponent = new TargetedKnockBackComponent(); ReduceAgroRangeComponent = new ReduceAgroRangeComponent(); ResurrectComponent = new ResurrectComponent(); StunComponent = new StunComponent(); TimedEffectComponent = new TimedEffectComponent(); EnslaveComponent = new EnslaveComponent(); CloakComponent = new CloakComponent(); #endregion base.Initialize(); }
private void LoadCollisionComponent(GameEntity entity, CollisionComponentInfo info) { var comp = new CollisionComponent(); entity.AddComponent(comp); comp.Loadinfo(info); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { AggregateFactory = new AggregateFactory(this); WeaponFactory = new WeaponFactory(this); DoorFactory = new DoorFactory(this); RoomFactory = new RoomFactory(this); CollectableFactory = new CollectibleFactory(this); WallFactory = new WallFactory(this); EnemyFactory = new EnemyFactory(this); // Initialize Components PlayerComponent = new PlayerComponent(); LocalComponent = new LocalComponent(); RemoteComponent = new RemoteComponent(); PositionComponent = new PositionComponent(); MovementComponent = new MovementComponent(); MovementSpriteComponent = new MovementSpriteComponent(); SpriteComponent = new SpriteComponent(); DoorComponent = new DoorComponent(); RoomComponent = new RoomComponent(); HUDSpriteComponent = new HUDSpriteComponent(); HUDComponent = new HUDComponent(); InventoryComponent = new InventoryComponent(); InventorySpriteComponent = new InventorySpriteComponent(); ContinueNewGameScreen = new ContinueNewGameScreen(graphics, this); EquipmentComponent = new EquipmentComponent(); WeaponComponent = new WeaponComponent(); BulletComponent = new BulletComponent(); PlayerInfoComponent = new PlayerInfoComponent(); WeaponSpriteComponent = new WeaponSpriteComponent(); StatsComponent = new StatsComponent(); EnemyAIComponent = new EnemyAIComponent(); CollectibleComponent = new CollectibleComponent(); CollisionComponent = new CollisionComponent(); TriggerComponent = new TriggerComponent(); EnemyComponent = new EnemyComponent(); QuestComponent = new QuestComponent(); LevelManager = new LevelManager(this); SpriteAnimationComponent = new SpriteAnimationComponent(); SkillProjectileComponent = new SkillProjectileComponent(); SkillAoEComponent = new SkillAoEComponent(); SkillDeployableComponent = new SkillDeployableComponent(); //TurretComponent = new TurretComponent(); //TrapComponent = new TrapComponent(); //PortableShopComponent = new PortableShopComponent(); //PortableShieldComponent = new PortableShieldComponent(); //MotivateComponent = new MotivateComponent(); //FallbackComponent = new FallbackComponent(); //ChargeComponent = new ChargeComponent(); //HealingStationComponent = new HealingStationComponent(); //ExplodingDroidComponent = new ExplodingDroidComponent(); base.Initialize(); }
public void Initialize() { _entityMock = new Mock<IEntity>(); _container = new FakeGameplayContainer(); _screen = new Mock<ITiledScreen>(); _entityMock.SetupGet(e => e.Screen).Returns(_screen.Object); _entityMock.SetupGet(e => e.Container).Returns(_container); _entityMock.SetupGet(e => e.IsGravitySensitive).Returns(false); _container.IsGravityFlipped = false; _collision = new CollisionComponent(); _collision.Parent = _entityMock.Object; }