public bool OnCollision(DrawableSceneComponent dsc) { Ground g = dsc as Ground; if (g != null) { return(true); } Levels.Characters.Hero h = dsc as Levels.Characters.Hero; if (life <= 0) { if (h != null) { if (hasPaint) { Levels.Characters.Hero.IncreaseLife(); hasPaint = false; this.Visible = false; } } return(false); } AI.AIMonster ai = dsc as AI.AIMonster; if (ai != null) { return(true); } if (h == null) { if (dsc.PhysicsBody.LinearVelocity.Length() * dsc.PhysicsBody.Mass > minLinearMoment) { life--; if (life == 0) { Message m = new Message { MessageType = MessageTypes.die, timeDelivery = 0, to = this }; AIManager.messageQueue.sendMessage(m); } return(false); } } return(true); }
/// <summary> /// The add drawable scene component. /// </summary> /// <param name="sceneId"> /// The scene id. /// </param> /// <param name="dsc"> /// The dsc. /// </param> public static void AddDrawableSceneComponent(int sceneId, ref DrawableSceneComponent dsc) { // SetUpLists(sceneId); List <DrawableSceneComponent> drawableComponents; if (drawableSceneComponents.TryGetValue(sceneId, out drawableComponents)) { int index = drawableComponents.BinarySearch(dsc, DrawableOrderComparer.Default); if (index < 0) { index = ~index; while ((index < drawableComponents.Count) && (drawableComponents[index].DrawOrder == dsc.DrawOrder)) { index++; } drawableComponents.Insert(index, dsc); } } }
/// <summary> /// The remove drawable scene component. /// </summary> /// <param name="sceneId"> /// The scene id. /// </param> /// <param name="dsc"> /// The dsc. /// </param> public static void RemoveDrawableSceneComponent(int sceneId, ref DrawableSceneComponent dsc) { drawableSceneComponents[sceneId].Remove(dsc); }