Exemplo n.º 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 (operand2 == 0)
                {
                    throw new Exception();
                }
                return(unchecked (operand1 / operand2));
            }
Exemplo n.º 2
0
            public long Evaluate(
                EnemyObjectExpressionInfo enemyObjectExpressionInfo,                 // nullable
                long playerXMillis,
                long playerYMillis,
                long elapsedMillisecondsPerIteration,
                IDTDeterministicRandom rng)
            {
                long value = this.operand.Evaluate(
                    enemyObjectExpressionInfo: enemyObjectExpressionInfo,
                    playerXMillis: playerXMillis,
                    playerYMillis: playerYMillis,
                    elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration,
                    rng: rng);

                if (value == long.MinValue)
                {
                    return(long.MinValue);
                }

                if (value < 0)
                {
                    return(-value);
                }

                return(value);
            }
Exemplo n.º 3
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));
            }
Exemplo n.º 4
0
            public long Evaluate(
                EnemyObjectExpressionInfo enemyObjectExpressionInfo,                 // nullable
                long playerXMillis,
                long playerYMillis,
                long elapsedMillisecondsPerIteration,
                IDTDeterministicRandom rng)
            {
                long randomExclusiveBound = this.operand.Evaluate(
                    enemyObjectExpressionInfo: enemyObjectExpressionInfo,
                    playerXMillis: playerXMillis,
                    playerYMillis: playerYMillis,
                    elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration,
                    rng: rng);

                if (randomExclusiveBound <= 0)
                {
                    throw new Exception();
                }

                long randomByte1 = rng.NextInt(128);
                long randomByte2 = rng.NextInt(256);
                long randomByte3 = rng.NextInt(256);
                long randomByte4 = rng.NextInt(256);
                long randomByte5 = rng.NextInt(256);
                long randomByte6 = rng.NextInt(256);
                long randomByte7 = rng.NextInt(256);
                long randomByte8 = rng.NextInt(256);
                long randomLong  =
                    (randomByte1 << 56)
                    | (randomByte2 << 48)
                    | (randomByte3 << 40)
                    | (randomByte4 << 32)
                    | (randomByte5 << 24)
                    | (randomByte6 << 16)
                    | (randomByte7 << 8)
                    | (randomByte8);

                if (randomLong < 0)
                {
                    randomLong = unchecked (-randomLong);
                }

                if (randomLong < 0)
                {
                    randomLong = 0;
                }

                if (randomExclusiveBound == 1)
                {
                    return(0);
                }

                // Note that this isn't perfectly uniform for large values of randomExclusiveBound
                // but it'll decent enough for now.
                long randomVal = randomLong % randomExclusiveBound;

                return(randomVal);
            }
Exemplo n.º 5
0
 public long Evaluate(
     EnemyObjectExpressionInfo enemyObjectExpressionInfo,                 // nullable
     long playerXMillis,
     long playerYMillis,
     long elapsedMillisecondsPerIteration,
     IDTDeterministicRandom rng)
 {
     return(this.value);
 }
Exemplo n.º 6
0
 public long Evaluate(
     EnemyObjectExpressionInfo enemyObjectExpressionInfo,                 // nullable
     long playerXMillis,
     long playerYMillis,
     long elapsedMillisecondsPerIteration,
     IDTDeterministicRandom rng)
 {
     if (enemyObjectExpressionInfo == null)
     {
         throw new Exception();
     }
     return(enemyObjectExpressionInfo.YMillis);
 }
Exemplo n.º 7
0
        public EnemyObjectExpressionInfo Parent;         // nullable

        public EnemyObjectExpressionInfo(
            Dictionary <string, long> numericVariables,
            Dictionary <string, bool> booleanVariables,
            long xMillis,
            long yMillis,
            long?milliHP,
            EnemyObjectExpressionInfo parent)
        {
            this.NumericVariables = numericVariables;
            this.BooleanVariables = booleanVariables;
            this.XMillis          = xMillis;
            this.YMillis          = yMillis;
            this.MilliHP          = milliHP;
            this.Parent           = parent;
        }
Exemplo n.º 8
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.CosineScaled(operand));
            }
Exemplo n.º 9
0
 public long Evaluate(
     EnemyObjectExpressionInfo enemyObjectExpressionInfo,                 // nullable
     long playerXMillis,
     long playerYMillis,
     long elapsedMillisecondsPerIteration,
     IDTDeterministicRandom rng)
 {
     if (enemyObjectExpressionInfo == null)
     {
         throw new Exception();
     }
     if (enemyObjectExpressionInfo.Parent == null)
     {
         throw new Exception();
     }
     return(enemyObjectExpressionInfo.Parent.NumericVariables[this.variableName]);
 }
