private IMathExpression similar(IMathExpression e, Types innerType, Types outerType)
        {
            bool          isAdd = outerType == Types.Addition;
            List <Helper> tmp   = repeatatives(e, isAdd);

            if (tmp.Count == e.getOperands().Count)
            {
                return(e);
            }

            List <IExpressionType> list = new List <IExpressionType>();

            foreach (var h in tmp)
            {
                if (h.count == 1)
                {
                    list.Add(h.expression);
                    continue;
                }

                List <IExpressionType> operands = new List <IExpressionType>();
                operands.Add(h.expression);
                operands.Add(new Number(h.count));
                list.Add(new Function(innerType, operands, ""));
            }

            if (list.Count == 1)
            {
                return((IMathExpression)list[0]);
            }
            return(new Function(outerType, list, ""));
        }
        public override void ExportCode(ActionBranch currentAction, ActionBranch nextAction, ILimnorCodeCompiler compiler, IMethodCompile methodToCompile, System.CodeDom.CodeMemberMethod method, System.CodeDom.CodeStatementCollection statements, bool debug)
        {
            IMathExpression mathExp = MathExp;

            if (mathExp != null)
            {
                CodeExpression ceCondition = null;
                if (Condition != null)
                {
                    ceCondition = Condition.ExportCode(methodToCompile);
                    if (ceCondition != null)
                    {
                        ceCondition = CompilerUtil.ConvertToBool(Condition.DataType, ceCondition);
                    }
                }
                CodeExpression ce = mathExp.ReturnCodeExpression(methodToCompile);
                if (ce != null)
                {
                    if (ceCondition == null)
                    {
                        statements.Add(new CodeMethodReturnStatement(ce));
                    }
                    else
                    {
                        CodeConditionStatement cd = new CodeConditionStatement();
                        cd.Condition = ceCondition;
                        cd.TrueStatements.Add(new CodeMethodReturnStatement(ce));
                        statements.Add(cd);
                    }
                }
            }
        }
 public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     if (context != null && context.Instance != null && provider != null)
     {
         IWindowsFormsEditorService service = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
         if (service != null)
         {
             IWithProject mc = context.Instance as IWithProject;
             if (mc == null)
             {
                 MathNode.Log(new DesignerException("{0} does not implement IWithProject", context.Instance.GetType()));
             }
             else
             {
                 if (mc.Project == null)
                 {
                     MathNode.Log(new DesignerException("Project not set for {0} [{1}]", mc, mc.GetType()));
                 }
                 else
                 {
                     Rectangle       rc = new Rectangle(System.Windows.Forms.Cursor.Position, new Size(20, 60));
                     IMathExpression im = value as IMathExpression;
                     if (im == null)
                     {
                         im = new MathNodeRoot();
                     }
                 }
             }
         }
     }
     return(value);
 }
예제 #4
0
        public IActionResult EvaluateExpression([FromBody, SwaggerRequestBody("The request that contains the expression and variables")] ExpressionRequest request)
        {
            if (!this.ModelState.IsValid)
            {
                this.logger.LogError("This model doesn't look right to me!");
                throw new ArgumentException("Your request body wasn't proper! ");
            }

            this.logger.LogInformation($"All looks good.  Let's start parsing: {request.Expression}.");
            MathExpressionBuilder builder          = new MathExpressionBuilder(request.Expression);
            IMathExpression       parsedExpression = builder.GenerateExpression();

            this.logger.LogDebug("Yup.  Looks like a legit expression.");
            foreach (var variable in request.VariableEntries)
            {
                builder.SetVariable(variable.Name, variable.Value.ToString());
                this.logger.LogDebug("Setting variable {0} with {1}", variable.Name, variable.Value);
            }

            ExpressionResponse response = new ExpressionResponse
            {
                AdjustedExpression = parsedExpression.ToString(),
                Expression         = request.Expression,
                VariableEntries    = request.VariableEntries,
                ValueGenerated     = parsedExpression.EvaluateExpression()
            };

            return(this.Ok(response));
        }
예제 #5
0
        private IMathExpression integateCos(IMathExpression coeff)
        {
            List <IExpressionType> list = new List <IExpressionType>();

            list.Add(_param);
            return(new Function(Types.FuncExpression, list, "sin"));
        }
