Beispiel #1
0
        private void Move()
        {
            //Trailing smoke particles
            if (tiLifetimeCounter.ElapsedSoFar > 0.5 - GM.r.FloatBetween(0.1f, 0.3f))
            {
                Vector2 offset = new Vector2(20 * RotationHelper.MyDirection(this, 180).X, 20 * RotationHelper.MyDirection(this, 180).Y);
                new SmokeParticle(Position2D + offset, Vector3.Zero, Vector2.Zero, 0.2f);
                GM.eventM.AddTimer(tiSmokeCounter = new Event(0.5f, "Smoke Counter"));
            }

            if (target.Dead)
            {
                RotationHelper.VelocityInCurrentDirection(this, speed, 0);
            }
            else
            {
                //turnDir = -1, anticlockwise; 0, none; 1, clockwise
                int turnDir = (int)RotationHelper.AngularDirectionTo(this, target.Position, 0, false);

                //Direction to add velocity to, additional angle is 90 * turnDir so -90 for anticlockwise, 90 for clockwise, straight ahead for none
                Vector3 velDir = RotationHelper.MyDirection(this, 90 * turnDir);

                Velocity  = RotationHelper.MyDirection(this, 0) * speed;
                Velocity += velDir * (turnAmount / 5);
                RotationHelper.FaceVelocity(this, DirectionAccuracy.free, false, 0);
            }
        }
Beispiel #2
0
 private void AfterHit(Sprite hit)
 {
     RotationHelper.FaceVelocity(this, DirectionAccuracy.free, false, 0f);
 }