Example #1
0
 public override void onAddedToEntity()
 {
     this.bugEntity   = (Bug1)entity;
     this.boxCollider = entity.getComponent <BoxCollider>();
     this.mover       = entity.getComponent <TiledMapMover>();
     moveDir          = new Vector2(-1, 0);
 }
Example #2
0
 public override void onAddedToEntity()
 {
     base.onAddedToEntity();
     sprite  = entity.getComponent <Sprite>();
     moveBox = entity.getComponent <BoxCollider>();
     mover   = entity.getComponent <TiledMapMover>();
 }
 public void LoadInPlayer()
 {
     PlayerEntity      = createEntity(myPlayerInfo.UserID);
     PlayerDirectional = new DirectionalSprite(myPlayerInfo.GetLastSpriteDirection());
     PlayerEntity.addComponent(PlayerDirectional);
     PlayerTileMapMover = new TiledMapMover(myCollisionLayer);
     PlayerEntity.addComponent(PlayerTileMapMover);
 }
Example #4
0
        public override void onAddedToEntity()
        {
            base.onAddedToEntity();

            mover        = this.getComponent <TiledMapMover>();
            box          = this.getComponent <BoxCollider>();
            sprite       = this.getComponent <Sprite <Animations.Boss> >();
            initialState = Animations.Boss.Walk;
        }
Example #5
0
        public override void onAddedToEntity()
        {
            boxCollider = entity.getComponent <BoxCollider>();
            mover       = entity.getComponent <TiledMapMover>();
            animations  = entity.addComponent(new Sprite <Animations>());

            loadUpAnimations();
            setupInput();
        }
Example #6
0
        public override void onAddedToEntity()
        {
            base.onAddedToEntity();
            loadContent();

            _boxCollider    = entity.getComponent <BoxCollider>();
            _mover          = entity.getComponent <TiledMapMover>();
            _physicsHandler = entity.getComponent <PhysicsHandler>();
        }
Example #7
0
        public override void onAddedToEntity()
        {
            base.onAddedToEntity();
            mover    = this.getComponent <TiledMapMover>();
            collider = entity.getComponent <BoxCollider>();

            grounded   = false;
            coyoteTime = DateTime.Now;
        }
Example #8
0
 public override void onAddedToEntity()
 {
     input       = entity.getComponent <Input>();
     mover       = entity.getComponent <TiledMapMover>();
     sprite      = entity.getComponent <Sprite>();
     collider    = entity.getComponents <BoxCollider>().FirstOrDefault(c => c.name == "hurtbox");
     velocity    = Vector2.Zero;
     maxSpeedVec = new Vector2(maxSpeed, maxSpeed);
 }
Example #9
0
        public override void onAddedToEntity()
        {
            base.onAddedToEntity();

            _mover         = this.getComponent <TiledMapMover>();
            _collider      = entity.getCollider <BoxCollider>();
            _triggerHelper = new ColliderTriggerHelper(entity);

            p = entity as Player;
        }
Example #10
0
        /// <summary>
        /// Init
        /// </summary>
        public override void onAddedToEntity()
        {
            this.playerEntity    = (Player)this.entity;
            this.boxCollider     = entity.getComponent <BoxCollider>();
            this.mover           = entity.getComponent <TiledMapMover>();
            this.playerAnimation = entity.getComponent <PlayerAnimations>();
            this.initialPosition = playerEntity.position;
            this.moveDir         = Vector2.Zero;

            setupInput();
        }
Example #11
0
        public override void OnAddedToEntity()
        {
            Stats = Entity.GetComponent <UnitStat>();

            Animator = Entity.AddComponent(new SpriteAnimator());
            AddAnimations();

            AddColliders();

            Mover = Entity.GetComponent <TiledMapMover>();
            TiledCollisionState = new TiledMapMover.CollisionState();
        }