예제 #6
0
        /// <summary>
        /// called when loading the group
        /// </summary>
        /// <param name="item"></param>
        public void ImportMathItem(MathExpItem item)
        {
            bLoading      = true;
            this.Name     = item.Name;
            this.Location = item.Location;
            this.Size     = item.Size;
            this.mathExp  = item.MathExpression;
            if (Site != null)
            {
                Site.Name = item.Name;
            }
            mathExp.GenerateInputVariables();

            mathExp.PrepareDrawInDiagram();
            if (OutputPorts != null)
            {
                for (int i = 0; i < OutputPorts.Length; i++)
                {
                    OutputPorts[i].Owner         = this;
                    OutputPorts[i].Label.Visible = false;
                    OutputPorts[i].RestoreLocation();
                }
            }
            createImage();
            bLoading = false;
        }
예제 #7
0
        private static ObjectAction GetSatelliteShootAction(
            Dictionary <string, DTDanmakuImage> spriteNameToImageDictionary,
            Dictionary <string, EnemyObjectTemplate> enemyObjectTemplates,
            GuidGenerator guidGenerator)
        {
            IMathExpression initialShootCooldownInMillis = MathExpression.RandomInteger(6000);
            IMathExpression shootCooldownInMillis        = MathExpression.Add(5000, MathExpression.RandomInteger(1000));

            string cooldownVariableName = guidGenerator.NextGuid();

            ObjectAction initialStartCooldownAction = ObjectAction.SetNumericVariable(cooldownVariableName, initialShootCooldownInMillis);
            ObjectAction startCooldownAction        = ObjectAction.SetNumericVariable(cooldownVariableName, shootCooldownInMillis);
            ObjectAction decrementCooldownAction    = ObjectAction.SetNumericVariable(cooldownVariableName, MathExpression.Subtract(MathExpression.Variable(cooldownVariableName), MathExpression.ElapsedMillisecondsPerIteration()));
            ObjectAction createBulletAction         = SpawnSatelliteBullet(
                spriteNameToImageDictionary: spriteNameToImageDictionary,
                enemyObjectTemplates: enemyObjectTemplates,
                guidGenerator: guidGenerator);

            var createBulletWhenCooldownFinishedAction = ObjectAction.Condition(
                condition: BooleanExpression.LessThanOrEqualTo(MathExpression.Variable(cooldownVariableName), MathExpression.Constant(0)),
                action: ObjectAction.Union(startCooldownAction, createBulletAction));

            return(ObjectAction.ConditionalNextAction(
                       currentAction: initialStartCooldownAction,
                       condition: BooleanExpression.True(),
                       nextAction: ObjectAction.Union(decrementCooldownAction, createBulletWhenCooldownFinishedAction)));
        }
        public override void CreateJavaScript(StringCollection methodToCompile, Dictionary <string, StringCollection> formsumissions, string nextActionInput, string indent)
        {
            IMathExpression mathExp = MathExp;

            if (mathExp != null)
            {
                string ce = mathExp.ReturnJavaScriptCodeExpression(methodToCompile);
                if (!string.IsNullOrEmpty(ce))
                {
                    string ceCondition = null;
                    if (Condition != null)
                    {
                        ceCondition = Condition.CreateJavaScriptCode(methodToCompile);
                    }
                    if (string.IsNullOrEmpty(ceCondition))
                    {
                        methodToCompile.Add(indent);
                        methodToCompile.Add(ce);
                    }
                    else
                    {
                        methodToCompile.Add(indent);
                        methodToCompile.Add("if(");
                        methodToCompile.Add(ceCondition);
                        methodToCompile.Add(") {\r\n");
                        methodToCompile.Add(indent);
                        methodToCompile.Add("\t");
                        methodToCompile.Add(ce);
                        methodToCompile.Add("\r\n");
                        methodToCompile.Add(indent);
                        methodToCompile.Add("}\r\n");
                    }
                }
            }
        }
        public override void CreatePhpScript(StringCollection methodToCompile)
        {
            IMathExpression mathExp = MathExp;

            if (mathExp != null)
            {
                string ce = mathExp.ReturnPhpScriptCodeExpression(methodToCompile);
                if (!string.IsNullOrEmpty(ce))
                {
                    string ceCondition = null;
                    if (Condition != null)
                    {
                        ceCondition = Condition.CreatePhpScriptCode(methodToCompile);
                    }
                    if (string.IsNullOrEmpty(ceCondition))
                    {
                        methodToCompile.Add(ce);
                    }
                    else
                    {
                        methodToCompile.Add("if(");
                        methodToCompile.Add(ceCondition);
                        methodToCompile.Add(")\r\n{\r\n");
                        methodToCompile.Add(ce);
                        methodToCompile.Add("\r\n}\r\n");
                    }
                }
            }
        }
