Пример #1
0
        protected override void UpdateInternal(GameTime time)
        {
            Body.SleepingAllowed = false;

            UnsafeDisableEvents();
            var velocity = InputState.MovementSpeed *
                           MovementSpeed;

            var rotationAmount = InputState.RotationSpeed *
                                 RotationSpeed * (time.ElapsedGameTime.TotalMilliseconds / 16.66666);

            //calculate the actual movement by axis
            var x = velocity * Math.Sin(Rotation);
            var y = velocity * -Math.Cos(Rotation);

            LinearVelocity  = new Vector2((float)x, (float)y);
            AngularVelocity = 0;
            Rotation       += (float)rotationAmount;
            UnsafeEnableEvents();
            //Set the active weapon
            SetActiveWeapon();
            //And update weapons
            PrimaryWeapon?.Update(time);
            SecondaryWeapon?.Update(time);
            TertiaryWeapon?.Update(time);

            if (ActiveWeapon.Recharged && InputState.FirePressed)
            {
                ActiveWeapon.Fire();
            }
        }
Пример #2
0
 protected override void GetTypeStateHeader(ByteArrayWriter writer)
 {
     writer.Write(PrimaryWeapon != null);
     PrimaryWeapon?.GetFullState(writer);
     writer.Write(SecondaryWeapon != null);
     SecondaryWeapon?.GetFullState(writer);
     writer.Write(TertiaryWeapon != null);
     TertiaryWeapon?.GetFullState(writer);
 }
Пример #3
0
 protected override void SetTypeStateHeader(ByteArrayReader reader)
 {
     if (reader.ReadBool() && PrimaryWeapon != null)
     {
         PrimaryWeapon.SetFullState(reader);
     }
     if (reader.ReadBool() && SecondaryWeapon != null)
     {
         SecondaryWeapon.SetFullState(reader);
     }
     if (reader.ReadBool() && TertiaryWeapon != null)
     {
         TertiaryWeapon.SetFullState(reader);
     }
 }