private void SetInput(CharacterMoveModes moveModes, float rotationAngleRad)
        {
            this.characterInput.MoveModes        = moveModes;
            this.characterInput.RotationAngleRad = rotationAngleRad;

            //// uncomment visualize rotation angle correctness with Physics Visualizer
            //var fromPosition = this.character.Position
            //                   + (0, this.character.ProtoCharacter.CharacterWorldWeaponOffsetRanged);
            //var toPosition = fromPosition + (30, 0).RotateRad(rotationAngleRad);
            //Client.Characters.CurrentPlayerCharacter.PhysicsBody.PhysicsSpace.TestLine(
            //    fromPosition,
            //    toPosition,
            //    collisionGroup: null);

            if (!this.characterInput.HasChanged)
            {
                return;
            }

            this.characterInput.SetChanged(false);

            var command = new CharacterInputUpdate(
                this.characterInput.MoveModes,
                this.characterInput.RotationAngleRad);

            ((PlayerCharacter)this.character.ProtoCharacter)
            .ClientSetInput(command);
        }
Esempio n. 2
0
 public CharacterInputUpdate(
     CharacterMoveModes moveModes,
     float rotationAngleRad)
 {
     this.MoveModes = moveModes;
     this.rotationAngleCompressed = (ushort)(rotationAngleRad
                                             % MathConstants.DoublePI
                                             * MathConstants.RadToDeg
                                             / 360
                                             * ushort.MaxValue);
 }
        public void GetCurrentAnimationSetting(
            ICharacter character,
            CharacterMoveModes moveModes,
            double angle,
            ViewOrientation lastViewOrientation,
            out string starterAnimationName,
            out string currentAnimationName,
            out DrawMode currentDrawMode,
            out float aimCoef,
            out ViewOrientation viewOrientation,
            out bool isIdle)
        {
            this.ClientGetAimingOrientation(character,
                                            angle,
                                            lastViewOrientation,
                                            out viewOrientation,
                                            out aimCoef);

            currentDrawMode = viewOrientation.IsLeft ? DrawMode.Default : DrawMode.FlipHorizontally;

            isIdle = moveModes == CharacterMoveModes.None;
            if (isIdle)
            {
                starterAnimationName = null;
                currentAnimationName = "Idle";
                return;
            }

            if ((moveModes & (CharacterMoveModes.Left | CharacterMoveModes.Right))
                != CharacterMoveModes.None)
            {
                if (viewOrientation.IsLeft && (moveModes & CharacterMoveModes.Left) != 0 ||
                    !viewOrientation.IsLeft && (moveModes & CharacterMoveModes.Right) != 0)
                {
                    starterAnimationName = "RunSideStart";
                    currentAnimationName = "RunSide";
                }
                else
                {
                    starterAnimationName = "RunSideBackwardStart";
                    currentAnimationName = "RunSideBackward";
                }
            }
            else
            {
                // going up or down
                var isMoveUp = (moveModes & CharacterMoveModes.Up) != 0;
                starterAnimationName = isMoveUp ? "RunUpStart" : "RunDownStart";
                currentAnimationName = isMoveUp ? "RunUp" : "RunDown";
            }
        }