예제 #10
0
        private List <IMathExpression> ReduceExponents(List <IMathExpression> expressions, params OperationType[] desiredOperationTypes)
        {
            List <IMathExpression> reducedExpressions = new List <IMathExpression>();
            bool requiresEvaluation = false;

            foreach (IMathExpression expression in expressions)
            {
                if (!requiresEvaluation)
                {
                    BinaryExpression binaryExpression = expression as BinaryExpression;
                    if (binaryExpression == null || desiredOperationTypes.All(x => x != binaryExpression.Operator))
                    {
                        reducedExpressions.Add(expression);
                        continue; // Skip the rest and move to the next iteration.
                    }

                    requiresEvaluation = true;
                    int             index          = reducedExpressions.Count - 1;
                    IMathExpression leftExpression = reducedExpressions[index];
                    reducedExpressions.RemoveAt(index);
                    binaryExpression.LeftExpression = leftExpression;
                    reducedExpressions.Add(binaryExpression);
                }
                else
                {
                    requiresEvaluation = false;
                    int index = reducedExpressions.Count - 1;
                    BinaryExpression rightExpression = reducedExpressions[index] as BinaryExpression;
                    rightExpression.RightExpression = expression;
                }
            }

            return(reducedExpressions);
        }
예제 #11
0
        public IExpressionType doVarDefenition(Equation eq)
        {
            Context    ctx  = Context.getInstance();
            Computator comp = new Computator();

            // если опредлено как отложенные, то пропускаем
            if (eq.isDelayed())
            {
                eq.setDelayed(false);
                return(eq);
            }

            // иначе вычисляем
            List <IExpressionType> lst     = new List <IExpressionType>();
            IMathExpression        operand = (IMathExpression)eq.getOperands()[1].doOperation(comp);

            lst.Add(eq.getOperands()[0]);
            lst.Add(operand);
            Equation ne = new Equation(lst, false);

            // change context
            ctx.changeVariable(((Variable)ne.getOperands()[0]).getValue(), ctx.getCurrPath(), ne);

            return(ne);
        }
        public override void ExportJavaScriptCode(ActionBranch currentAction, ActionBranch nextAction, StringCollection jsCode, StringCollection methodToCompile, JsMethodCompiler data)
        {
            IMathExpression mathExp = MathExp;

            if (mathExp != null)
            {
                string ce = mathExp.ReturnJavaScriptCodeExpression(methodToCompile);
                if (!string.IsNullOrEmpty(ce))
                {
                    string target = null;
                    string output = null;
                    if (nextAction != null)
                    {
                        if (nextAction.UseInput)
                        {
                            methodToCompile.Add("var ");
                            methodToCompile.Add(currentAction.OutputCodeName);
                            methodToCompile.Add("=");
                            methodToCompile.Add(ce);
                            methodToCompile.Add(";\r\n");
                            output = currentAction.OutputCodeName;
                        }
                    }
                    IVariable v = mathExp.OutputVariable;
                    if (v != null)
                    {
                        string ceCondition = null;
                        if (Condition != null)
                        {
                            ceCondition = Condition.CreateJavaScriptCode(methodToCompile);
                        }
                        target = v.ExportJavaScriptCode(methodToCompile);
                        string jsLine;
                        if (output != null)
                        {
                            jsLine = string.Format(System.Globalization.CultureInfo.InvariantCulture,
                                                   "{0}={1};\r\n", target, currentAction.OutputCodeName);
                        }
                        else
                        {
                            jsLine = string.Format(System.Globalization.CultureInfo.InvariantCulture,
                                                   "{0}={1};\r\n", target, ce);
                        }
                        if (string.IsNullOrEmpty(ceCondition))
                        {
                            methodToCompile.Add(jsLine);
                        }
                        else
                        {
                            methodToCompile.Add("if(");
                            methodToCompile.Add(ceCondition);
                            methodToCompile.Add(")\r\n{\r\n");
                            methodToCompile.Add(jsLine);
                            methodToCompile.Add("\r\n}\r\n");
                        }
                    }
                }
            }
        }
