Пример #1
0
        /// <summary>
        /// Creates a player from a given user object - this is an entity ready to be sent into a simulation game.
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public static Entity CreatePlayer(User user, Vector2 location)
        {
            var entity = new Entity();

            var transformComponent = new TransformComponent(location, new Vector2(50, 70));
            var nameComponent      = new NameComponent(user.Name);
            var skinComponent      = new SkinComponent(user.SessionConfig.Skin);
            var playerComponent    = new PlayerComponent();
            var bombModifier       = new BombCountModifierComponent();
            var rangeModifier      = new RangeModifierComponent();
            var movementModifier   = new MovementModifierComponent();

            // Add modifier components to the sprite

            playerComponent.Connection  = user.Connection;
            playerComponent.SecureToken = user.SecureToken;

            entity.AddComponent(transformComponent);
            entity.AddComponent(nameComponent);
            entity.AddComponent(skinComponent);
            entity.AddComponent(playerComponent);
            entity.AddComponent(bombModifier);
            entity.AddComponent(rangeModifier);
            entity.AddComponent(movementModifier);

            return(entity);
        }
Пример #2
0
        public static Entity CreateBombCountUpPackage(Vector2 location)
        {
            var entity = new Entity();

            var rangeModifier = new BombCountModifierComponent();
            var list          = new List <PowerUpComponent>();
            var transform     = new TransformComponent(location, new Vector2(32, 32));

            list.Add(rangeModifier);
            var powerupPackage = new PowerUpCollectionComponent(list);
            var skinComponent  = new SkinComponent(rangeModifier.SkinName);

            entity.AddComponent(powerupPackage);
            entity.AddComponent(skinComponent);
            entity.AddComponent(transform);

            return(entity);
        }