/// <summary>The build entity.</summary>
        /// <param name="entity">The entity.</param>
        /// <param name="entityWorld">The entityWorld.</param>
        /// <param name="args">The args.</param>
        /// <returns>The <see cref="Entity" />.</returns>
        public Entity BuildEntity(Entity entity, EntityWorld entityWorld, params object[] args)
        {
            entity.Group = "EFFECTS";

            entity.AddComponentFromPool<TransformComponent>();
            entity.AddComponent(new SpatialFormComponent("BulletExplosion"));
            entity.AddComponent(new ExpiresComponent(1000));

            return entity;
        }
        /// <summary>The build entity.</summary>
        /// <param name="entity">The entity.</param>
        /// <param name="entityWorld">The entityWorld.</param>
        /// <param name="args">The args.</param>
        /// <returns>The <see cref="Entity" />.</returns>
        public Entity BuildEntity(Entity entity, EntityWorld entityWorld, params object[] args)
        {
            entity.Group = "BULLETS";

            entity.AddComponentFromPool<TransformComponent>();
            entity.AddComponent(new SpatialFormComponent("Missile"));
            entity.AddComponent(new VelocityComponent());
            entity.AddComponent(new ExpiresComponent(2000));

            return entity;
        }
        /// <summary>The build entity.</summary>
        /// <param name="entity">The entity.</param>
        /// <param name="entityWorld">The entity world.</param>
        /// <param name="args">The args.</param>
        /// <returns>The <see cref="Entity" />.</returns>
        public Entity BuildEntity(Entity entity, EntityWorld entityWorld, params object[] args)
        {
            entity.Group = "SHIPS";

            entity.AddComponentFromPool<TransformComponent>();
            entity.AddComponent(new SpatialFormComponent("EnemyShip"));
            entity.AddComponent(new HealthComponent(10));
            entity.AddComponent(new WeaponComponent());
            entity.AddComponent(new EnemyComponent());
            entity.AddComponent(new VelocityComponent());

            return entity;
        }
Beispiel #4
0
        public Entity BuildEntity(Entity e, EntityWorld world, params object[] args)
        {
            e.AddComponent(new Position());

            e.Refresh();

            return e;
        }
Beispiel #5
0
        public Entity BuildEntity(Entity entity, params object[] args)
        {
            string dataFile = "./Levels/" + args[0] + ".json";
            LevelData levelData = _dataManager.Load<LevelData>(dataFile);

            Nameable nameable = _componentFactory.Create<Nameable>();
            nameable.Name = levelData.Name;

            Map map = _componentFactory.Create<Map>();
            map.Width = levelData.Width;
            map.Height = levelData.Height;
            map.Spritesheet = _contentManager.Load<Texture2D>("./Graphics/Tilesets/" + levelData.Spritesheet);
            map.Tiles = levelData.Tiles;

            entity.AddComponent(nameable);
            entity.AddComponent(map);
            return entity;
        }
        /// <summary>The build entity.</summary>
        /// <param name="entity">The entity.</param>
        /// <param name="entityWorld">The entity world.</param>
        /// <param name="args">The args.</param>
        /// <returns>The built <see cref="Entity" />.</returns>
        public Entity BuildEntity(Entity entity, EntityWorld entityWorld, params object[] args)
        {
            entity.AddComponent(new TestPowerComponent());
            entity.GetComponent<TestPowerComponent>().Power = 100;

            entity.Refresh();

            return entity;
        }
Beispiel #7
0
        public Entity BuildEntity(Entity e, EntityWorld world, params object[] args)
        {
            e.AddComponent(new Direction());
            e.AddComponent(new IsControllable());
            e.AddComponent(new ControllableStates());
            e.AddComponent(new Position());
            e.AddComponent(new Health());
            e.AddComponent(new Velocity());
            e.AddComponent(new TransformC());

            e.Refresh();

            return e;
        }