예제 #13
0
        public static ObjectAction SetFacingDirection(IMathExpression facingDirectionInMillidegrees)
        {
            ObjectAction action = new ObjectAction();

            action.ObjectActionType = Type.SetFacingDirection;
            action.SetFacingDirectionInMillidegrees = facingDirectionInMillidegrees;
            return(action);
        }
예제 #14
0
        public static ObjectAction DecreaseSpeed(IMathExpression speedInMillipixelsPerMillisecond)
        {
            ObjectAction action = new ObjectAction();

            action.ObjectActionType = Type.DecreaseSpeed;
            action.SpeedInMillipixelsPerMillisecond = speedInMillipixelsPerMillisecond;
            return(action);
        }
예제 #15
0
        private IMathExpression integateAbsoluteTerm(IMathExpression exp)
        {
            List <IExpressionType> list = new List <IExpressionType>();

            list.Add((Number)exp);
            list.Add(_param);
            return(new Function(Types.Multiplication, list, ""));
        }
예제 #16
0
 public bool compare(IMathExpression e)
 {
     if (getType() != e.getType())
     {
         return(false);
     }
     return(true);
 }
예제 #17
0
        public static BooleanExpression LessThanOrEqualTo(IMathExpression leftSide, IMathExpression rightSide)
        {
            BooleanExpression expression = new BooleanExpression();

            expression.BooleanExpressionType = Type.LessThanOrEqualTo;
            expression.MathLeftSide          = leftSide;
            expression.MathRightSide         = rightSide;
            return(expression);
        }
예제 #18
0
        public static ObjectAction DisplayBossHealthBar(IMathExpression healthBarMeterNumber, IMathExpression healthBarMilliPercentage)
        {
            ObjectAction action = new ObjectAction();

            action.ObjectActionType             = Type.DisplayBossHealthBar;
            action.BossHealthBarMeterNumber     = healthBarMeterNumber;
            action.BossHealthBarMilliPercentage = healthBarMilliPercentage;
            return(action);
        }
예제 #19
0
 public void LoadMathExpression(IMathExpression data)
 {
     mathExp        = data;
     this.Name      = data.Name;
     this.Site.Name = data.Name;
     mathExp.PrepareDrawInDiagram();
     //
     createImage();
 }
예제 #20
0
        public static ObjectAction SetPosition(IMathExpression xMillis, IMathExpression yMillis)
        {
            ObjectAction action = new ObjectAction();

            action.ObjectActionType   = Type.SetPosition;
            action.SetXMillisPosition = xMillis;
            action.SetYMillisPosition = yMillis;
            return(action);
        }
예제 #21
0
        public static ObjectAction StrafeMove(IMathExpression moveToXMillis, IMathExpression moveToYMillis)
        {
            ObjectAction action = new ObjectAction();

            action.ObjectActionType = Type.StrafeMove;
            action.MoveToXMillis    = moveToXMillis;
            action.MoveToYMillis    = moveToYMillis;
            return(action);
        }
예제 #22
0
        public static BooleanExpression GreaterThan(IMathExpression leftSide, IMathExpression rightSide)
        {
            BooleanExpression expression = new BooleanExpression();

            expression.BooleanExpressionType = Type.GreaterThan;
            expression.MathLeftSide          = leftSide;
            expression.MathRightSide         = rightSide;
            return(expression);
        }
예제 #23
0
        public static ObjectAction SetParentNumericVariable(string variableName, IMathExpression variableValue)
        {
            ObjectAction action = new ObjectAction();

            action.ObjectActionType        = Type.SetParentNumericVariable;
            action.SetVariableName         = variableName;
            action.SetNumericVariableValue = variableValue;
            return(action);
        }
예제 #24
0
        public static BooleanExpression NotEqual(IMathExpression leftSide, IMathExpression rightSide)
        {
            BooleanExpression expression = new BooleanExpression();

            expression.BooleanExpressionType = Type.NotEqual;
            expression.MathLeftSide          = leftSide;
            expression.MathRightSide         = rightSide;
            return(expression);
        }
