// Handle Collisions // ====================================== // Define behaviour when an object is colliding // with another public override bool Intersect(GameObject go) { if (base.Intersect(go)) { // Collide with Apple if (go.GetType() == typeof(Apple)) { Grow(); return(true); } // Collide with Bomb if (go.GetType() == typeof(Bomb)) { Shrink(); return(true); } // Collide with Bouncer if (go.GetType() == typeof(Bouncer)) { m_direction = GetReverseDirection(); return(true); } } // Check if tail is hit by a bomb // ====================================== if (go.GetType() == typeof(Bomb)) { for (int i = 0; i < m_size; i++) { if (m_tail[i].Equals(go.Position)) { Shrink(); return(true); } } } return(false); }
// Handle Collisions // ====================================== // Define behaviour when an object is colliding // with another public override bool Intersect(GameObject go) { if (base.Intersect(go)) { // Remove if (go.GetType() == typeof(Snake)) { m_state = State.DEAD; return(true); } } return(false); }