当前位置: 首页>>代码示例>>C#>>正文


C# Emitter类代码示例

本文整理汇总了C#中Emitter的典型用法代码示例。如果您正苦于以下问题:C# Emitter类的具体用法?C# Emitter怎么用?C# Emitter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Emitter类属于命名空间,在下文中一共展示了Emitter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RenderEmitter

        /// <summary>
        /// Renders the specified Emitter, applying the specified transformation offset.
        /// </summary>
        public override void RenderEmitter(Emitter emitter, ref Matrix transform)
        {
            Guard.ArgumentNull("emitter", emitter);
            Guard.IsTrue(this.Batch == null, "SpriteBatchRenderer is not ready! Did you forget to LoadContent?");

            if (emitter.ParticleTexture != null && emitter.ActiveParticlesCount > 0)
            {
                // Bail if the emitter blend mode is "None"...
                if (emitter.BlendMode == EmitterBlendMode.None)
                    return;

                // Calculate the source rectangle and origin offset of the Particle texture...
                Rectangle source = new Rectangle(0, 0, emitter.ParticleTexture.Width, emitter.ParticleTexture.Height);
                Vector2 origin = new Vector2(source.Width / 2f, source.Height / 2f);

                BlendState blendState = this.GetBlendState(emitter.BlendMode);

                this.Batch.Begin(SpriteSortMode.Deferred, blendState);

                for (int i = 0; i < emitter.ActiveParticlesCount; i++)
                {
                    Particle particle = emitter.Particles[i];

                    float scale = particle.Scale / emitter.ParticleTexture.Width;

                    this.Batch.Draw(emitter.ParticleTexture, particle.Position, source, new Color(particle.Colour), particle.Rotation, origin, scale, SpriteEffects.None, 0f);
                }

                this.Batch.End();
            }
        }
开发者ID:Andrea,项目名称:MercuryParticleEngine,代码行数:34,代码来源:SpriteBatchRenderer.cs

示例2: Compile

        public override void Compile(Emitter.Emitter emitter)
        {
            var numTypes = new[] { "int", "float" };

              var fromType = From.GetExpressionType(emitter);
              var toType = To.GetExpressionType(emitter);
              var stepType = Step.GetExpressionType(emitter);

              // validate parameters
              if (!fromType.IsAnyOf(numTypes) || !toType.IsAnyOf(numTypes) || !stepType.IsAnyOf(numTypes))
            Error(Resources.errIntFloatExpected);

              // from, to, step
              From.Compile(emitter);
              if (fromType != "float")
            emitter.EmitConvertToFloat();

              To.Compile(emitter);
              if (toType != "float")
            emitter.EmitConvertToFloat();

              Step.Compile(emitter);
              if (stepType != "float")
            emitter.EmitConvertToFloat();

              // invoke method
              var method = typeof(MirelleStdlib.ArrayHelper).GetMethod("CreateRangedArray", new[] { typeof(double), typeof(double), typeof(double) });
              emitter.EmitCall(emitter.AssemblyImport(method));
        }
开发者ID:menozz,项目名称:mirelle,代码行数:29,代码来源:FloatRangeNode.cs

示例3: Compile

        public override void Compile(Emitter.Emitter emitter)
        {
            try
              {
            Resolve(emitter);

            if (!emitter.TypeIsParent(IdentifierType, Expression.GetExpressionType(emitter)))
              Error(String.Format(Resources.errAssignTypeMismatch, Expression.GetExpressionType(emitter), IdentifierType));
              }
              catch(CompilerException ex)
              {
            ex.AffixToLexem(Lexem);
            throw;
              }

              switch (Kind)
              {

            case IdentifierKind.StaticField:  Expression.Compile(emitter);
                                          emitter.EmitSaveField(emitter.FindField(OwnerType, Name)); break;

            case IdentifierKind.Field:        if (ExpressionPrefix != null)
                                            ExpressionPrefix.Compile(emitter);
                                          else
                                            emitter.EmitLoadThis();
                                          Expression.Compile(emitter);
                                          emitter.EmitSaveField(emitter.FindField(OwnerType, Name)); break;

            case IdentifierKind.Variable:     Expression.Compile(emitter);
                                          emitter.EmitSaveVariable(emitter.CurrentMethod.Scope.Find(Name)); break;

            case IdentifierKind.Parameter:    Expression.Compile(emitter);
                                          emitter.EmitSaveParameter(emitter.CurrentMethod.Parameters[Name].Id); break;
              }
        }
开发者ID:menozz,项目名称:mirelle,代码行数:35,代码来源:IdentifierSetNode.cs

示例4: Compile

        public override void Compile(Emitter.Emitter emitter)
        {
            var leftType = Left.GetExpressionType(emitter);
              var rightType = Right.GetExpressionType(emitter);

              // an array of values
              if (rightType == leftType + "[]")
              {
            Right.Compile(emitter);
            Left.Compile(emitter);
            if (leftType.IsAnyOf("int", "bool", "float", "complex"))
              emitter.EmitBox(emitter.ResolveType(leftType));

            var method = typeof(MirelleStdlib.ArrayHelper).GetMethod("Has", new[] { typeof(object), typeof(object) });
            emitter.EmitCall(emitter.AssemblyImport(method));
              }

              // an object has a "has" method that accepts the lefthand expression
              else
              {
            try
            {
              Expr.IdentifierInvoke("has", Right, Left).Compile(emitter);
              return;
            }
            catch { }

            Error(String.Format(Resources.errOperatorTypesMismatch, "in", leftType, rightType));
              }
        }
