public static void AiNewCmderPhase(Faction curFac, List <Zone> availableZones) { if (availableZones.Count == 1) { //not much thinking needed for the AI in this case NewCmderPhaseMan.OrderPlaceNewCmder(availableZones[0].ID, GameModeHandler.instance.curPlayingFaction); return; } Zone topZone = null; float topScore = 0; float candidateScore; //zones with higher recruit factors and safety are better for new cmders foreach (Zone z in availableZones) { candidateScore = GetZoneDangerScore(z, curFac, true); candidateScore = z.multRecruitmentPoints + candidateScore * NEW_CMDER_ZONE_DANGER_INFLUENCE; if (candidateScore >= topScore) { topScore = candidateScore; topZone = z; } } if (!GameModeHandler.instance.currentTurnIsFast) { CameraPanner.instance.JumpToSpot(topZone.MyZoneSpot.transform.position); } NewCmderPhaseMan.OrderPlaceNewCmder(topZone.ID, GameModeHandler.instance.curPlayingFaction); }
void Update() { if (GameInterface.openedPanelsOverlayLevel != 0) { return; } if (Physics.Raycast(cam.ScreenPointToRay(Input.mousePosition), out hit, 100, 1 << 8)) { ZoneSpot hitSpotScript = hit.transform.GetComponent <ZoneSpot>(); if (allowedSpots.Contains(hitSpotScript)) { //select zone if no zone was already selected curHoveredValidZone = hitSpotScript; cmderBlueprint.gameObject.SetActive(true); cmderBlueprint.position = hitSpotScript.GetGoodSpotForCommander(); cmderBlueprint.Rotate(Vector3.up * Time.deltaTime * 100); //just a little rotation to make it prettier haha } else { curHoveredValidZone = null; cmderBlueprint.gameObject.SetActive(false); } } else { curHoveredValidZone = null; cmderBlueprint.gameObject.SetActive(false); } if (Input.GetButtonDown("Select")) { if (curHoveredValidZone != null) { NewCmderPhaseMan.OrderPlaceNewCmder((curHoveredValidZone.data as Zone).ID, GameModeHandler.instance.curPlayingFaction); actionOnSpotSelect(); enabled = false; } } }