Example #12
0
        /// <summary>
        ///
        /// </summary>
        public override void onAddedToScene()
        {
            base.onAddedToScene();

            //Add a static sprite to the player for standing
            Subtexture tex = new Subtexture(this.scene.content.Load <Texture2D>("Sprites/StandingCharacter"));

            playerSprite.setRenderLayer(-99); //Make sure that the player sprite is always on top
            playerSprite.setSubtexture(tex);
            addComponent(playerSprite);


            //Set animation sprite from spritesheet
            Texture2D spriteSheet     = this.scene.content.Load <Texture2D>("Sprites/WalkingSpriteSheet");
            int       subSpriteWidth  = 18;
            int       subSpriteHeight = 23;

            //Goes through 4 times because there are 4 walking animation frames
            //Gets the sub sprite images out of the spritesheet
            for (int i = 0; i < 4; i++)
            {
                ;
                Rectangle sourceRectangle = new Rectangle((i * subSpriteWidth), 0, subSpriteWidth, subSpriteHeight);
                Texture2D cropTexture     = new Texture2D(graphics, sourceRectangle.Width, sourceRectangle.Height);
                Color[]   data            = new Color[sourceRectangle.Width * sourceRectangle.Height];
                spriteSheet.GetData(0, sourceRectangle, data, 0, data.Length);
                cropTexture.SetData(data);
                walkingAnimation.addFrame(new Subtexture(cropTexture));
            }
            playerSprite.addAnimation(Animations.WalkingRight, walkingAnimation);


            playerSprite.addAnimation(Animations.standing, new SpriteAnimation().addFrame(tex)); //Set the standing animation (right now it is just a single frame)

            //Add the controller and mover and add collision layers to the mover
            addComponent <PlayerController>();
            TiledMapMover mapMover = new TiledMapMover(map.getLayer <TiledTileLayer>("CollidableLayer1")); //Add the first collision layer

            for (int i = 1; i < numCollisionLayers; i++)
            {
                int    num       = i + 1;
                string layerName = "CollidableLayer" + num.ToString();
                mapMover.addCollisionLayer(map.getLayer <TiledTileLayer>(layerName));
            }
            addComponent(mapMover);
            addCollider(new BoxCollider(-tex.sourceRect.Width / 2, -tex.sourceRect.Height / 2, tex.sourceRect.Width, tex.sourceRect.Height));

            //Add an ObjectInteractor
            addComponent(new ObjectInteractor(this.scene, map, numObjLayers));

            //Add ItemHandler
            addComponent(new ItemHandler());
        }
Example #13
0
        public override void OnAddedToEntity()
        {
            var texture = Entity.Scene.Content.LoadSpriteAtlas("Content/Assets/Player/Player.atlas");

            _boxCollider = Entity.GetComponent <BoxCollider>();
            _mover       = Entity.GetComponent <TiledMapMover>();
            _animator    = Entity.AddComponent(new SpriteAnimator());
            _animator.AddAnimationsFromAtlas(texture);
            _animator.Speed = 0.7f;
            _animator.Play("idle");
            SetupInput();
        }
Example #14
0
        public override void onAddedToEntity()
        {
            base.onAddedToEntity();
            hp = entity.getComponent <Health>();
            animationManager = entity.getComponent <AnimationManager>();
            camera           = entity.scene.camera;
            mover            = entity.getComponent <TiledMapMover>();
            sprite           = entity.getComponent <Sprite <Animations> >();
            var boxes = entity.getComponents <BoxCollider>();

            moveBox      = boxes.FirstOrDefault(c => c.name == Constants.Strings.MoveCollider);
            maxSpeedVec  = new Vector2(moveSpeed * 2f, moveSpeed * 3f);
            sprite.flipX = true;
        }
Example #15
0
        public override void OnAddedToEntity()
        {
            Mover               = this.getComponent <TiledMapMover>();
            Collider            = this.getComponent <BoxCollider>();
            RegularStateMachine = new GroundedState();
            SpeedState          = new SpeedModiferState();
            Sprite              = this.getComponent <Sprite <PlayerAnimationState> >();
            Input               = this.getComponent <PlayerInput>();

            RegularStateMachine.Begin(this);
            SpeedState.Begin(this);

            base.OnAddedToEntity();
        }
Example #16
0
        public override void onAddedToEntity()
        {
            boxCollider   = entity.getComponent <BoxCollider>();
            mover         = entity.getComponent <TiledMapMover>();
            animations    = entity.addComponent(new Sprite <Animations>());
            senseCollider = entity.getComponent <CircleCollider>();

            hitCounter = 0;

            senseCollider.isTrigger = true;

            isAlive = true;

            loadUpAnimations();
        }