예제 #25
0
        public static ObjectAction SpawnBarrageEnemy(
            IMathExpression xMillis,
            Dictionary <string, DTDanmakuImage> spriteNameToImageDictionary,
            Dictionary <string, EnemyObjectTemplate> enemyObjectTemplates,
            Dictionary <string, DTDanmakuSound> soundNameToSoundDictionary,
            GuidGenerator guidGenerator)
        {
            // Should be called first so it sets the "can shoot" variable that the shootBullet action will need
            ObjectAction moveAction = GetMoveAndSetCanShootVariableAction(
                xMillis: xMillis,
                guidGenerator: guidGenerator);

            ObjectAction shootAction = GetShootBulletAction(
                spriteNameToImageDictionary: spriteNameToImageDictionary,
                enemyObjectTemplates: enemyObjectTemplates,
                guidGenerator: guidGenerator);

            ObjectAction destroyAction = ObjectActionGenerator.DestroyWhenHpIsZeroAndMaybeDropPowerUp(
                chanceToDropPowerUpInMilliPercent: 15 * 1000,
                spriteNameToImageDictionary: spriteNameToImageDictionary,
                enemyObjectTemplates: enemyObjectTemplates,
                soundNameToSoundDictionary: soundNameToSoundDictionary,
                guidGenerator: guidGenerator);

            string spriteName = guidGenerator.NextGuid();

            spriteNameToImageDictionary.Add(spriteName, DTDanmakuImage.BarrageEnemyShip);

            List <ObjectBox> damageBoxes = new List <ObjectBox>();

            damageBoxes.Add(new ObjectBox(lowerXMillis: -46500, upperXMillis: 46500, lowerYMillis: 0, upperYMillis: 40000));
            damageBoxes.Add(new ObjectBox(lowerXMillis: -31500, upperXMillis: 31500, lowerYMillis: -35000, upperYMillis: 30000));

            List <ObjectBox> collisionBoxes = new List <ObjectBox>();

            collisionBoxes.Add(new ObjectBox(lowerXMillis: -10000, upperXMillis: 10000, lowerYMillis: -25000, upperYMillis: 25000));
            collisionBoxes.Add(new ObjectBox(lowerXMillis: -25000, upperXMillis: 25000, lowerYMillis: -10000, upperYMillis: 10000));

            EnemyObjectTemplate enemyObjectTemplate = EnemyObjectTemplate.Enemy(
                action: ObjectAction.Union(moveAction, shootAction, destroyAction),
                initialMilliHP: MathExpression.Add(MathExpression.Constant(38000), MathExpression.RandomInteger(MathExpression.Constant(10000))),
                damageBoxes: damageBoxes,
                collisionBoxes: collisionBoxes,
                spriteName: spriteName);

            string templateName = guidGenerator.NextGuid();

            enemyObjectTemplates.Add(templateName, enemyObjectTemplate);

            return(ObjectAction.SpawnChild(
                       childXMillis: MathExpression.Constant(-1000 * 1000),
                       childYMillis: MathExpression.Constant(-1000 * 1000),
                       childObjectTemplateName: templateName,
                       childInitialNumericVariables: null,
                       childInitialBooleanVariables: null));
        }
        public override void ExportCode(ActionBranch currentAction, ActionBranch nextAction, ILimnorCodeCompiler compiler, IMethodCompile methodToCompile, CodeMemberMethod method, CodeStatementCollection statements, bool debug)
        {
            IMathExpression mathExp = MathExp;

            if (mathExp != null)
            {
                CodeExpression ceCondition = null;
                if (Condition != null)
                {
                    ceCondition = Condition.ExportCode(methodToCompile);
                    if (ceCondition != null)
                    {
                        ceCondition = CompilerUtil.ConvertToBool(Condition.DataType, ceCondition);
                    }
                }
                CodeExpression ce = mathExp.ReturnCodeExpression(methodToCompile);
                if (ce != null)
                {
                    CodeExpression target = null;
                    CodeVariableDeclarationStatement output = null;
                    if (nextAction != null)
                    {
                        if (nextAction.UseInput)
                        {
                            output = new CodeVariableDeclarationStatement(currentAction.OutputType.TypeString, currentAction.OutputCodeName, ce);
                            statements.Add(output);
                        }
                    }
                    IVariable v = mathExp.OutputVariable;
                    if (v != null)
                    {
                        CodeStatement cs;
                        target = v.ExportCode(methodToCompile);
                        if (output != null)
                        {
                            cs = new CodeAssignStatement(target, new CodeVariableReferenceExpression(currentAction.OutputCodeName));
                        }
                        else
                        {
                            cs = new CodeAssignStatement(target, ce);
                        }
                        if (ceCondition == null)
                        {
                            statements.Add(cs);
                        }
                        else
                        {
                            CodeConditionStatement cd = new CodeConditionStatement();
                            cd.Condition = ceCondition;
                            cd.TrueStatements.Add(cs);
                            statements.Add(cd);
                        }
                    }
                }
            }
        }