开发者ID:menozz,项目名称:mirelle,代码行数:30,代码来源:InNode.cs

示例5: Compile

        public override void Compile(Emitter.Emitter emitter)
        {
            // declare variables and methods
              var tmpVar = emitter.CurrentMethod.Scope.Introduce("dict", emitter.ResolveType("dict"));
              var ctor = emitter.AssemblyImport(typeof(MirelleStdlib.Dict).GetConstructor(new Type[] { }));
              var set = emitter.FindMethod("dict", "set", "string", "string");

              // var tmp = new dict
              emitter.EmitNewObj(ctor);
              emitter.EmitSaveVariable(tmpVar);

              // tmp[key] = value
              foreach(var curr in Data)
              {
            var keyType = curr.Item1.GetExpressionType(emitter);
            var valueType = curr.Item2.GetExpressionType(emitter);

            if (keyType != "string")
              Error(Resources.errDictItemTypeMismatch, curr.Item1.Lexem);

            if (valueType != "string")
              Error(Resources.errDictItemTypeMismatch, curr.Item2.Lexem);

            emitter.EmitLoadVariable(tmpVar);
            curr.Item1.Compile(emitter);
            curr.Item2.Compile(emitter);
            emitter.EmitCall(set);
              }

              emitter.EmitLoadVariable(tmpVar);
        }
开发者ID:menozz,项目名称:mirelle,代码行数:31,代码来源:DictNode.cs

示例6: Compile

        public override void Compile(Emitter.Emitter emitter)
        {
            // ensure this is a matrix
              if (ExpressionPrefix.GetExpressionType(emitter) != "matrix")
            Error(Resources.errIndexingNotAMatrix);

              // ensure indexes are integers
              if (Index1.GetExpressionType(emitter) != "int")
            Error(Resources.errIntIndexExpected, Index1.Lexem);

              if (Index2.GetExpressionType(emitter) != "int")
            Error(Resources.errIntIndexExpected, Index2.Lexem);

              // ensure assigned value is either int or float
              var exprType = Expression.GetExpressionType(emitter);
              if (!exprType.IsAnyOf("int", "float"))
            Error(Resources.errMatrixItemTypeMismatch);

              ExpressionPrefix.Compile(emitter);

              Index1.Compile(emitter);
              Index2.Compile(emitter);

              Expression.Compile(emitter);
              if(exprType != "float")
            emitter.EmitConvertToFloat();

              var method = emitter.AssemblyImport(typeof(MN.DenseMatrix).GetMethod("At", new[] { typeof(int), typeof(int), typeof(double) }));
              emitter.EmitCall(method);
        }
开发者ID:menozz,项目名称:mirelle,代码行数:30,代码来源:MatrixSetNode.cs

示例7: Compile

        public override void Compile(Emitter.Emitter emitter)
        {
            var leftType = Left.GetExpressionType(emitter);
              var rightType = Right.GetExpressionType(emitter);

              var type = GetExpressionType(emitter);

              // subtract matrices
              if(type == "matrix")
              {
            Left.Compile(emitter);
            Right.Compile(emitter);

            var matrixType = typeof(MN.Matrix<double>);
            var method = emitter.AssemblyImport(matrixType.GetMethod("Subtract", new [] { matrixType } ));
            emitter.EmitCall(method);
              }

              // subtract dicts
              else if (type == "dict")
              {
            Left.Compile(emitter);
            Right.Compile(emitter);

            var dictType = typeof(Dict);
            var method = emitter.AssemblyImport(dictType.GetMethod("Subtract", new[] { dictType }));
            emitter.EmitCall(method);
              }

              // subtract complex numbers
              else if (type == "complex")
              {
            Left.Compile(emitter);
            if (leftType != "complex")
            {
              emitter.EmitUpcastBasicType(leftType, "float");
              emitter.EmitLoadFloat(0);
              emitter.EmitNewObj(emitter.FindMethod("complex", ".ctor", "float", "float"));
            }

            Right.Compile(emitter);
            if (rightType != "complex")
            {
              emitter.EmitUpcastBasicType(rightType, "float");
              emitter.EmitLoadFloat(0);
              emitter.EmitNewObj(emitter.FindMethod("complex", ".ctor", "float", "float"));
            }

            emitter.EmitCall(emitter.AssemblyImport(typeof(SN.Complex).GetMethod("op_Subtraction", new[] { typeof(SN.Complex), typeof(SN.Complex) })));
              }
              // add floating point numbers or integers
              else if (type.IsAnyOf("int", "float"))
              {
            Left.Compile(emitter);
            emitter.EmitUpcastBasicType(leftType, type);
            Right.Compile(emitter);
            emitter.EmitUpcastBasicType(rightType, type);
            emitter.EmitSub();
              }
        }