Example #17
0
        public override void OnAddedToEntity()
        {
            _mover       = this.GetComponent <TiledMapMover>();
            _boxCollider = Entity.GetComponent <BoxCollider>();

            _xAxisInput = new VirtualIntegerAxis();
            _xAxisInput.Nodes.Add(new VirtualAxis.KeyboardKeys(VirtualInput.OverlapBehavior.TakeNewer, Microsoft.Xna.Framework.Input.Keys.A, Microsoft.Xna.Framework.Input.Keys.D));

            _jumpInput = new VirtualButton();
            _jumpInput.Nodes.Add(new VirtualButton.KeyboardKey(Microsoft.Xna.Framework.Input.Keys.Space));

            _animator = Entity.AddComponent <SpriteAnimator>();
            atlas     = thisScene.Content.LoadSpriteAtlas("Content/out.atlas");
            _animator.AddAnimationsFromAtlas(atlas);
            camera = this.GetComponent <Camera>();
        }
Example #18
0
        public Debris(TiledTileLayer collisionLayer, Vector2 position, List <Subtexture> subtextures, float xDir = 0f, float yDir = 0f) : base()
        {
            //get initial vel
            float xSpeed = Nez.Random.range(-maxSpeedX, maxSpeedX);
            float ySpeed = Nez.Random.range(-maxYSpeed, minYSpeed);

            if (xDir > 0f)
            {
                xSpeed = Nez.Random.range(0f, 2f * maxSpeedX);
            }
            else if (xDir < 0f)
            {
                xSpeed = Nez.Random.range(-maxSpeedX, 0f);
            }
            if (yDir > 0f)
            {
                ySpeed = Nez.Random.range(0f, maxYSpeed);
            }
            else if (yDir < 0f)
            {
                ySpeed = Nez.Random.range(-maxYSpeed, 0f);
            }
            //sprite
            int spriteNum = Nez.Random.range(144, 149);
            var sprite    = new Sprite(subtextures[spriteNum]);

            sprite.renderLayer = (int)Constants.RenderLayers.Decorative;
            //sprite.color = new Color(90, 83, 83);
            addComponent(sprite);
            //move collide box
            var box = new BoxCollider(4, 4);

            box.name = Constants.Strings.MoveCollider;
            addComponent(box);
            //tiled mover
            var tiledMover = new TiledMapMover(collisionLayer);

            addComponent(tiledMover);
            //debris controller
            var controller = new DebrisController();

            controller.SetInitialy(new Vector2(xSpeed, ySpeed));
            addComponent(controller);

            this.position = position;
        }
Example #19
0
        /// <summary>
        ///
        /// </summary>
        public override void onAddedToScene()
        {
            base.onAddedToScene();

            //Add a static sprite to the enemy for standing
            Subtexture tex = new Subtexture(this.scene.content.Load <Texture2D>("Sprites/DefaultSmallEnemy"));

            enemySprite.setRenderLayer(-9);
            enemySprite.setSubtexture(tex);
            addComponent(enemySprite);

            //Add the physics collider
            BoxCollider mainCollider = new BoxCollider(-tex.sourceRect.Width / 2, -tex.sourceRect.Height / 2, tex.sourceRect.Width, tex.sourceRect.Height);

            addCollider(mainCollider);

            //Attack area
            //This is the box around the enemy that if a player is in it then they will actively attack the player
            int         xMult          = 15;
            int         yMult          = 7;
            BoxCollider attackCollider = new BoxCollider((-tex.sourceRect.Width * xMult) / 2, (-tex.sourceRect.Height * yMult) / 2, tex.sourceRect.Width * xMult, tex.sourceRect.Height * yMult);

            addCollider(attackCollider);

            Vector2 updatedPos = new Vector2(transform.position.X, transform.position.Y - mainCollider.height / 2);

            transform.setPosition(updatedPos);

            //Create and add the mover
            mapMover = new TiledMapMover(map.getLayer <TiledTileLayer>("CollidableLayer1")); //Add the first collision layer
            for (int i = 1; i < numCollisionLayers; i++)
            {
                int    num       = i + 1;
                string layerName = "CollidableLayer" + num.ToString();
                mapMover.addCollisionLayer(map.getLayer <TiledTileLayer>(layerName));
            }
            addComponent(mapMover);

            //Add enemy controller
            enemyController = new GroundEnemyController(mapMover, mainCollider, attackCollider);
            addComponent(enemyController);
        }
