public void CommandCollisionTest() { Command c = new Command(new Point(35, 75), PsychicNinja.Data.Util.CommandType.LedgeClimb); Platform p = new Platform(new Rectangle(35, 75, 40, 80)); c.ConnectToPlatform(p); Assert.Equal(true, c.CollidesWithConnectedPlatforms(new Platform(new Rectangle(70, 65, 40, 80))) != null); }
/// <summary> /// Makes the ninja slide on a wall associated with the command passed in. /// Returns true if wall slide was successful, false otherwise /// </summary> public bool Action_WallSlide(Command c) { if (actionState == NinjaActionState.WallSliding) return false; Platform p = c.CollidesWithConnectedPlatforms(this); //Checks to see if the Ninja collides with Command C's list of tagged platforms if (p != null) { if (velocity.X > 0) wallSlideFacingLeft = false; else wallSlideFacingLeft = true; actionState = NinjaActionState.WallSliding; WallSlidePlatform = p; //create rectangle for emission based on ninja's direction int xvar; if (!wallSlideFacingLeft) xvar = drawRect.Right - 10; else xvar = drawRect.Left; Rectangle b = new Rectangle(xvar, drawRect.Bottom, 10, 10); //create the emitter wallSlideSparkEmitter = new Emitter(b, //bounding box of the emitter //new Vector2((float)(facingLeft ? Math.Tan(Math.PI / 18) * NinjaWallSlideSpeed : Math.Tan(Math.PI / 18) * -NinjaWallSlideSpeed), new Vector2(wallSlideFacingLeft ? 0.6215f : -0.6215f, (float)-NinjaWallSlideSpeed), //starting velocity vector (roughly 100 or 80 degrees depending which way ninja is facing) Math.PI / 18, //maximum angle (in radians) a particle's vector may deviate from the specified one 0.3, 0.01, //intensity (particles are generated at a frequency of 30 frames / thisvalue) 300, //maximum number of particles 30, //particle lifespan, in frames SparkTextures, //Linked list of textures this emitter can use when generating particles new Vector2(0, 1.7f), //A delta vector acting on particles; in this case, it's working as a lighter form of gravity new Vector2(0, 8f), //a delta vector cutoff; in this case, it's the max velocity 0.2); //the fraction of particles generated by this emitter that will employ the above delta vectors to modify their velocity wallSlideSparkEmitter.particlesFade = true; return true; } return false; }