开发者ID:menozz,项目名称:mirelle,代码行数:60,代码来源:OperatorSubtractNode.cs

示例8: Compile

        public override void Compile(Emitter.Emitter emitter)
        {
            // check for variable definitions being the only expressions in a block
              if (Statements.Count == 1 && (Statements[0] is VarDeclarationNode || Statements[0] is VarSplatNode))
            Error(Resources.errVariableDefinitionOnly, Statements[0].Lexem);

              emitter.CurrentMethod.Scope.EnterSubScope();

              foreach (var curr in Statements)
              {
            curr.Compile(emitter);

            // eliminate dead code
            if (curr is ReturnNode || (curr is IfNode && (curr as IfNode).AllPathsReturn))
            {
              AllPathsReturn = true;
              break;
            }

            // remove clutter from stack
            if (!curr.GetExpressionType(emitter).IsAnyOf("", "void"))
              emitter.EmitPop();
              }

              emitter.CurrentMethod.Scope.LeaveSubScope();
        }
开发者ID:menozz,项目名称:mirelle,代码行数:26,代码来源:CodeBlockNode.cs

示例9: TestHostedInstance

 public void TestHostedInstance()
 {
     var r = GetRealSink();
     var emitter = new Emitter(r);
     var evt = CreateIdSrvEvent(DateTimeOffset.UtcNow);
     emitter.Emit(evt);
 }
开发者ID:Xamarui,项目名称:IdentityServer3.Contrib.ElasticSearchEventService,代码行数:7,代码来源:EmitterTests.cs

示例10: CreateTestMethod

		static MethodDefinition CreateTestMethod(Emitter emitter)
		{
			TypeReference type = new TypeReference("", "Test", null, null);
			MethodDefinition test = new MethodDefinition("Test", MethodAttributes.Public, type);
			emitter(test.Body.GetILProcessor());
			return test;
		}
开发者ID:Galigator,项目名称:db4o,代码行数:7,代码来源:ILPatternTestCase.cs

示例11: Compile

        public override void Compile(Emitter.Emitter emitter)
        {
            var method = emitter.AssemblyImport(typeof(MirelleStdlib.Events.Simulation).GetMethod("Process", new[] { typeof(int), typeof(int) }));

              // processor count
              if(Processors == null)
            emitter.EmitLoadInt(1);
              else
              {
            if(Processors.GetExpressionType(emitter) != "int")
              Error(Resources.errSimulateProcessorsInt);

            Processors.Compile(emitter);
              }

              // queue length
              if(MaxQueue == null)
            emitter.EmitLoadInt(0);
              else
              {
            if(MaxQueue.GetExpressionType(emitter) != "int")
              Error(Resources.errSimulateQueueInt);

            MaxQueue.Compile(emitter);
              }

              emitter.EmitCall(method);
        }
开发者ID:menozz,项目名称:mirelle,代码行数:28,代码来源:SimulateAnyNode.cs

示例12: Compile

        public override void Compile(Emitter.Emitter emitter)
        {
            try
              {
            Resolve(emitter);
              }
              catch (CompilerException ex)
              {
            ex.AffixToLexem(Lexem);
            throw;
              }

              var method = emitter.FindMethod(OwnerType, Name, GetSignature(emitter));

              // load 'this'
              if (ExpressionPrefix != null)
            ExpressionPrefix.Compile(emitter);
              else if (!Static)
            emitter.EmitLoadThis();

              // load parameters
              for (int idx = 0; idx < Parameters.Count; idx++)
              {
            Parameters[idx].Compile(emitter);
            emitter.EmitUpcastBasicType(Parameters[idx].GetExpressionType(emitter), method.Parameters[idx].Type.Signature);
              }

              // invoke
              emitter.EmitCall(method);
        }
开发者ID:menozz,项目名称:mirelle,代码行数:30,代码来源:IdentifierInvokeNode.cs

示例13: ListenersWithoutHandlers

 public void ListenersWithoutHandlers()
 {
     LogManager.SetupLogManager();
     var emitter = new Emitter();
     var expected = new IListener[] {};
     Assert.Equal(expected, emitter.Listeners("foo").ToArray());
 }
开发者ID:Quobject,项目名称:EngineIoClientDotNet,代码行数:7,代码来源:EmitterTests.cs

示例14: Compile

        public override void Compile(Emitter.Emitter emitter)
        {
            if (emitter.CurrentLoop == null)
            Error(Resources.errBreakRedoOutsideLoop);

              emitter.EmitBranch(emitter.CurrentLoop.BodyStart);
        }
开发者ID:menozz,项目名称:mirelle,代码行数:7,代码来源:RedoNode.cs

示例15: Compile

        public override void Compile(Emitter.Emitter emitter)
        {
            foreach (var curr in Types)
            Types[curr].Compile(emitter);

              GlobalMethod.Compile(emitter);
        }
开发者ID:menozz,项目名称:mirelle,代码行数:7,代码来源:RootNode.cs


注:本文中的Emitter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。