Example #20
0
        public override void onAddedToEntity()
        {
            mover            = entity.getComponent <TiledMapMover>();
            animationManager = entity.getComponent <AnimationManager>();
            sprite           = animationManager.sprite;
            weaponSprite     = entity.getComponents <Sprite>().First((s) => s.name == Strings.Weapon);
            var boxes = entity.getComponents <BoxCollider>();

            moveBox = boxes.FirstOrDefault(c => c.name == Constants.Strings.MoveCollider);
            hurtBox = boxes.FirstOrDefault(c => c.name == Constants.Strings.HitCollider);
            //velocity = Vector2.Zero;
            maxSpeedVec   = new Vector2(moveSpeed * 2f, moveSpeed * 3f);
            triggerHelper = new ColliderTriggerHelper(entity);
            animationManager.Play(Animations.PlayerIdle);

            var gs = (GameScene)entity.scene;

            jumpSound  = gs.JumpSound;
            shootSound = gs.ShootSound;
        }
Example #21
0
        public override void initialize()
        {
            base.initialize();

            createWithDefaultRenderer(Color.CornflowerBlue);
            setDesignResolution(1280, 720, SceneResolutionPolicy.ShowAllPixelPerfect);
            clearColor = Color.Black;

            //load up our TiledMap
            var tiledMap    = content.Load <TiledMap>(Paths.Misc.tiledMap);
            var objectLayer = tiledMap.getObjectGroup("objects");
            var spawnObject = objectLayer.objectWithName("spawn");
            var tiledEntity = createEntity("tiled-map-entity");
            var topLeft     = new Vector2(tiledMap.tileWidth - Constants.tilePaddingSize, tiledMap.tileWidth + Constants.tilePaddingSize);
            var bottomRight = new Vector2(tiledMap.tileWidth * (tiledMap.width - 1) + Constants.tilePaddingSize,
                                          tiledMap.tileWidth * (tiledMap.height - 1) + Constants.tilePaddingSize);

            tiledEntity.addComponent(new CameraBounds(topLeft, bottomRight));
            var tiledMapComponent = tiledEntity.addComponent(new TiledMapComponent(tiledMap, "collision"));
            var tiledMapMover     = new TiledMapMover(tiledMapComponent.collisionLayer, false);

            Flags.setFlagExclusive(ref tiledMapComponent.physicsLayer, 0);

            var bomber = addEntity(new Bomber());

            bomber.addComponent(tiledMapMover);

            var cucumber = addEntity(new Cucumber());

            cucumber.addComponent(tiledMapMover);

            bomber.position   = new Vector2(spawnObject.x, spawnObject.y);
            cucumber.position = new Vector2(spawnObject.x + 50, spawnObject.y + 50);

            camera.entity.addComponent(new FollowCamera(bomber)); //add follow camera for player

            addPostProcessor(new VignettePostProcessor(1));
        }
Example #22
0
        public override void onAddedToEntity()
        {
            base.onAddedToEntity();

            //switch to a buterfly animation when get one.
            //var texture = entity.scene.content.Load<Texture2D>(Content.Textures.butterfly1);

            var texture = entity.scene.content.Load <Texture2D>(Content.Textures.caveman);

            _boxCollider = entity.getComponent <BoxCollider>();
            _mover       = entity.getComponent <TiledMapMover>();

            var subtextures = Subtexture.subtexturesFromAtlas(texture, 32, 32);

            _animation = entity.addComponent(new Sprite <Animations>(subtextures[0]));
            //extract the animations from the atlas they are setup in rows with 8 columns
            _animation.addAnimation(Animations.Walk, new SpriteAnimation(new List <Subtexture>()
            {
                subtextures[0],
                subtextures[1],
                subtextures[2],
                subtextures[3],
                subtextures[4],
                subtextures[5]
            }
                                                                         ));

            _animation.addAnimation(Animations.Run, new SpriteAnimation(new List <Subtexture>()
            {
                subtextures[8 + 0],
                subtextures[8 + 1],
                subtextures[8 + 2],
                subtextures[8 + 3],
                subtextures[8 + 4],
                subtextures[8 + 5],
                subtextures[8 + 6]
            }));

            _animation.addAnimation(Animations.Idle, new SpriteAnimation(new List <Subtexture>()
            {
                subtextures[16]
            }));

            _animation.addAnimation(Animations.Attack, new SpriteAnimation(new List <Subtexture>()
            {
                subtextures[24 + 0],
                subtextures[24 + 1],
                subtextures[24 + 2],
                subtextures[24 + 3]
            }));

            _animation.addAnimation(Animations.Death, new SpriteAnimation(new List <Subtexture>()
            {
                subtextures[40 + 0],
                subtextures[40 + 1],
                subtextures[40 + 2],
                subtextures[40 + 3]
            }));

            _animation.addAnimation(Animations.Falling, new SpriteAnimation(new List <Subtexture>()
            {
                subtextures[48]
            }));

            _animation.addAnimation(Animations.Hurt, new SpriteAnimation(new List <Subtexture>()
            {
                subtextures[64],
                subtextures[64 + 1]
            }));

            _animation.addAnimation(Animations.Jumping, new SpriteAnimation(new List <Subtexture>()
            {
                subtextures[72 + 0],
                subtextures[72 + 1],
                subtextures[72 + 2],
                subtextures[72 + 3]
            }));
            setupInput();
        }
