示例#1
0
 public override void OnUpdate()
 {
     if ((HostEntity.CollisionLeft() == ColliderType.Land) || (HostEntity.Location.X <= 0))
     {
         HostEntity.Velocity.X = _speed;
         HostEntity.SetAnime(_rightAnimeStartIndex, _rightAnimeEndIndex, 8);
     }
     if ((HostEntity.CollisionRight() == ColliderType.Land) || (HostEntity.Location.X >= Core.I.CurrentMap.Size.X * 16 - 1))
     {
         HostEntity.Velocity.X = -_speed;
         HostEntity.SetAnime(_leftAnimeStartIndex, _leftAnimeEndIndex, 8);
     }
 }
示例#2
0
 public override void OnInit()
 {
     if (HostEntity.Parent.MainEntity.Location.X < HostEntity.Location.X)
     {
         HostEntity.Velocity.X = -_speed;
         HostEntity.SetAnime(_leftAnimeStartIndex, _leftAnimeEndIndex, 8);
     }
     else
     {
         HostEntity.Velocity.X = _speed;
         HostEntity.SetAnime(_rightAnimeStartIndex, _rightAnimeEndIndex, 8);
     }
     base.OnInit();
 }
示例#3
0
 public override void OnUpdate()
 {
     if ((HostEntity.CollisionLeft() == ColliderType.Land) || (HostEntity.Location.X <= 0))
     {
         HostEntity.Velocity.X = _speed;
         HostEntity.SetAnime(_rightAnimeStartIndex, _rightAnimeEndIndex, 8);
     }
     if ((HostEntity.CollisionRight() == ColliderType.Land) || (HostEntity.Location.X >= Core.I.CurrentMap.Size.X * 16 - 1))
     {
         HostEntity.Velocity.X = -_speed;
         HostEntity.SetAnime(_leftAnimeStartIndex, _leftAnimeEndIndex, 8);
     }
     HostEntity.Velocity.Y = (float)Math.Sin(_deg / 180.0 * Math.PI) * (HostEntity.Direction == Direction.Left ? -1 : 1);
     _deg = (_deg + 5) % 360;
 }
示例#4
0
        public override void OnUpdate()
        {
            _tick++;

            if (_tick > 60)
            {
                var atan =
                    (float)
                    Math.Atan2(HostEntity.Parent.MainEntity.Location.Y - HostEntity.Location.Y,
                               HostEntity.Parent.MainEntity.Location.X - HostEntity.Location.X);
                HostEntity.Velocity.X = (float)Math.Cos(atan);
                HostEntity.Velocity.Y = (float)Math.Sin(atan);
                _tick = 0;
            }
            if (HostEntity.Direction == Direction.Left)
            {
                HostEntity.SetAnime(_leftAnimeStartIndex, _leftAnimeEndIndex, 8);
            }
            else
            {
                HostEntity.SetAnime(_rightAnimeStartIndex, _rightAnimeEndIndex, 8);
            }
        }