예제 #27
0
 public static MathExpressionOffset GetOffset(
     IMathExpression millipixels,
     IMathExpression movementDirectionInMillidegrees)
 {
     return(new MathExpressionOffset
     {
         DeltaXInMillipixels = MathExpression.Divide(MathExpression.Multiply(millipixels, MathExpression.SineScaled(movementDirectionInMillidegrees)), MathExpression.Constant(1000L)),
         DeltaYInMillipixels = MathExpression.Divide(MathExpression.Multiply(millipixels, MathExpression.CosineScaled(movementDirectionInMillidegrees)), MathExpression.Constant(1000L))
     });
 }
예제 #28
0
        public static TExpression AsExpressionType <TExpression>(this IMathExpression <TExpression> e)
            where TExpression : class, IMathExpression <TExpression>
        {
            if (e is TExpression ret)
            {
                return(ret);
            }

            throw new Exception("Expression does not inherit from its generic type parameter TExpression.");
        }
예제 #29
0
        private static ObjectAction GetShootBulletAction(
            Dictionary <string, DTDanmakuImage> spriteNameToImageDictionary,
            Dictionary <string, EnemyObjectTemplate> enemyObjectTemplates,
            GuidGenerator guidGenerator)
        {
            IMathExpression initialShootCooldownInMillis = MathExpression.RandomInteger(2750);
            IMathExpression shootCooldownInMillis        = MathExpression.Add(1750, MathExpression.RandomInteger(1000));

            string cooldownVariableName    = guidGenerator.NextGuid();
            string childObjectTemplateName = guidGenerator.NextGuid();
            string enemyBulletSpriteName   = guidGenerator.NextGuid();

            IMathExpression facingAngleInMillidegrees = DTDanmakuMath.GetMovementDirectionInMillidegrees(
                currentX: MathExpression.XMillis(),
                currentY: MathExpression.YMillis(),
                desiredX: MathExpression.PlayerXMillis(),
                desiredY: MathExpression.Min(MathExpression.PlayerYMillis(), 300 * 1000));

            DTDanmakuMath.MathExpressionOffset deltaXAndY = DTDanmakuMath.GetOffset(
                millipixels: MathExpression.Constant(40000),
                movementDirectionInMillidegrees: facingAngleInMillidegrees);

            ObjectAction initialStartCooldownAction = ObjectAction.SetNumericVariable(cooldownVariableName, initialShootCooldownInMillis);
            ObjectAction startCooldownAction        = ObjectAction.SetNumericVariable(cooldownVariableName, shootCooldownInMillis);
            ObjectAction decrementCooldownAction    = ObjectAction.SetNumericVariable(cooldownVariableName, MathExpression.Subtract(MathExpression.Variable(cooldownVariableName), MathExpression.ElapsedMillisecondsPerIteration()));
            ObjectAction createBulletAction         = ObjectAction.SpawnChild(
                childXMillis: MathExpression.Add(MathExpression.XMillis(), deltaXAndY.DeltaXInMillipixels),
                childYMillis: MathExpression.Add(MathExpression.YMillis(), deltaXAndY.DeltaYInMillipixels),
                childObjectTemplateName: childObjectTemplateName,
                childInitialNumericVariables: null,
                childInitialBooleanVariables: null);

            List <ObjectBox> collisionBoxes = new List <ObjectBox>();

            collisionBoxes.Add(new ObjectBox(lowerXMillis: -4000, upperXMillis: 4000, lowerYMillis: -4000, upperYMillis: 4000));

            enemyObjectTemplates.Add(childObjectTemplateName,
                                     EnemyObjectTemplate.EnemyBullet(
                                         action: ObjectAction.Union(GetBulletMovementAction(guidGenerator: guidGenerator), GetBulletAnimationAction(guidGenerator: guidGenerator)),
                                         initialMilliHP: null,
                                         damageBoxes: null,
                                         collisionBoxes: collisionBoxes,
                                         spriteName: enemyBulletSpriteName));

            spriteNameToImageDictionary.Add(enemyBulletSpriteName, DTDanmakuImage.EliteSniperEnemyBullet);

            var createBulletWhenCooldownFinishedAction = ObjectAction.Condition(
                condition: BooleanExpression.LessThanOrEqualTo(MathExpression.Variable(cooldownVariableName), MathExpression.Constant(0)),
                action: ObjectAction.Union(startCooldownAction, createBulletAction));

            return(ObjectAction.ConditionalNextAction(
                       currentAction: initialStartCooldownAction,
                       condition: BooleanExpression.True(),
                       nextAction: ObjectAction.Union(decrementCooldownAction, createBulletWhenCooldownFinishedAction)));
        }