Example #23
0
        public override void OnAddedToEntity()
        {
            var texture = Entity.Scene.Content.LoadTexture("Content/Tilesets/caveman.png");
            var sprites = Sprite.SpritesFromAtlas(texture, 32, 32);

            _camera = Entity.Scene.Camera;

            _boxCollider = Entity.GetComponent <BoxCollider>();
            _mover       = Entity.GetComponent <TiledMapMover>();
            _animator    = Entity.AddComponent(new SpriteAnimator(sprites[0]));

            // extract the animations from the atlas. they are setup in rows with 8 columns
            _animator.AddAnimation("Walk", new[]
            {
                sprites[0],
                sprites[1],
                sprites[2],
                sprites[3],
                sprites[4],
                sprites[5]
            });

            _animator.AddAnimation("Run", new[]
            {
                sprites[8 + 0],
                sprites[8 + 1],
                sprites[8 + 2],
                sprites[8 + 3],
                sprites[8 + 4],
                sprites[8 + 5],
                sprites[8 + 6]
            });

            _animator.AddAnimation("Idle", new[]
            {
                sprites[16]
            });

            _animator.AddAnimation("Attack", new[]
            {
                sprites[24 + 0],
                sprites[24 + 1],
                sprites[24 + 2],
                sprites[24 + 3]
            });

            _animator.AddAnimation("Death", new[]
            {
                sprites[40 + 0],
                sprites[40 + 1],
                sprites[40 + 2],
                sprites[40 + 3]
            });

            _animator.AddAnimation("Falling", new[]
            {
                sprites[48]
            });

            _animator.AddAnimation("Hurt", new[]
            {
                sprites[64],
                sprites[64 + 1]
            });

            _animator.AddAnimation("Jumping", new[]
            {
                sprites[72 + 0],
                sprites[72 + 1],
                sprites[72 + 2],
                sprites[72 + 3]
            });

            SetupInput();
        }
Example #24
0
 /// <summary>
 ///
 /// </summary>
 public GroundEnemyController(TiledMapMover mover, BoxCollider physicsCollider, BoxCollider attackCollider)
 {
     this.enemyMover       = mover;
     this.enemyCollider    = physicsCollider;
     this.enemyAttCollider = attackCollider;
 }
 public override void onAddedToEntity()
 {
     _mover       = this.getComponent <TiledMapMover>();
     _boxCollider = entity.getComponent <BoxCollider>();
 }
Example #26
0
 public override void onAddedToEntity()
 {
     mover  = this.getComponent <TiledMapMover>();
     box    = this.getComponent <BoxCollider>();
     sprite = this.getComponent <Sprite <Animations.Main> >();
 }
Example #27
0
 public void setMover(TiledMapMover mover)
 {
     _mover = mover;
 }
 /// <summary>
 ///
 /// </summary>
 public override void onAddedToEntity()
 {
     base.onAddedToEntity();
     _mover    = entity.getComponent <TiledMapMover>();
     _collider = entity.getCollider <BoxCollider>();
 }
