public static void AddJavaScript(Script script)
		{
			script.AddRange(
				"function helloWord() {",
				"	alert('Hello World');",
				"}",
				"",
				"helloWorld();",
				"",
				Js.Function("helloWord",
					Js.Statement(Js.Call("alert", Js.Q("Hello World"))),
					"line 2",
					Js.Block(
						"This should be blocked",
						"This should be blocked",
						Sb.Line("This should be blocked"),
						"This should be blocked",
						Sb.Indent(
							Sb.Line("This should be indented"),
							"This should be indented"
						),
						"This should be blocked",
						"This should be blocked",
						Sb.Wrapper(
							"/*",
							Sb.Script(ScriptLayout.InlineBlock,
								"comment",
								"comment",
								"comment",
								"comment",
								"comment",
								"comment"
							),
							"*/"
						),
						Sb.Line("1", "2", "3", "4"),
						Sb.ScriptIf(true, "This is true", "should not show"),
						Sb.ScriptIf(false, "should not show", "This is false"),
						Sb.ScriptIf(true, "This is true"),
						Sb.ScriptIf(false, "should not show")

					)
				),
				Js.Function("withParams",
					Js.Parameters("aaa", "ddd", "fff"),
					Js.Statement(Js.Call("alert", Js.Q("Hello World"))),
					"line 2"
				),
				Js.Function("withBigParams",
					Js.Parameters(ScriptLayout.Block,
						"aaa",
						"ddd",
						"fff"
					),
					Js.Statement(Js.Call("alert", Js.Q("Hello World"))),
					"line 2"
				),
				Sb.Line(),
				Js.Statement(Js.Call("helloWorld")),
				Sb.Line(),
				Js.Statement("var testBool = ", true),
				Js.Statement("var testDate = ", Js.Q(new DateTime(2008, 12, 18, 14, 30, 45))),
				Js.Statement("var testSecureString = ", Js.QQ(Encryption.CreateSecureString("pass'wo\"rd"))),
				Js.Statement("var testQuotes = ", Js.Q("dfgdfg'gdfgdfg'gdfsg\"dsfg")),
				Js.Statement("var testList = ", Js.List("1", "2", "3")),
				Js.Statement("var testArray = ", Js.Array("1", "2", "3")),
				Js.Statement("var testNew = ", Js.New("className", "a", "b")),
				Js.Statement("var testXml = ", Js.Q(
						Xs.Element("name",
							"tony"
						)
					)
				),
				Js.Statement("var testObject = ",
					Js.Object(
						Js.Property("name1", "value1"),
						Js.Property("name2", "value2"),
						Js.Property("name3", "value3"),
						Js.Property("name4", "value4")
					)
				),
				Js.Statement("var testScript = ",
					Sb.Script(
						Js.Property("name1", "value1"),
						Js.Property("name2", "value2"),
						Js.Property("name3", "value3"),
						Js.Property("name4", "value4")
					)
				),
				Js.Statement("var testObject = ",
					Js.Object(ScriptLayout.InlineBlock,
						Js.Property("name1", "value1"),
						Js.Property("name2", "value2"),
						Js.Property("name3", "value3"),
						Js.Property("name4", "value4"),
						Js.Property("name5",
							Js.Function(
								Js.Statement("statement1"),
								Js.Statement("statement2"),
								Js.Statement("statement3"),
								Js.Statement("statement4")
							)
						),
						Js.Property("name6",
							Js.Function(
								Js.Parameters("a", "b"),
								Js.Statement("statement1"),
								Js.Statement("statement2"),
								Js.Statement(Js.Call("test", "a", "b")),
								Js.Statement("statement4")
							)
						),
						Js.Property("shortfunction",
							Js.Function(ScriptLayout.Inline,
								Js.Parameters("a", "b"),
								Js.Statement("statement1")
							)
						)
					)
				),
				"END"

			);
		}
示例#2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="currentKey"></param>
        /// <param name="framesOnKey"></param>
        /// <param name="rect"></param>
        /// <param name="script"></param>
        /// <param name="direction"></param>
        /// <param name="spriteFlipped"></param>
        /// <param name="reversed"></param>
        public virtual void GetFrameInfo(ref int currentKey, ref int framesOnKey, ref FloatRectangle rect, ref Script script, RotationComponent.CardinalDirections direction, out bool spriteFlipped,bool reversed = false)
        {
            framesOnKey++;
            if (framesOnKey > mFrameDurations[currentKey])
            {
                framesOnKey = 0;

                if (reversed)
                {
                    currentKey--;
                    if (currentKey < 0)
                    {
                        currentKey = mFrames[DirectionMap[RotationComponent.CardinalDirections.N]].Count - 1;
                    }
                }
                else
                {
                    currentKey++;
                    if (currentKey > mFrames[DirectionMap[RotationComponent.CardinalDirections.N]].Count - 1)
                    {
                        currentKey = 0;
                    }
                }
            }

            if (mFrames.Count == 1)
            {
                rect = mFrames[RotationComponent.CardinalDirections.NONE][currentKey];
            }
            else
            {
                rect = mFrames[mDirectionMap[direction]][currentKey];
            }

            if (direction > RotationComponent.CardinalDirections.S && mDirectionMap[RotationComponent.CardinalDirections.SW] != RotationComponent.CardinalDirections.SW)
            {
                spriteFlipped = true;
            }
            else
            {
                spriteFlipped = false;
            }

            script.AddRange(mWholeAnimationScript);

            if (mFrameScripts.ContainsKey(currentKey))
            {
                script.AddRange(mFrameScripts[currentKey]);
            }
        }