Beispiel #8
0
        public Physics2dComponent CreateComponent(Entity entity, BodyDefinition definition, bool remoteSync = true)
        {
            var body = CreateBody(definition);

            var component = new Physics2dComponent();
            component.Body = body;
            body.UserData = entity;
            entity.AddComponent(component);

            if (remoteSync)
            {
                ObjectMapper.Create(
                    (uint)entity.UniqueId, typeof(NetPhysicsObject));
            }

            return component;
        }
Beispiel #9
0
        public Entity BuildEntity(Entity entity, params object[] args)
        {
            _characterType = args.Length > 0 ? (CharacterType) args[0] : CharacterType.X;
            LoadPlayerDataFile();

            entity.AddComponent(BuildSprite());
            PlayerAction action = _componentFactory.Create<PlayerAction>();
            action.MaxDashLength = _playerData.MaxDashLength;
            entity.AddComponent(action);
            entity.AddComponent(_componentFactory.Create<Health>());

            Position position = _componentFactory.Create<Position>();
            position.Facing = Direction.Right;
            position.X = (int?) args[1] ?? 0;
            position.Y = (int?) args[2] ?? 0;
            entity.AddComponent(position);

            entity.AddComponent(_componentFactory.Create<LocalData>());
            entity.AddComponent(_componentFactory.Create<Velocity>());
            entity.AddComponent(_componentFactory.Create<Renderable>());
            entity.AddComponent(BuildCollisionBox());
            PlayerCharacter playerCharacter = _componentFactory.Create<PlayerCharacter>();
            playerCharacter.CharacterType = _characterType;
            entity.AddComponent(playerCharacter);

            Nameable nameable = _componentFactory.Create<Nameable>();
            nameable.Name = _playerData.Name;
            entity.AddComponent(nameable);

            Heartbeat heartbeat = _componentFactory.Create<Heartbeat>();
            heartbeat.Interval = _playerData.HeartbeatInterval;
            entity.AddComponent(heartbeat);

            Script script = _componentFactory.Create<Script>();
            script.FilePath = _playerData.Script;
            entity.AddComponent(script);

            EntitySystem.BlackBoard.SetEntry("Player", entity);

            return entity;
        }
Beispiel #10
0
        public Entity BuildEntity(Entity entity, params object[] args)
        {
            string enemyResourceFile = args[0] as string;
            string dataFile = "/Creatures/Enemies/" + enemyResourceFile + ".json";
            CreatureData data = _dataManager.Load<CreatureData>(dataFile);

            Sprite sprite = _componentFactory.Create<Sprite>();
            sprite.Texture = _contentManager.Load<Texture2D>("./Graphics/Enemies/" + data.TextureFile);
            foreach (Animation animation in data.Animations)
            {
                sprite.Animations.Add(animation.Name, animation);
                if (animation.IsDefaultAnimation)
                {
                    sprite.SetCurrentAnimation(animation.Name);
                }
            }

            entity.AddComponent(sprite);
            entity.AddComponent(_componentFactory.Create<Health>());
            Position position = _componentFactory.Create<Position>();
            position.X = (int?) args[1] ?? 0;
            position.Y = (int?) args[2] ?? 0;
            entity.AddComponent(position);
            entity.AddComponent(_componentFactory.Create<Renderable>());
            entity.AddComponent(_componentFactory.Create<Velocity>());
            entity.AddComponent(_componentFactory.Create<Hostile>());
            entity.AddComponent(_componentFactory.Create<LocalData>());

            Nameable nameable = _componentFactory.Create<Nameable>();
            nameable.Name = data.Name;
            entity.AddComponent(nameable);

            Script script = _componentFactory.Create<Script>();
            script.FilePath = data.Script;
            entity.AddComponent(script);

            CollisionBox box = _componentFactory.Create<CollisionBox>();
            box.Width = data.CollisionWidth;
            box.Height = data.CollisionHeight;
            box.OffsetX = data.CollisionOffsetX;
            box.OffsetY = data.CollisionOffsetY;
            entity.AddComponent(box);

            Heartbeat hb = _componentFactory.Create<Heartbeat>();
            hb.Interval = data.HeartbeatInterval;
            entity.AddComponent(hb);

            return entity;
        }