예제 #30
0
        public static ObjectAction SpawnEliteOrbiterEnemy(
            IMathExpression xMillis,
            Dictionary <string, DTDanmakuImage> spriteNameToImageDictionary,
            Dictionary <string, EnemyObjectTemplate> enemyObjectTemplates,
            Dictionary <string, DTDanmakuSound> soundNameToSoundDictionary,
            GuidGenerator guidGenerator)
        {
            ObjectAction moveAction = GetMoveAction(
                xMillis: xMillis);

            ObjectAction destroyAction = ObjectActionGenerator.DestroyWhenHpIsZeroAndMaybeDropPowerUp(
                chanceToDropPowerUpInMilliPercent: 15 * 1000,
                spriteNameToImageDictionary: spriteNameToImageDictionary,
                enemyObjectTemplates: enemyObjectTemplates,
                soundNameToSoundDictionary: soundNameToSoundDictionary,
                guidGenerator: guidGenerator);

            string spriteName = guidGenerator.NextGuid();

            spriteNameToImageDictionary.Add(spriteName, DTDanmakuImage.EliteOrbiterEnemyShip);

            List <ObjectBox> damageBoxes = new List <ObjectBox>();

            damageBoxes.Add(new ObjectBox(lowerXMillis: -68000, upperXMillis: 68000, lowerYMillis: -30000, upperYMillis: 50000));
            damageBoxes.Add(new ObjectBox(lowerXMillis: -46000, upperXMillis: 46000, lowerYMillis: -48000, upperYMillis: 68000));
            damageBoxes.Add(new ObjectBox(lowerXMillis: -26000, upperXMillis: 26000, lowerYMillis: -68000, upperYMillis: 74000));

            List <ObjectBox> collisionBoxes = new List <ObjectBox>();

            collisionBoxes.Add(new ObjectBox(lowerXMillis: -58000, upperXMillis: 58000, lowerYMillis: -35000, upperYMillis: 50000));

            ObjectAction spawnOrbiterSatellitesAction = GetSpawnOrbiterSatellitesAction(
                spriteNameToImageDictionary: spriteNameToImageDictionary,
                enemyObjectTemplates: enemyObjectTemplates,
                guidGenerator: guidGenerator);

            EnemyObjectTemplate enemyObjectTemplate = EnemyObjectTemplate.Enemy(
                action: ObjectAction.Union(moveAction, spawnOrbiterSatellitesAction, destroyAction),
                initialMilliHP: MathExpression.Add(MathExpression.Constant(45000), MathExpression.RandomInteger(MathExpression.Constant(15000))),
                damageBoxes: damageBoxes,
                collisionBoxes: collisionBoxes,
                spriteName: spriteName);

            string templateName = guidGenerator.NextGuid();

            enemyObjectTemplates.Add(templateName, enemyObjectTemplate);

            return(ObjectAction.SpawnChild(
                       childXMillis: MathExpression.Constant(-1000 * 1000),
                       childYMillis: MathExpression.Constant(-1000 * 1000),
                       childObjectTemplateName: templateName,
                       childInitialNumericVariables: null,
                       childInitialBooleanVariables: null));
        }
 public MathOperation(IMathExpression leftOperand, char operationChar, IMathExpression rightOperand)
 {
     this.leftOperand = leftOperand;
     this.operationChar = operationChar;
     this.rightOperand = rightOperand;
 }
예제 #32
0
 public ExpressionStackItem(IMathExpression expression)
     : this(expression, 0, false)
 {
 }
예제 #33
0
 public ExpressionStackItem(IMathExpression expression, double value, bool evaluated)
 {
     Expression = expression;
     Value = value;
     IsEvaluated = evaluated;
 }
예제 #34
0
 public OperatorStackItem(IMathExpression expression, OperatorPrecedence precedence)
 {
     Expression = expression;
     Precedence = precedence;
 }