public void Collide() { // tell mario what he collide with by check object's type and tell the object mario collide with it. if (Character1.Type == Sprint5Main.CharacterType.Mario) { MarioCharacter MarioCharacters = (MarioCharacter)Character1; if (Character2.Type == Sprint5Main.CharacterType.Block) { Character2.MarioCollide((Time == yTime) && (relativeVelocity.Y < 0)); } else if (Character2 is PlantEnemyCharacter || Character2 is CloudEnemyCharacter) { Character2.MarioCollide(false); } else { Character2.MarioCollide((Time == yTime) && (relativeVelocity.Y > 0)); } if (!MarioCharacters.IsDied()) { MarioCharacters.OnPipe = false; MarioCharacters.CollideWith(Character2, Time == yTime, relativeVelocity.Y > 0); } } else if (Character1.Type == Sprint5Main.CharacterType.Fireball) { Character1.Parameters.IsHidden = true; // fireball will hide no matter what it hit //only mario has response when collide with fireball if (Character2.Type == Sprint5Main.CharacterType.Enemy) { Character2.MarioCollide(true); } } else //items and enemies { if (Character1.Parameters.Velocity.X * relativeVelocity.X >= 0) { Character1.BlockCollide((Time == yTime) && (relativeVelocity.Y > 0)); } if (Character1 is BossEnemyCharacter && Character2 is BlockCharacter) { BlockCharacter block = (BlockCharacter)Character2; block.BossEnemyCollide(); } } }