コード例 #1
0
        public static Offset GetOffset(
            long speedInMillipixelsPerMillisecond,
            long movementDirectionInMillidegrees,
            long elapsedMillisecondsPerIteration)
        {
            if (speedInMillipixelsPerMillisecond < 0)
            {
                throw new Exception();
            }

            if (speedInMillipixelsPerMillisecond == 0)
            {
                return new Offset {
                           DeltaXInMillipixels = 0, DeltaYInMillipixels = 0
                }
            }
            ;

            movementDirectionInMillidegrees = DTMath.NormalizeAngleInMillidegrees(movementDirectionInMillidegrees);

            long numberOfMillipixels = speedInMillipixelsPerMillisecond * elapsedMillisecondsPerIteration;

            return(new Offset
            {
                DeltaXInMillipixels = numberOfMillipixels * DTMath.SineScaled(milliDegrees: movementDirectionInMillidegrees) / 1000L,
                DeltaYInMillipixels = numberOfMillipixels * DTMath.CosineScaled(milliDegrees: movementDirectionInMillidegrees) / 1000L
            });
        }
コード例 #2
0
            public long Evaluate(
                EnemyObjectExpressionInfo enemyObjectExpressionInfo,                 // nullable
                long playerXMillis,
                long playerYMillis,
                long elapsedMillisecondsPerIteration,
                IDTDeterministicRandom rng)
            {
                long operand = this.operand.Evaluate(
                    enemyObjectExpressionInfo: enemyObjectExpressionInfo,
                    playerXMillis: playerXMillis,
                    playerYMillis: playerYMillis,
                    elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration,
                    rng: rng);

                return(DTMath.SineScaled(operand));
            }