public override bool collide(cCritter pcritter) { bool playerhigherthancritter = Position.Y - Radius > pcritter.Position.Y; /* If you are "higher" than the pcritter, as in jumping on it, you get a point * and the critter dies. If you are lower than it, you lose health and the * critter also dies. To be higher, let's say your low point has to higher * than the critter's center. We compute playerhigherthancritter before the collide, * as collide can change the positions. */ _baseAccessControl = 1; bool collided = base.collide(pcritter); _baseAccessControl = 0; if (!collided) { return(false); } /* If you're here, you collided. We'll treat all the guys the same -- the collision * with a Treasure is different, but we let the Treasure contol that collision. */ if (playerhigherthancritter) { Framework.snd.play(Sound.Goopy); addScore(10); } else { damage(1); Framework.snd.play(Sound.Crunch); } pcritter.die(); return(true); }
public override bool collide(cCritter pcritter) { bool playerhigherthancritter = Position.Y - Radius > pcritter.Position.Y; /* If you are "higher" than the pcritter, as in jumping on it, you get a point * and the critter dies. If you are lower than it, you lose health and the * critter also dies. To be higher, let's say your low point has to higher * than the critter's center. We compute playerhigherthancritter before the collide, * as collide can change the positions. */ _baseAccessControl = 1; bool collided = base.collide(pcritter); _baseAccessControl = 0; if (!collided) { return(false); } /* If you're here, you collided. We'll treat all the guys the same -- the collision * with a Treasure is different, but we let the Treasure contol that collision. */ if (playerhigherthancritter) { Framework.snd.play(Sound.Goopy); addScore(10); } else if (pcritter.IsKindOf("cCritter3DBoss")) { damage(2); } else if (pcritter.IsKindOf("cCritterWank")) { if (gohanSpawned) { return(false); } else { //spawn little goku cCritterGohan gohan = new cCritterGohan(owner); gohan.moveTo(new cVector3(20.0f, 0.0f, -22.0f)); gohanSpawned = true; MessageBox.Show("Your son, Gohan, has been born."); return(true); } } else if (pcritter.IsKindOf("cCritterGohan")) { //play gohan sound return(true); } else if (pcritter.IsKindOf("cCritterDragonball")) { int rand = (int)Framework.randomOb.random(3); switch (rand) { case 0: Framework.snd.play(Sound.Samurai); break; case 1: Framework.snd.play(Sound.Shout); break; case 2: Framework.snd.play(Sound.WorkHard); break; } addScore(100); addHealth(5); numDragBallsCollected++; pcritter.die(); return(true); } else { damage(1); Framework.snd.play(Sound.Crunch); pcritter.die(); } return(true); }