private void customCreatureThoughtPattern(ArtificialIntelligence creatureAI) { Point creaturePos = creatureAI.GetBody().GetPosition(); Color creatureColor = Color.Black; List<LightSource> nearLights = LightSource.GetLocalLightSources(creaturePos.x, creaturePos.y); //if there's a light of the opposite color close to us, run from it, and don't think of anything else foreach (LightSource light in nearLights) { if (light is Lightstone) { continue; } if (light.GetColor().IsOpposite(creatureColor)) { //run away! creatureAI.GetBody().SetDirection(GetOppositeDirection(creaturePos, light.GetPosition())); } } //if there's an active lightstone nearby, check if we're in range to be able to attack it //if we are in range, attack it //if we're not in range, move closer to it }
private void exitReached(ArtificialIntelligence ai) { ai.GetBody().Destroy(); playerHealth -= 1; GuiLayer.GetLayerByName("HUD").GetGUIElement(1).As<LabelValue>().SetValue(playerHealth.ToString()); if (playerHealth == 0) { levelDefeat(); } // If there are no more enemies... else if (this.levelEntryPoint.Active == false && enemyFaction.EntityCount == 0) { levelVictory(); } }