public void recruiteDrones(GameEvent gameEvent, QuantumModel model, General general, double cloudRadius) { double milsForDrone = model.milsPerDronToRecruite; int amountOfDroneToRecruite = (int)((recruiteAccumulatedTime + gameEvent.deltaTime) / milsForDrone); recruiteAccumulatedTime += gameEvent.deltaTime - amountOfDroneToRecruite * milsForDrone; if (amountOfDroneToRecruite <= 0) { return; } Outpost outpost = model.findOutpostByPosition(general.Position, 1.5 * model.cloudRadius); if (outpost == null) { return; } while (amountOfDroneToRecruite > 0) { Drone drone = findDrone(outpost, general, cloudRadius); if (drone == null) { return; } drone.Order = DroneOrder.MoveToGeneral; amountOfDroneToRecruite--; } }
public void giveOrderToDrones(GameEvent gameEvent, QuantumModel model, General general, Vector targetPosition, double cloudRadius) { Vector distanceToPoint = Vector.Subtract(targetPosition, general.Position); double milsForDrone = distanceToPoint.Length * distanceToPoint.Length * distanceToPoint.Length / model.milsOrderFactor; int amountOfDroneToSend = (int)((orderAccumulatedTime + gameEvent.deltaTime) / milsForDrone); orderAccumulatedTime += gameEvent.deltaTime - amountOfDroneToSend * milsForDrone; Outpost outpost = model.findOutpostByPosition(targetPosition, model.cloudRadius); foreach (Drone dron in general.Drones) { if (amountOfDroneToSend <= 0) { break; } if (dron.Order == DroneOrder.MoveToGeneral && Vector.Subtract(dron.Position, general.Position).Length < cloudRadius * 1.5) { amountOfDroneToSend--; if (outpost != null) { dron.TargetOutpost = outpost.id; dron.Order = DroneOrder.MoveToOutpost; } else { dron.TargetPosition = targetPosition; dron.Order = DroneOrder.MoveToPosition; } } } }