/// <summary> /// Checks if there is any current collision in game /// </summary> /// <returns>Enum of type CollisionType</returns> public CollisionType CollisionStatus(FallingObject fallingObject) { if (fallingObject.Type == FallingObjectType.Good && fallingObject.Visible == true) { if (fallingObject.IsTouchingToCar()) { return(CollisionType.GoodTouchesCar); } else if (fallingObject.IsTouchingToGround()) { return(CollisionType.GoodTouchesGround); } } else if (fallingObject.Type == FallingObjectType.Bad && fallingObject.Visible == true) { if (fallingObject.IsTouchingToCar()) { return(CollisionType.BadTouchesCar); } else if (fallingObject.IsTouchingToGround()) { return(CollisionType.BadTouchesGround); } } else if (fallingObject.Type == FallingObjectType.Shield && fallingObject.Visible == true) { if (fallingObject.IsTouchingToCar()) { return(CollisionType.ShieldTouchesCar); } else if (fallingObject.IsTouchingToGround()) { return(CollisionType.ShieldTouchesGround); } } return(CollisionType.None); }
// Spawn falling objects at left big lane private void TmrLeftObjectSpawner_Tick(object sender, EventArgs e) { FallingObject fallingObject = new FallingObject(FallingObject.RandomType(), FallingObject.RandomLane(FallingObjectBigLane.Left)); this.Controls.Add(fallingObject); }
/// <summary> /// Player will be immune to bombs for 3 second /// </summary> public void ShieldCollected(FallingObject fallingObject) { Current.IsShieldActive = true; Current.ShieldTimer = DateTime.UtcNow; fallingObject.Destroy(); }
/// <summary> /// Pauses the game and brings end-game screen /// </summary> public void Fail(FallingObject fallingObject) { Pause(); EndGame(); }
/// <summary> /// Rewards player with a score, destroys given object /// </summary> public void Score(FallingObject fallingObject) { fallingObject.Destroy(); CurrentScore++; Scored(this, EventArgs.Empty); }
/// <summary> /// No reward for user, destroys given object /// </summary> public void NoScore(FallingObject fallingObject) { fallingObject.Destroy(); }