public bool overlappedCrate(object sender, FlxSpriteCollisionEvent e) { FlxG.score++; if (e.Object2.GetType().ToString().EndsWith("Fruit")) { ((Fruit)(e.Object2))._body.SetTransform(new Vector2((int)FlxU.random(0, 0), (int)FlxU.random(0, 0)), 0.0f); //e.Object2.reset(-110, -110); e.Object2.debugName = "repack"; ((Fruit)(e.Object2))._body.Enabled = false; } if (e.Object2.GetType().ToString().EndsWith("Crate")) { foreach (var item in crates.members) { if (item.GetType().ToString().EndsWith("Fruit")) //&& item.debugName == "repack" { //e.Object2.reset(e.Object2.x, e.Object2.y); ((Fruit)(item))._body.SetTransform(new Vector2(e.Object2.x, e.Object2.y), 0.0f); item.debugName = ""; ((Fruit)(item))._body.Enabled = true; } } e.Object2.reset((int)FlxU.random(0, FlxG.width), (int)FlxU.random(0, FlxG.height - 100)); } return(true); }
protected bool overlapped(object Sender, FlxSpriteCollisionEvent e) { //you can fire functions on each object. //((FlxObject)(e.Object1)).overlapped(e.Object2); //((FlxObject)(e.Object2)).overlapped(e.Object1); //if (e.Object1.dead == false && e.Object2.dead == false) //{ // if (Math.Abs(e.Object1.velocity.Y) > Math.Abs(e.Object2.velocity.Y)) // { // e.Object2.kill(); // } // else if (Math.Abs(e.Object2.velocity.Y) < Math.Abs(e.Object1.velocity.Y)) // { // e.Object1.kill(); // } //} if (FlxU.random() < 0.5f) { e.Object2.kill(); } else { e.Object1.kill(); } return(true); }
protected bool getPellet(object Sender, FlxSpriteCollisionEvent e) { if (shadow.debugName == "onground") { e.Object1.kill(); } return(true); }
protected bool trampolinesOverlap(object Sender, FlxSpriteCollisionEvent e) { if (e.Object1.dead == false) { bubbleParticle.at(e.Object1); bubbleParticle.start(true, 0, 30); } e.Object1.overlapped(e.Object2); e.Object2.overlapped(e.Object1); return(true); }
protected bool scaleUp(object Sender, FlxSpriteCollisionEvent e) { //((FlxObject)(e.Object1)).overlapped(e.Object2); //((FlxObject)(e.Object2)).overlapped(e.Object1); if (((FlxSprite)(e.Object1)).color == Color.Aqua) { ((FlxSprite)(e.Object1)).scale = 1.2f; } //((FlxSprite)(e.Object2)).scale += 2; return(true); }
public bool overlapped(object sender, FlxSpriteCollisionEvent e) { //if (e.Object2 == doors.members[1]) //{ // e.Object1.x = doors.members[0].x+70; // e.Object1.y = doors.members[0].y + 80; //} if (e.Object2 == doors.members[0]) { e.Object1.x = doors.members[1].x; e.Object1.y = doors.members[1].y + 80; } return(true); }
protected bool ballInHole(object Sender, FlxSpriteCollisionEvent e) { Console.WriteLine("Ball speed at time of sinking x {0} y {1} -- ball x/y {2} {3} hole x/y {4} {5} ", ball.velocity.X, ball.velocity.Y, ball.x, ball.y, hole.x, hole.y); if (ball.rise == true) { return(false); } else if (ball.velocity.Y < -35) { // Voice -- "A little too much juice on that one. Next time try a softer approach. // too fast to sink playSound("alittletoomuchjuice"); FlxG.play("putt/sfx/ballinhole"); if (ball.x > hole.x - 1) { ball.velocity.X = 56; } else if (ball.x < hole.x - 3) { ball.velocity.X = -56; } } else { //went in the hole. if (ball.visible) { FlxG.play("putt/sfx/GolfBallInHole"); Globals.ballInHole = true; if (FlxG.debug) { FlxU.saveToDevice(string.Format("Hole Aim (x) Power Force: ,{0},{1},{2},{3},{4}", Globals.hole, aim.x, aim.health, selectedClub, selectedForce), "hole" + Globals.hole + ".txt"); } } state = GameState.BallEnded; ball.visible = false; resetSelections(); } return(true); }
protected bool genericOverlap(object Sender, FlxSpriteCollisionEvent e) { e.Object1.overlapped(e.Object2); e.Object2.overlapped(e.Object1); return(true); }
protected bool exitOverlap(object Sender, FlxSpriteCollisionEvent e) { ((Exit)(e.Object2)).play("open", true); return(true); }
protected bool overlapped(object Sender, FlxSpriteCollisionEvent e) { velValue -= 40; return(true); }