Example #1
0
        public override bool RunImpact(RoomScene room, GameObject actor, short gridX, short gridY, DirCardinal dir)
        {
            if (actor is Projectile)
            {
                if (actor is GloveProjectile)
                {
                    this.DestroyBrick(room, gridX, gridY);
                    return(false);
                }
                return(base.RunImpact(room, actor, gridX, gridY, dir));
            }

            // Nudge Brick Upward
            if (dir == DirCardinal.Up)
            {
                if (actor is Character)
                {
                    Character character = (Character)actor;

                    // Only Spikey Hats destroy Bricks
                    if (character.hat is SpikeyHat)
                    {
                        BlockTile.DamageAbove(room, gridX, gridY);
                        this.DestroyBrick(room, gridX, gridY);
                        return(base.RunImpact(room, actor, gridX, gridY, dir));
                    }
                }

                // Nudge. Damages enemies above.
                byte sub = room.tilemap.GetMainSubType(gridX, gridY);

                // Make the brick disappear (turn invisible) and replace it with a nudge particle. Then return the brick to visible after completion.
                if (sub < 10)
                {
                    SimpleEmitter.GravityParticle(room, this.Texture[sub], gridX * (byte)TilemapEnum.TileWidth, gridY * (byte)TilemapEnum.TileHeight);
                    room.tilemap.SetTileSubType(gridX, gridY, (byte)(sub + 10));
                    room.queueEvents.AddEvent(Systems.timer.Frame + 9, this.tileId, (short)gridX, (short)gridY);
                }

                BlockTile.DamageAbove(room, gridX, gridY);
                room.PlaySound(Systems.sounds.thudHit, 0.7f, gridX * (byte)TilemapEnum.TileWidth, gridY * (byte)TilemapEnum.TileHeight);
            }

            // Slam-Down Action can break bricks.
            if (actor is Character && ((Character)actor).status.action is SlamAction)
            {
                // Bricks will cause some hindrance, slowing down vertical velocity.
                actor.physics.velocity.Y *= FInt.Create(0.6);
                this.DestroyBrick(room, gridX, gridY);

                return(true);
            }

            return(base.RunImpact(room, actor, gridX, gridY, dir));
        }
Example #2
0
        /// <summary>
        /// This program hosts a Web API that has a controller decorated with .a PerfIt filter and then sends an HTTP request to instrument
        /// There is a Zipkin ServerTraceHandler to pick up headers from request and inject headers to the response.
        /// Zipkin emitter has a console dispatcher which outputs spans to the console.
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            string baseAddress   = "http://localhost:34543/";
            var    configuration = new HttpSelfHostConfiguration(baseAddress);

            configuration.Routes.Add("def", new HttpRoute("api/{controller}"));
            configuration.MessageHandlers.Add(new ServerTraceHandler("server-test")); // adding Zipkin handler to inject headers
            var server = new HttpSelfHostServer(configuration);

            server.OpenAsync().Wait();

            // zipkin emitter
            var emitter = new SimpleEmitter();

            emitter.RegisterDispatcher(new ConsoleDispatcher());

            // hook to the filter and add a tracer
            PerfItRuntime.InstrumentorCreated += (sender, e) =>
            {
                if (e.Info.CategoryName == "server-test")
                {
                    e.Instrumentor.Tracers.Add("Console", new ServerTracer(emitter));
                }
            };

            // handler
            var handler = new PerfitClientDelegatingHandler("client-test", new ClientTracer(emitter))
            {
                InnerHandler    = new ClientTraceHandler("client-test", new HttpClientHandler()),
                PublishCounters = false
            };

            var client = new HttpClient(handler);
            var result = client.GetAsync(baseAddress + "api/test").Result;

            Console.WriteLine(result.Content.ReadAsStringAsync().Result);

            // notice Zipkin headers in the request as a result of ClientTraceHandler
            Console.BackgroundColor = ConsoleColor.Yellow;
            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.WriteLine(result.RequestMessage.Headers.ToString());
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine(result.Headers.ToString());
            Console.ResetColor();
            result.EnsureSuccessStatusCode();

            Console.Read();
        }
Example #3
0
        /// <summary>
        /// This is sample whereby a .NET Core MVC API is hosted with a controller that is decorated with PerfIt filter.
        /// A Zipkin emitter is created with a Console dispatcher so that all Zipkin traces are sent to Console.
        /// A Zipkin tracer gets added by hooking into PerfItRuntime.InstrumentorCreated.
        /// On the other hand, we have HttpClient which gets a PerfIt handler with a ClientTraceHandler which injects Zipkin headers.
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            // server
            var h = BuildWebHost(args);

            h.Start();

            // zipkin emitter
            var emitter = new SimpleEmitter();

            emitter.RegisterDispatcher(new ConsoleDispatcher());

            // hook to the filter and add a tracer
            PerfItRuntime.InstrumentorCreated += (sender, e) =>
            {
                if (e.Info.CategoryName == "server-test")
                {
                    e.Instrumentor.Tracers.Add("Console", new ServerTracer(emitter));
                }
            };

            // handler
            var handler = new PerfitClientDelegatingHandler("client-test", new ClientTracer(emitter))
            {
                InnerHandler = new ClientTraceHandler("client-test", new HttpClientHandler())
            };

            var client = new HttpClient(handler);
            var result = client.GetAsync(baseAddress + "api/test").Result;

            Console.WriteLine(result.Content.ReadAsStringAsync().Result);

            // notice Zipkin headers in the request as a result of ClientTraceHandler
            Console.BackgroundColor = ConsoleColor.Yellow;
            Console.ForegroundColor = ConsoleColor.DarkMagenta;
            Console.WriteLine(result.RequestMessage.Headers.ToString());
            Console.ResetColor();
            result.EnsureSuccessStatusCode();

            Console.Read();

            h.StopAsync().Wait();
        }