/// <summary> /// highlights the selected cmder and tells the commandPhaseMan to proceed with the selection /// </summary> /// <param name="cmd3d"></param> public void SelectCmder(Cmder3d cmd3d) { cmderHighlight.gameObject.SetActive(true); cmderHighlight.transform.position = cmd3d.transform.position; curSelectedCmder = cmd3d.data as Commander; cmdPhaseMan.OnCmderSelectedInWorld(cmd3d.data as Commander); }
void Update() { if (GameInterface.openedPanelsOverlayLevel != 0) { return; } foreach (Cmder3d cmd3d in allowedCmders3d) { //commanders which haven't taken an action this turn will keep spinning cmd3d.transform.Rotate(Vector3.up * 100 * Time.deltaTime); } //we still want the spinning commanders if no overlay panel is open if (EventSystem.current.IsPointerOverGameObject()) { return; } if (curSelectedCmder != null) { if (Input.GetButtonDown("Select")) { if (Physics.Raycast(cam.ScreenPointToRay(Input.mousePosition), out hit, 100)) { ZoneSpot hitSpotScript = hit.transform.GetComponent <ZoneSpot>(); if (hitSpotScript) { if (allowedMoveSpots.Contains(hitSpotScript)) { //move commander to target zone spot cmdPhaseMan.MoveCommander(curSelectedCmder, hitSpotScript); } } } } } else { if (Input.GetButtonDown("Select")) { if (Physics.Raycast(cam.ScreenPointToRay(Input.mousePosition), out hit, 100, 1 << 9)) { Cmder3d hitCmder = hit.transform.GetComponent <Cmder3d>(); if (hitCmder) { if (allowedCmders3d.Contains(hitCmder)) { SelectCmder(hitCmder); } } } } } }
public static Commander CreateNewCmderAtZone(Zone targetZone, Faction ownerFac) { Commander newCmder = new Commander(ownerFac.ID, targetZone.ID); Cmder3d cmd3d = Cmder3dRecycler.GetACmderObj(); cmd3d.transform.position = targetZone.MyZoneSpot. GetGoodSpotForCommander(GameController.GetCommandersInZone(targetZone).Count - 1); cmd3d.data = newCmder; cmd3d.RefreshDataDisplay(); instance.spawnedCmders.Add(cmd3d); return(newCmder); }
void Update() { if (GameInterface.openedPanelsOverlayLevel != 0 || EventSystem.current.IsPointerOverGameObject()) { if (LayoutToolTip.Instance.gameObject.activeSelf) { LayoutToolTip.Instance.HideTooltip(); } return; } if (Physics.Raycast(cam.ScreenPointToRay(Input.mousePosition), out hit, 100, (1 << 8) | (1 << 9))) { if (!curHoveredObj || curHoveredObj != hit.transform) { LayoutToolTip.Instance.HideTooltip(); curHoveredObj = hit.transform; ZoneSpot spotScript = curHoveredObj.GetComponent <ZoneSpot>(); if (spotScript) { LayoutToolTip.Instance.ShowTooltipForZone (spotScript.data as Zone, Input.mousePosition, GameInterface.instance.curInterfaceMode == GameInterface.InterfaceMode.game); } else { Cmder3d cmderScript = curHoveredObj.GetComponent <Cmder3d>(); if (cmderScript) { LayoutToolTip.Instance.ShowTooltipForCmder(cmderScript.data as Commander, Input.mousePosition); } } } } else { if (curHoveredObj) { curHoveredObj = null; LayoutToolTip.Instance.HideTooltip(); } } }
/// <summary> /// places all commanders stored in the current game data /// </summary> public static void SetupAllCommandersFromData() { Dictionary <Zone, int> placedCmdersInEachZone = new Dictionary <Zone, int>(); foreach (Zone z in GameController.instance.curData.zones) { placedCmdersInEachZone.Add(z, 0); } List <Commander> cmders = GameController.instance.curData.deployedCommanders; Cmder3d cmd3d = null; Zone curZone = null; for (int i = 0; i < cmders.Count; i++) { cmd3d = Cmder3dRecycler.GetACmderObj(); curZone = GameController.GetZoneByID(cmders[i].zoneIAmIn); cmd3d.transform.position = curZone.MyZoneSpot.GetGoodSpotForCommander(placedCmdersInEachZone[curZone]); cmd3d.data = cmders[i]; cmd3d.RefreshDataDisplay(); instance.spawnedCmders.Add(cmd3d); placedCmdersInEachZone[curZone]++; } }
public static void RemoveCmder3d(Cmder3d target3d) { Cmder3dRecycler.instance.cycler.PoolObj(target3d.gameObject); instance.spawnedCmders.Remove(target3d); target3d.transform.localScale = Vector3.one; }