Example #29
0
        /// <summary>
        /// Does all the stuff needed when essentially spawning in
        /// </summary>
        public override void onAddedToScene()
        {
            base.onAddedToScene();

            state = States.dropped;

            MasterScene mScene = this.scene as MasterScene;

            swordSprite.setRenderLayer(-9);
            addComponent(swordSprite);

            Rectangle sourceRectangle;
            Texture2D cropTexture;

            Color[] data;

            #region Set Idle Animation
            //Set idle animation sprite from spritesheet
            Texture2D spriteSheet     = this.scene.content.Load <Texture2D>("Sprites/DefaultSwordSpinningSpriteSheet");
            int       subSpriteWidth  = 11;
            int       subSpriteHeight = 24;
            //Goes through 4 times because there are 4 walking animation frames
            //Gets the sub sprite images out of the spritesheet
            for (int i = 0; i < 4; i++)
            {
                sourceRectangle = new Rectangle((i * subSpriteWidth), 0, subSpriteWidth, subSpriteHeight);
                cropTexture     = new Texture2D(graphics, sourceRectangle.Width, sourceRectangle.Height);
                data            = new Color[sourceRectangle.Width * sourceRectangle.Height];
                spriteSheet.GetData(0, sourceRectangle, data, 0, data.Length);
                cropTexture.SetData(data);
                idleAnimation.addFrame(new Subtexture(cropTexture));
            }
            swordSprite.addAnimation(Animations.idle, idleAnimation);
            #endregion

            //Then play the idle animation because it just spawned in
            swordSprite.play(Animations.idle);


            Texture2D swingSpriteSheet = this.scene.content.Load <Texture2D>("Sprites/DefaultSwordSpriteSheet");
            subSpriteWidth  = 22;
            subSpriteHeight = 24;
            #region Set Held Animation
            //Add the sprite animation for the sword being held
            sourceRectangle = new Rectangle(0, 0, subSpriteWidth, subSpriteHeight);
            cropTexture     = new Texture2D(graphics, sourceRectangle.Width, sourceRectangle.Height);
            data            = new Color[sourceRectangle.Width * sourceRectangle.Height];
            swingSpriteSheet.GetData(0, sourceRectangle, data, 0, data.Length);
            cropTexture.SetData(data);
            //Subtexture heldSprite = new Subtexture(this.scene.content.Load<Texture2D>("Sprites/DefaultSword"));
            swordSprite.addAnimation(Animations.held, new SpriteAnimation().addFrame(new Subtexture(cropTexture)));
            #endregion

            #region Set Swing animation
            //Add the swinging animation
            //Goes through 4 times because there are 4 walking animation frames
            //Gets the sub sprite images out of the spritesheet for the swinging
            for (int i = 0; i < 4; i++)
            {
                sourceRectangle = new Rectangle((i * subSpriteWidth), 0, subSpriteWidth, subSpriteHeight);
                cropTexture     = new Texture2D(graphics, sourceRectangle.Width, sourceRectangle.Height);
                data            = new Color[sourceRectangle.Width * sourceRectangle.Height];
                swingSpriteSheet.GetData(0, sourceRectangle, data, 0, data.Length);
                cropTexture.SetData(data);
                swingAnimation.addFrame(new Subtexture(cropTexture));
            }
            swingAnimation.setLoop(false);
            swingAnimation.setFps(20);
            swordSprite.addAnimation(Animations.swing, swingAnimation);
            #endregion

            #region Add the controller so the object can move with physics
            //Add the controller and mover and add collision layers to the mover
            TiledMapMover mapMover = new TiledMapMover(mScene.tileMap.getLayer <TiledTileLayer>("CollidableLayer1")); //Add the first collision layer
            for (int i = 1; i < mScene.numOfCollisionLayers; i++)
            {
                int    num       = i + 1;
                string layerName = "CollidableLayer" + num.ToString();
                mapMover.addCollisionLayer(mScene.tileMap.getLayer <TiledTileLayer>(layerName));
            }
            addComponent(mapMover);

            //Add controller
            controller = new ObjectMapController(1500);
            addComponent(controller);
            #endregion
            addCollider(new BoxCollider(-swordSprite.width / 2, -swordSprite.height / 2, swordSprite.width, swordSprite.height));

            //Do little bounce when spawning in
            controller.bounce(20);

            spawnTime = 25;
        }