Exemplo n.º 10
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);

                return(operand1 > operand2 ? operand1 : operand2);
            }
Exemplo n.º 11
0
        public bool Evaluate(
            EnemyObjectExpressionInfo enemyObjectExpressionInfo, // nullable
            bool?isParentDestroyed,                              // null if parent doesn't exist
            bool isPlayerDestroyed,
            long playerXMillis,
            long playerYMillis,
            long elapsedMillisecondsPerIteration,
            IDTDeterministicRandom rng)
        {
            switch (this.BooleanExpressionType)
            {
            case Type.True:
                return(true);

            case Type.False:
                return(false);

            case Type.Variable:
                if (enemyObjectExpressionInfo == null)
                {
                    throw new Exception();
                }
                return(enemyObjectExpressionInfo.BooleanVariables[this.VariableName]);

            case Type.ParentVariable:
                if (enemyObjectExpressionInfo == null)
                {
                    throw new Exception();
                }
                if (enemyObjectExpressionInfo.Parent == null)
                {
                    throw new Exception();
                }
                return(enemyObjectExpressionInfo.Parent.BooleanVariables[this.VariableName]);

            case Type.IsParentDestroyed:
                if (isParentDestroyed == null)
                {
                    throw new Exception();
                }
                return(isParentDestroyed.Value);

            case Type.IsPlayerDestroyed:
                return(isPlayerDestroyed);

            case Type.Equal:
            case Type.NotEqual:
            case Type.GreaterThan:
            case Type.GreaterThanOrEqualTo:
            case Type.LessThan:
            case Type.LessThanOrEqualTo:
                long leftSide = this.MathLeftSide.Evaluate(
                    enemyObjectExpressionInfo: enemyObjectExpressionInfo,
                    playerXMillis: playerXMillis,
                    playerYMillis: playerYMillis,
                    elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration,
                    rng: rng);
                long rightSide = this.MathRightSide.Evaluate(
                    enemyObjectExpressionInfo: enemyObjectExpressionInfo,
                    playerXMillis: playerXMillis,
                    playerYMillis: playerYMillis,
                    elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration,
                    rng: rng);

                if (this.BooleanExpressionType == Type.Equal)
                {
                    return(leftSide == rightSide);
                }
                else if (this.BooleanExpressionType == Type.NotEqual)
                {
                    return(leftSide != rightSide);
                }
                else if (this.BooleanExpressionType == Type.GreaterThan)
                {
                    return(leftSide > rightSide);
                }
                else if (this.BooleanExpressionType == Type.GreaterThanOrEqualTo)
                {
                    return(leftSide >= rightSide);
                }
                else if (this.BooleanExpressionType == Type.LessThan)
                {
                    return(leftSide < rightSide);
                }
                else if (this.BooleanExpressionType == Type.LessThanOrEqualTo)
                {
                    return(leftSide <= rightSide);
                }
                else
                {
                    throw new Exception();
                }

            case Type.And:
            case Type.Or:
            case Type.Not:
                bool operand1 = this.BooleanOperand1.Evaluate(
                    enemyObjectExpressionInfo: enemyObjectExpressionInfo,
                    isParentDestroyed: isParentDestroyed,
                    isPlayerDestroyed: isPlayerDestroyed,
                    playerXMillis: playerXMillis,
                    playerYMillis: playerYMillis,
                    elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration,
                    rng: rng);

                if (this.BooleanExpressionType == Type.Not)
                {
                    return(!operand1);
                }

                if (this.BooleanExpressionType == Type.And && operand1 == false)
                {
                    return(false);
                }
                if (this.BooleanExpressionType == Type.Or && operand1 == true)
                {
                    return(true);
                }

                bool operand2 = this.BooleanOperand2.Evaluate(
                    enemyObjectExpressionInfo: enemyObjectExpressionInfo,
                    isParentDestroyed: isParentDestroyed,
                    isPlayerDestroyed: isPlayerDestroyed,
                    playerXMillis: playerXMillis,
                    playerYMillis: playerYMillis,
                    elapsedMillisecondsPerIteration: elapsedMillisecondsPerIteration,
                    rng: rng);

                if (this.BooleanExpressionType == Type.And)
                {
                    return(operand1 && operand2);
                }
                else if (this.BooleanExpressionType == Type.Or)
                {
                    return(operand1 || operand2);
                }
                else
                {
                    throw new Exception();
                }

            default:
                throw new Exception();
            }
        }