Beispiel #1
0
            public long Evaluate(
                EnemyObjectExpressionInfo enemyObjectExpressionInfo,                 // nullable
                long playerXMillis,
                long playerYMillis,
                long elapsedMillisecondsPerIteration,
                IDTDeterministicRandom rng)
            {
                long operand1 = this.operand1.Evaluate(
                    enemyObjectExpressionInfo: enemyObjectExpressionInfo,
                    playerXMillis: playerXMillis,
                    playerYMillis: playerYMillis,
                    elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration,
                    rng: rng);
                long operand2 = this.operand2.Evaluate(
                    enemyObjectExpressionInfo: enemyObjectExpressionInfo,
                    playerXMillis: playerXMillis,
                    playerYMillis: playerYMillis,
                    elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration,
                    rng: rng);

                if (this.changeUndefinedOutputToZero && operand1 == 0L && operand2 == 0L)
                {
                    return(0);
                }

                return(DTMath.ArcTangentScaled(operand1, operand2));
            }
Beispiel #2
0
        // 0 degrees is going straight up
        // 90 degrees is going right
        // 180 degrees is straight down
        // 270 degrees is going left
        // (Note function returns value in millidegrees)
        public static long?GetMovementDirectionInMillidegrees(long currentX, long currentY, long desiredX, long desiredY)
        {
            long deltaX = desiredX - currentX;
            long deltaY = desiredY - currentY;

            if (deltaX == 0 && deltaY == 0)
            {
                return(null);
            }

            long angleInMillidegrees = DTMath.ArcTangentScaled(x: deltaX, y: deltaY);
            long angle2 = -angleInMillidegrees + 90L * 1000L;

            return(DTMath.NormalizeAngleInMillidegrees(angle2));
        }