Example #30
0
        public override void OnAddedToEntity()
        {
            #region Load up texture atlas...

            //Load up character texture atlas
            var idleTexture   = Entity.Scene.Content.Load <Texture2D>(Content.Textures.HeroIdle);
            var runTexture    = Entity.Scene.Content.Load <Texture2D>(Content.Textures.HeroRun);
            var attackTexture = Entity.Scene.Content.Load <Texture2D>(Content.Textures.HeroAttack);
            var jumpTexture   = Entity.Scene.Content.Load <Texture2D>(Content.Textures.HeroJump);
            var fallTexture   = Entity.Scene.Content.Load <Texture2D>(Content.Textures.HeroFall);
            var idleSprite    = Sprite.SpritesFromAtlas(idleTexture, 50, 37);
            var runSprite     = Sprite.SpritesFromAtlas(runTexture, 50, 37);
            var attackSprite  = Sprite.SpritesFromAtlas(attackTexture, 50, 37);
            var jumpSprite    = Sprite.SpritesFromAtlas(jumpTexture, 50, 37);
            var fallSprite    = Sprite.SpritesFromAtlas(fallTexture, 50, 37);

            #endregion Load up texture atlas...

            #region add componentents...

            //Movement component
            var map = Entity.Scene as SandBoxScene;
            Mover = Entity.AddComponent(new TiledMapMover(map.TiledMap.GetLayer <TmxLayer>("main")));
            //animator component
            Animator = Entity.AddComponent <SpriteAnimator>();

            //Set up collider
            Collider        = Entity.AddComponent <BoxCollider>();
            Collider.Width  = 16;
            Collider.Height = 30;
            Collider.SetLocalOffset(new Vector2(0, 3));
            Flags.SetFlagExclusive(ref Collider.CollidesWithLayers, 1);
            Flags.SetFlagExclusive(ref Collider.PhysicsLayer, 1);

            //CollisionListener
            CollisionListener = Entity.AddComponent <CollisionListener>();

            //SetType
            Type = Entity.AddComponent <TypeComponent>();
            Type.SetType(EntityType.PLAYER);

            //Set up StateMachine
            StateMachine = Entity.AddComponent(new StateMachine());
            StateMachine.AddState(STATES.PLAYER_FREE, new PlayerPlatformerStateFree(this));
            StateMachine.AddState(STATES.PLAYER_ATTACK, new PlayerStateAttack(this));
            StateMachine.CurrentState = STATES.PLAYER_FREE;

            //Set up Camera
            var camera = new FollowCamera(Entity);
            camera.MapLockEnabled = true;

            Entity.AddComponent(camera);
            var renderer = new DefaultRenderer(camera: camera.Camera);

            Entity.Scene.AddRenderer(renderer);
            //camera.Camera.Position = Entity.Transform.Position;
            camera.MapSize    = new Vector2(1280, 0);
            camera.FollowLerp = .3f;

            #endregion add componentents...

            #region Animations...

            Animator.AddAnimation("IdleSheathed", 3.5f, new[]
            {
                idleSprite[0],
                idleSprite[1],
                idleSprite[2],
                idleSprite[3]
            });
            Animator.AddAnimation("IdleUnSheathed", 3.5f, new[]
            {
                idleSprite[4],
                idleSprite[5],
                idleSprite[6],
                idleSprite[7]
            });
            Animator.AddAnimation("RunSheathed", 7.5f, new[]
            {
                runSprite[0],
                runSprite[1],
                runSprite[2],
                runSprite[3],
                runSprite[4],
                runSprite[5]
            });
            Animator.AddAnimation("RunUnSheathed", 7.5f, new[]
            {
                runSprite[6],
                runSprite[7],
                runSprite[8],
                runSprite[9],
                runSprite[10],
                runSprite[11]
            });
            Animator.AddAnimation("Attack0", 12, new[]
            {
                attackSprite[0],
                attackSprite[1],
                attackSprite[2],
                attackSprite[3],
                attackSprite[4],
                attackSprite[5],
            });
            Animator.AddAnimation("Attack1", 12, new[]
            {
                attackSprite[6],
                attackSprite[7],
                attackSprite[8],
                attackSprite[9],
                attackSprite[10]
            });
            Animator.AddAnimation("Attack2", 12, new[]
            {
                attackSprite[11],
                attackSprite[12],
                attackSprite[13],
                attackSprite[14],
                attackSprite[15],
                attackSprite[16]
            });
            Animator.AddAnimation("Jump", 15, new[] {
                //jumpSprite[0],
                //jumpSprite[1],
                jumpSprite[2],
                jumpSprite[3]
            });
            Animator.AddAnimation("Fall", 8, new[]
            {
                fallSprite[0],
                fallSprite[1]
            });

            #endregion Animations...

            //Set up Input
            SetupInput();
            base.OnAddedToEntity();
        }