void processSelectedAction(CreatureActions externalAction) { Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); if (worldServer != null && worldServer.IsConnected) { //Console.WriteLine("Action choosen: " + externalAction); switch (externalAction) { case CreatureActions.DO_NOTHING: // Do nothing as the own value says break; case CreatureActions.ROTATE_CLOCKWISE: //worldServer.SendSetAngle(creatureId, 2, 0, 0); worldServer.SendSetAngle(creatureId, 0.5, -0.5, 0.5); break; case CreatureActions.GO_AHEAD: //worldServer.SendSetAngle(creatureId, 1, 1, prad); worldServer.SendSetAngle(creatureId, 0.5, -0.5, 0.5); //worldServer.SendSetAngle(creatureId, 2, 0, 0); break; case CreatureActions.GO_TO_JEWEL: worldServer.SendSetGoTo(creatureId, 1, 1, currentJewel.X1, currentJewel.Y1); break; case CreatureActions.FUEL_LOW: //Console.WriteLine ("Low fuel working.......current food: " + currentFood); if (currentFood != null) { worldServer.SendSetGoTo(creatureId, 1, 1, currentFood.X1, currentFood.Y1); // go to the near food } else { worldServer.SendSetAngle(creatureId, 0.5, -0.5, 0.5); // rotate to see more foods } break; case CreatureActions.EAT_FOOD: worldServer.SendEatIt(creatureId, currentFood.Name); break; case CreatureActions.GET_JEWEL: if (isDesiredJewel(currentJewel.Material.Color)) { worldServer.SendSackIt(creatureId, currentJewel.Name); } else { worldServer.SendHideIt(creatureId, currentJewel.Name); // Workaround in case to get a jewel that is not needed } processLeafletControl(currentJewel.Material.Color); //Console.WriteLine(currentJewel.Name + " | " + currentJewel.Material.Color + " | " + currentJewel.X1 + "|" + currentJewel.Y1); break; case CreatureActions.HIDE_JEWEL: worldServer.SendHideIt(creatureId, currentJewel.Name); break; case CreatureActions.GOAL_ACHIEVED: // Creature distance to spot - start String [] creatureXY = worldServer.sendGetCreaturePosition(creatureId); double creatureX = Convert.ToDouble(creatureXY [0]); double creatureY = Convert.ToDouble(creatureXY [1]); //Console.WriteLine ("Creature X: " + creatureX); //Console.WriteLine ("Creature Y: " + creatureY); double distance = worldServer.CalculateDistanceToCreature(creatureX, creatureY, 700.0, 500.0); //Console.WriteLine ("Creature distance to spot: " + distance); // Creature distance to spot - end if (distance <= 20) { worldServer.SendStopCreature(creatureId); processLeafletControl(); exchangeJewels = true; //Console.WriteLine ("Leaflet numbers: "); //Console.WriteLine (Convert.ToString (leaflet1.leafletID)); //Console.WriteLine (Convert.ToString (leaflet2.leafletID)); //Console.WriteLine (Convert.ToString (leaflet3.leafletID)); worldServer.sendDeliverLeaflet(creatureId, Convert.ToString(leaflet1.leafletID)); worldServer.sendDeliverLeaflet(creatureId, Convert.ToString(leaflet2.leafletID)); worldServer.sendDeliverLeaflet(creatureId, Convert.ToString(leaflet3.leafletID)); //Console.WriteLine ("Jewels exchanged!!!"); MaxNumberOfCognitiveCycles = CurrentCognitiveCycle; //Console.Out.WriteLine ("Clarion Creature: Goal achieved at: " + DateTime.Now); } else { worldServer.SendSetGoTo(creatureId, 1, 1, 700.0, 500.0); } break; default: break; } } //Console.WriteLine("Remaining jewel: " + getJewelRemainingTotal()); }