/// <summary> /// click confirm, process generic option and return data to calling class /// </summary> private void ProcessGenericChoice() { GenericReturnData returnData = new GenericReturnData(); returnData.optionID = optionIDSelected; returnData.optionName = optionNameSelected; returnData.optionNested = optionTextSelected; returnData.nodeID = nodeIDSelected; returnData.actorSlotID = actorSlotIDSelected; //close picker window regardless EventManager.i.PostNotification(EventType.CloseGenericPicker, this, null, "ModalGenericPicker.cs -> ProcessGenericChoice"); //trigger the appropriate return Event and pass selected optionID back to the originating class switch (defaultReturnEvent) { case EventType.GenericTeamRecall: case EventType.GenericNeutraliseTeam: case EventType.GenericGearChoice: case EventType.GenericTargetInfo: case EventType.GenericCompromisedGear: case EventType.GenericRecruitActorResistance: case EventType.GenericRecruitActorAuthority: case EventType.GenericHandleActor: case EventType.GenericReserveActor: case EventType.GenericDismissActor: case EventType.GenericDisposeActor: EventManager.i.PostNotification(defaultReturnEvent, this, returnData, "ModalGenericPicker.cs -> ProcessGenericChoice"); break; default: Debug.LogError(string.Format("Invalid returnEvent \"{0}\"", defaultReturnEvent)); break; } }
[HideInInspector] public bool isActive; //is the option a valid choice option or is it greyed out? (can't be selected) /// <summary> /// Internal initialisation /// </summary> private void Awake() { isSelected = false; data = new GenericReturnData(); //asserts Debug.Assert(highlightImage != null, "Invalid highlightImage (Null)"); Debug.Assert(optionImage != null, "Invalid optionImage (Null)"); Debug.Assert(displayText != null, "Invalid displayText (Null)"); Debug.Assert(imageTooltip != null, "Invalid imageTooltip (Null)"); Debug.Assert(textTooltip != null, "Invalid textTooltip (Null)"); Debug.Assert(imageInteraction != null, "Invalid imageInteraction (Null)"); }
/// <summary> /// Event Handler /// </summary> /// <param name="eventType"></param> /// <param name="Sender"></param> /// <param name="Param"></param> public void OnEvent(EventType eventType, Component Sender, object Param = null) { //select event type switch (eventType) { case EventType.OpenGenericPicker: GenericPickerDetails details = Param as GenericPickerDetails; SetGenericPicker(details); break; case EventType.CloseGenericPicker: CloseGenericPicker(); break; case EventType.CancelButtonGeneric: ProcessCancelButton(); break; case EventType.ChangeColour: SetColours(); break; case EventType.ChangeSide: SetSide(); break; case EventType.ConfirmGenericActivate: GenericReturnData data = Param as GenericReturnData; SetConfirmButton(true, data); break; case EventType.ConfirmGenericDeactivate: SetConfirmButton(false); break; case EventType.ConfirmGenericChoice: ProcessGenericChoice(); break; case EventType.BackButtonGeneric: ProcessBackButton(); break; default: Debug.LogError(string.Format("Invalid eventType {0}{1}", eventType, "\n")); break; } }
/// <summary> /// Confirm button switched on/off. Only ON and visible if a generic option has been selected and a data package returned /// </summary> /// <param name="activate"></param> public void SetConfirmButton(bool isActive, GenericReturnData data = null) { string text = "Unknown";; //An option is selected if (isActive == true) { buttonConfirm.gameObject.SetActive(true); if (data != null) { //update currently selected option optionIDSelected = data.optionID; optionNameSelected = data.optionName; optionTextSelected = data.optionNested; //change top text to show which option selected switch (defaultReturnEvent) { case EventType.GenericTeamRecall: if (data.optionID > -1) { Team teamRecall = GameManager.i.dataScript.GetTeam(data.optionID); if (teamRecall != null) { text = string.Format("{0}{1} Team {2}{3}selected{4}", colourEffect, teamRecall.arc.name, colourEnd, colourDefault, colourEnd); Debug.LogFormat("[UI] -> ModalGenericPicker: teamArcID {0} selected{1}", data.optionID, "\n"); } else { Debug.LogError(string.Format("Invalid team (Null) for teamID {0}", data.optionID)); } } else { Debug.LogError("Invalid data.optionID (< 0)"); } break; case EventType.GenericNeutraliseTeam: if (data.optionID > -1) { Team teamNeutralise = GameManager.i.dataScript.GetTeam(data.optionID); if (teamNeutralise != null) { text = string.Format("{0}{1} Team {2}{3}selected{4}", colourEffect, teamNeutralise.arc.name, colourEnd, colourDefault, colourEnd); Debug.LogFormat("[UI] -> ModalGenericPicker: teamArcID {0} selected{1}", data.optionID, "\n"); } else { Debug.LogError(string.Format("Invalid team (Null) for teamID {0}", data.optionID)); } } else { Debug.LogError("Invalid data.optionID (< 0)"); } break; case EventType.GenericGearChoice: if (string.IsNullOrEmpty(data.optionName) == false) { Gear gear = GameManager.i.dataScript.GetGear(data.optionName); if (gear != null) { text = string.Format("{0}{1}{2} {3}selected{4}", colourEffect, gear.tag.ToUpper(), colourEnd, colourDefault, colourEnd); Debug.LogFormat("[UI] -> ModalGenericPicker: gear {0} selected{1}", data.optionName, "\n"); } else { Debug.LogError(string.Format("Invalid gear (Null) for gear {0}", data.optionName)); } } else { Debug.LogError("Invalid data.optionName (Null or Empty)"); } break; case EventType.GenericTargetInfo: if (string.IsNullOrEmpty(data.optionName) == false) { Target target = GameManager.i.dataScript.GetTarget(data.optionName); if (target != null) { text = string.Format("{0}{1}{2} {3}selected{4}", colourEffect, target.targetName.ToUpper(), colourEnd, colourDefault, colourEnd); Debug.LogFormat("[UI] -> ModalGenericPicker: target {0} selected{1}", data.optionName, "\n"); } else { Debug.LogError(string.Format("Invalid target (Null) for target {0}", data.optionName)); } } else { Debug.LogError("Invalid data.optionID (< 0)"); } break; case EventType.GenericCompromisedGear: if (string.IsNullOrEmpty(data.optionName) == false) { Gear gear = GameManager.i.dataScript.GetGear(data.optionName); if (gear != null) { text = string.Format("Save {0}{1}{2} for {3}{4} Renown{5} (have {6}{7}{8})", colourEffect, gear.tag.ToUpper(), colourEnd, colourNeutral, datapoint, colourEnd, colourGood, GameManager.i.playerScript.Power, colourEnd); Debug.LogFormat("[UI] -> ModalGenericPicker: gear {0} selected{1}", data.optionName, "\n"); } else { Debug.LogErrorFormat("Invalid gear (Null) for gear {0}", data.optionName); } } else { Debug.LogError("Invalid data.optionName (Null or Empty)"); } break; case EventType.GenericRecruitActorResistance: case EventType.GenericRecruitActorAuthority: if (data.optionID > -1) { Actor actor = GameManager.i.dataScript.GetActor(data.optionID); if (actor != null) { text = string.Format("{0}{1}{2} {3}selected{4}", colourEffect, actor.arc.name, colourEnd, colourDefault, colourEnd); Debug.LogFormat("[UI] -> ModalGenericPicker: actorID {0} selected{1}", data.optionID, "\n"); } else { Debug.LogError(string.Format("Invalid actor (Null) for actorID {0}", data.optionID)); } } else { Debug.LogError("Invalid data.optionID (< 0)"); } break; case EventType.GenericHandleActor: if (data.actorSlotID > -1) { if (string.IsNullOrEmpty(data.optionNested) == false) { Actor actor = GameManager.i.dataScript.GetCurrentActor(data.actorSlotID, GameManager.i.sideScript.PlayerSide); if (actor != null) { switch (data.optionNested) { case "HandleReserve": text = string.Format("{0}Send {1} to Reserve Pool{2} {3}selected{4}", colourEffect, actor.arc.name, colourEnd, colourDefault, colourEnd); Debug.LogFormat("[UI] -> ModalGenericPicker: {0}, ID {1}, to RESERVE pool selected{2}", actor.actorName, data.actorSlotID, "\n"); break; case "HandleDismiss": text = string.Format("{0}Move On {1}{2} {3}selected{4}", colourEffect, actor.arc.name, colourEnd, colourDefault, colourEnd); Debug.LogFormat("[UI] -> ModalGenericPicker: {0}, ID {1}, DISMISS selected{2}", actor.actorName, data.actorSlotID, "\n"); break; case "HandleDispose": text = string.Format("{0}Dispose of {1}{2} {3}selected{4}", colourEffect, actor.arc.name, colourEnd, colourDefault, colourEnd); Debug.LogFormat("[UI] -> ModalGenericPicker: {0}, ID {1}, DISPOSE selected{2}", actor.actorName, data.actorSlotID, "\n"); break; default: Debug.LogErrorFormat("Invalid data.optionText \"{0}\"", data.optionNested); break; } } else { Debug.LogError(string.Format("Invalid actor (Null) for actorID {0}", data.actorSlotID)); } } else { Debug.LogError("Invalid data.optionText (Null or Empty)"); } } else { Debug.LogError("Invalid data.optionID (< 0)"); } break; case EventType.GenericReserveActor: if (data.actorSlotID > -1) { if (string.IsNullOrEmpty(data.optionNested) == false) { Actor actor = GameManager.i.dataScript.GetCurrentActor(data.actorSlotID, GameManager.i.sideScript.PlayerSide); if (actor != null) { switch (data.optionNested) { case "ReserveRest": text = string.Format("{0}Send {1} to Rest{2} {3}selected{4}", colourEffect, actor.arc.name, colourEnd, colourDefault, colourEnd); Debug.LogFormat("[UI] -> ModalGenericPicker: {0}, ID {1}, REST selected{2}", actor.actorName, data.actorSlotID, "\n"); break; case "ReservePromise": text = string.Format("{0}You Promise {1}{2} {3}selected{4}", colourEffect, actor.arc.name, colourEnd, colourDefault, colourEnd); Debug.LogFormat("[UI] -> ModalGenericPicker: {0}, ID {1}, PROMISE selected{2}", actor.actorName, data.actorSlotID, "\n"); break; case "ReserveNoPromise": text = string.Format("{0}NO promises to {1}{2} {3}selected{4}", colourEffect, actor.arc.name, colourEnd, colourDefault, colourEnd); Debug.LogFormat("[UI] -> ModalGenericPicker: {0}, ID {1}, NO PROMISE selected{2}", actor.actorName, data.actorSlotID, "\n"); break; default: Debug.LogError(string.Format("Invalid data.optionText \"{0}\"", data.optionNested)); break; } } else { Debug.LogError(string.Format("Invalid actor (Null) for actorID {0}", data.actorSlotID)); } } else { Debug.LogError("Invalid data.optionText (Null or Empty)"); } } else { Debug.LogError("Invalid data.actorSlotID (< 0)"); } break; case EventType.GenericDismissActor: if (data.actorSlotID > -1) { if (string.IsNullOrEmpty(data.optionNested) == false) { Actor actor = GameManager.i.dataScript.GetCurrentActor(data.actorSlotID, GameManager.i.sideScript.PlayerSide); if (actor != null) { switch (data.optionNested) { case "DismissPromote": text = string.Format("{0}Promote {1}{2} {3}selected{4}", colourEffect, actor.arc.name, colourEnd, colourDefault, colourEnd); Debug.LogFormat("[UI] -> ModalGenericPicker: {0}, ID {1}, PROMOTE selected{2}", actor.actorName, data.actorSlotID, "\n"); break; case "DismissIncompetent": text = string.Format("{0}Dismiss {1} for Incompetence{2} {3}selected{4}", colourEffect, actor.arc.name, colourEnd, colourDefault, colourEnd); Debug.LogFormat("[UI] -> ModalGenericPicker: {0}, ID {1}, INCOMPETENT selected{2}", actor.actorName, data.actorSlotID, "\n"); break; case "DismissUnsuited": text = string.Format("{0}Dismiss {1} for Unsuitability{2} {3}selected{4}", colourEffect, actor.arc.name, colourEnd, colourDefault, colourEnd); Debug.LogFormat("[UI] -> ModalGenericPicker: {0}, ID {1}, UNSUITED selected{2}", actor.actorName, data.actorSlotID, "\n"); break; default: Debug.LogErrorFormat("Invalid data.optionText \"{0}\"", data.optionNested); break; } } else { Debug.LogErrorFormat("Invalid actor (Null) for actorID {0}", data.actorSlotID); } } else { Debug.LogError("Invalid data.optionText (Null or Empty)"); } } else { Debug.LogError("Invalid data.actorSlotID (< 0)"); } break; case EventType.GenericDisposeActor: if (data.actorSlotID > -1) { if (string.IsNullOrEmpty(data.optionNested) == false) { Actor actor = GameManager.i.dataScript.GetCurrentActor(data.actorSlotID, GameManager.i.sideScript.PlayerSide); if (actor != null) { switch (data.optionNested) { case "DisposeLoyalty": text = string.Format("{0}Dispose of {1} because they are Disloyal{2} {3}selected{4}", colourEffect, actor.arc.name, colourEnd, colourDefault, colourEnd); Debug.LogFormat("[UI] -> ModalGenericPicker: {0}, ID {1}, DISPOSE due to LOYALTY selected{2}", actor.actorName, data.actorSlotID, "\n"); break; case "DisposeCorrupt": text = string.Format("{0}Dispose of {1} because they are Corrupt{2} {3}selected{4}", colourEffect, actor.arc.name, colourEnd, colourDefault, colourEnd); Debug.LogFormat("[UI] -> ModalGenericPicker: {0}, ID {1}, DISPOSE due to CORRUPTION{2}", actor.actorName, data.actorSlotID, "\n"); break; case "DisposeHabit": text = string.Format("{0}Dispose of {1} because you can{2} {3}selected{4}", colourEffect, actor.arc.name, colourEnd, colourDefault, colourEnd); Debug.LogFormat("[UI] -> ModalGenericPicker: {0}, ID {1}, DISPOSE due to HABIT{2}", actor.actorName, data.actorSlotID, "\n"); break; default: Debug.LogErrorFormat("Invalid data.optionText \"{0}\"", data.optionNested); break; } } else { Debug.LogErrorFormat("Invalid actor (Null) for actorID {0}", data.actorSlotID); } } else { Debug.LogError("Invalid data.optionText (Null or Empty)"); } } else { Debug.LogError("Invalid data.actorSlotID (< 0)"); } break; } } else { Debug.LogError("Invalid GenericReturnData (Null)"); } } else { //Nothing currently selected, show generic message buttonConfirm.gameObject.SetActive(false); switch (defaultReturnEvent) { case EventType.GenericTeamRecall: text = string.Format("{0}Recall{1} {2}team{3}", colourEffect, colourEnd, colourNormal, colourEnd); break; case EventType.GenericNeutraliseTeam: text = string.Format("{0}Neutralise{1} {2}team{3}", colourEffect, colourEnd, colourNormal, colourEnd); break; case EventType.GenericGearChoice: text = string.Format("{0}Gear{1} {2}selection{3}", colourEffect, colourEnd, colourNormal, colourEnd); break; case EventType.GenericTargetInfo: text = string.Format("{0}Target{1} {2}selection{3}", colourEffect, colourEnd, colourNormal, colourEnd); break; case EventType.GenericCompromisedGear: text = string.Format("{0}Use Renown to {1}{2}SAVE ONE{3}{4} item{5} <size=70%>(optional)</size>", colourNormal, colourEnd, colourNeutral, colourEnd, colourNormal, colourEnd); break; case EventType.GenericRecruitActorResistance: case EventType.GenericRecruitActorAuthority: text = string.Format("{0}Recruit{1} {2}selection{3}", colourEffect, colourEnd, colourNormal, colourEnd); break; case EventType.GenericHandleActor: text = string.Format("{0}Managerial{1} {2}selection{3}", colourEffect, colourEnd, colourNormal, colourEnd); break; case EventType.GenericReserveActor: text = string.Format("{0}Reserve Pool{1} {2}selection{3}", colourEffect, colourEnd, colourNormal, colourEnd); break; case EventType.GenericDismissActor: text = string.Format("{0}Dismiss{1} {2}selection{3}", colourEffect, colourEnd, colourNormal, colourEnd); break; case EventType.GenericDisposeActor: text = string.Format("{0}Dispose off{1} {2}selection{3}", colourEffect, colourEnd, colourNormal, colourEnd); break; default: text = string.Format("{0}Select {1}{2}ANY{3}{4} Option{5}", colourDefault, colourEnd, colourEffect, colourEnd, colourDefault, colourEnd); break; } } //update top text topText.text = text; }
private bool isSelected; //has the option been selected /// <summary> /// Internal initialisation /// </summary> private void Awake() { isSelected = false; data = new GenericReturnData(); }