Example #1
0
 protected override void UpdateEntity(float dt, Entity entity)
 {
     var tc = entity.Get<TypeChanger>();
     if ((tc.TTL -= dt) <= 0)
     {
         for (int i = 0; i < entity.Count(); ++i)
         {
             entity.Transform(i, tc.Transformation);
         }
     }
 }
Example #2
0
        protected override void UpdateEntity(float dt, Entity entity)
        {
            if (entity.Count() == 0)
            {
                return;
            }
            var direction = entity.Get<Direction>();
            var position = entity.Get<Position>();
            var input = entity.Get<InputComponent>();
            var hotspots = entity.Get<Hotspots>();

            float accel = dt * 0.8f;
            if (input.Right)
            {
                direction.X[0] = direction.X[0] + accel * (24.0f - direction.X[0]);
            }
            if (input.Left)
            {
                direction.X[0] = direction.X[0] + accel * (-24.0f - direction.X[0]);
            }
            if (!(input.Left || input.Right))
            {
                if (hotspots.BottomHit[0])
                {
                    direction.X[0] = direction.X[0] + dt * (0 - direction.X[0]);
                }
                else
                {
                    direction.X[0] = direction.X[0] + dt * .1f * (0 - direction.X[0]);
                }
            }
            if (input.Jump && hotspots.BottomHit[0])
            {
                if (input.Down)
                {
                    direction.Y[0] = 1.5f;
                    entity.Transform(0, input.DroppingPlayer);
                    input.DroppingPlayer.Get<TypeChanger>().Transformation = entity;
                    input.DroppingPlayer.Get<TypeChanger>().TTL = 0.8f;
                }
                else
                {
                    direction.Y[0] = -32.0f;
                }
            }
        }