public bool TryHitEnemies(List <SnakePlayer> listPlayers) { for (int j = 0; j < listPlayers.Count; j++) { SnakePlayer other = listPlayers[j]; if (this != other) { if (HitTest(other, HitDistance)) { Blast(); return(true); } } } return(false); }
//碰撞函数,就是两个圆相交 public bool HitTest(SnakePlayer player, float testDistance) { SnakeNode node = player.Head; while (node != null) { if (node.IsKeyNode()) { float distance = Vector3.Distance(m_head.Position(), node.Position()); if (distance < testDistance) { return(true); } } node = node.Next; } return(false); }