/// <summary> /// Collision trigger /// </summary> /// <param name="other">Other gameobject</param> public override void OnCollision(GameObject other) { // Apply effect to the collided gameobject ApplyEffect(other); base.OnCollision(other); }
/// <summary> /// Oncollision trigger /// </summary> /// <param name="other">Other gameobject</param> public override void OnCollision(GameObject other) { // if the other object is player if (other is Player) { // add this object to remove list GameWorld.ObjectsToRemove.Add(this); } }
/// <summary> /// On Collision with another GameObject /// </summary> /// <param name="other">the other GameObject</param> public override void OnCollision(GameObject other) { //If the collided object is an enemy, remove this object and remove helth from the enemy. if (other is Enemy) { GameWorld.ObjectsToRemove.Add(this); (other as Enemy).Health --; } }
/// <summary> /// Ally effect tot other player /// </summary> /// <param name="other">Other gameobject</param> public void ApplyEffect(GameObject other) { if (other is Player) { if ((other as Player).Health < 50) { (other as Player).Health += 50; } else { (other as Player).Health = 100; } } }
/// <summary> /// Ally effect tot other player /// </summary> /// <param name="other">Other gameobject</param> public void ApplyEffect(GameObject other) { if (other is Player) { if ((other as Player).Mana < 50) { (other as Player).Mana += 50; } else { (other as Player).Mana = 100; } } }
/// <summary> /// Enemy collison and its response to different GameObject's. /// </summary> /// <param name="other">The other GameObject</param> public override void OnCollision(GameObject other) { // if the other gameobject is of the class projectile if (other is Projectile) { // Loose health form the projectile Health -= 25; } // if other is player if (other is Player) { // call the attack function Attack(); } }
/// <summary> /// Abstract method for functionality when colliding with a specific GameObject /// </summary> /// <param name="other">The other GameObject</param> public abstract void OnCollision(GameObject other);
/// <summary> /// Checks for collision with a specific GameObject /// </summary> /// <param name="other">The other GameObject</param> /// <returns></returns> public bool IsCollidingWith(GameObject other) { //Return wether two collisionboxes are collising return collisionBox.IntersectsWith(other.CollisionBox); }
/// <summary> /// Collision trigger /// </summary> /// <param name="other">Other gameobject</param> public override void OnCollision(GameObject other) { ApplyEffect(other); base.OnCollision(other); }
/// <summary> /// Collision, nothing happens /// </summary> /// <param name="other">other gameobject</param> public override void OnCollision(GameObject other) { }