public virtual void Back(OptButton opt) { if (previous != null) { characterCustomization.SwitchState(previous); } }
public override void Entered(State s, State fromPrevious) { characterCustomization.character.race = null; base.Entered(s, fromPrevious); characterCustomization.manager.optionsWindow.SetTitle("Choose Race"); OptButton human = characterCustomization.manager.optionsWindow.AddButton("Human"); human.OnOptLeftClicked += SelectedHuman; Race race = new Race(RaceName.HUMAN); race.DressOptButtonForTooltip(human, Tooltip.TooltipPosition.RIGHT); race = new Race(RaceName.HALF_ORC); OptButton halfOrc = characterCustomization.manager.optionsWindow.AddButton("Half-Orc"); race.DressOptButtonForTooltip(halfOrc, Tooltip.TooltipPosition.RIGHT); halfOrc.OnOptLeftClicked += SelectedHalfOrc; human.WasLeftClicked(); }
public override void Entered(State s, State fromPrevious) { base.Entered(s, fromPrevious); characterCustomization.manager.optionsWindow.SetTitle(featurePointer.headerText); //filtration should happen here... List <GenericFeature> filtered = featurePointer.filterPool(characterCustomization.character); if (filtered.Count == 0) { Debug.LogWarning(this.GetType().ToString() + " had 0 options after being filtered"); characterCustomization.SwitchState(destination); return; } foreach (GenericFeature f in filtered) { OptButton opt = characterCustomization.manager.optionsWindow.AddButton(f.Name()); f.DressOptButtonForTooltip(opt, Tooltip.TooltipPosition.RIGHT); opt.OnOptLeftClicked += SelectedOption; buttonsToFeatureOpts.Add(opt, f); } buttonsToFeatureOpts.Keys.ToList().First().WasLeftClicked(); }
void SelectedFighter(OptButton opt) { CleanLastChosen (); //@switchin // Tooltip.instance.SetText (ClassLevel5e.Description (ClassType.FIGHTER)); // characterCustomization.manager.infoWindow.ClearContent (); // characterCustomization.manager.infoWindow.AddTextContent(ClassLevel5e.Description (ClassType.FIGHTER)); lastClassChosen = ClassLvlFromType(ClassType.FIGHTER); // // if (characterCustomization.character.CharacterLevel == 0) { // //0 represents a starting character class level // // lastClassChosen = new ClassLevel5e (ClassType.FIGHTER, 0); // } else { // Debug.Log("gettin nth level: " + (characterCustomization.character.ClassLevelIn(ClassType.FIGHTER) + 1).ToString()); // //1 + represents a multiclassing, or continuing level fighter. // lastClassChosen = new ClassLevel5e (ClassType.FIGHTER, characterCustomization.character.ClassLevelIn(ClassType.FIGHTER) + 1); // } // characterCustomization.manager.infoWindow.SetTitle(Util.UtilString.Capitalize(lastClassChosen.PresentableType ())); lastClassChosen.InitDefaultFeatures (); characterCustomization.character.AddClassLevel(lastClassChosen); SelectFeatures (lastClassChosen.features); }
void Cancel(OptButton button) { if (OnCanceled != null) { OnCanceled(this); } }
void Confirm(OptButton button) { if (OnConfirmed != null) { OnConfirmed(this); } }
void SelectStartOver(OptButton opt) { // characterCustomization.manager.infoWindow.ClearContent (); // characterCustomization.manager.infoWindow.AddTextContent("\n Press confirm to start all over."); doFinish = false; characterCustomization.manager.confirmSelection.GetComponent <Button> ().interactable = true; }
void SelectFinish(OptButton opt) { doFinish = true; // characterCustomization.manager.infoWindow.ClearContent (); // characterCustomization.manager.infoWindow.AddTextContent("\n Press confirm to finalize your choices."); characterCustomization.manager.confirmSelection.GetComponent <Button> ().interactable = true; }
public void UnindicateDroppable(OptButton self) { if (currentlyDraggingSlot != null) { //TODO: cancel the illustration that you may NOT drop here. } }
private void SetOnClickForOpt(OptButton opt, ActionButtonNode n) { if (n.disabled) { opt.OnOptMousedOver += (button) => { UIManager.instance.Tooltip.SetText(n.label + ": " + n.disabledReason); UIManager.instance.Tooltip.Show(opt.transform as RectTransform); }; opt.OnOptMousedOut += (button) => { UIManager.instance.Tooltip.Hide(); // UIManager.instance.tooltip.SetText(n.disabledReason); }; opt.GetComponent <Button> ().interactable = false; } else { opt.OnOptLeftClicked += (button) => { NodeSelected(n); }; opt.SetTooltipInfo(Tooltip.TooltipPosition.TOP, 0, n.label, n.rightClickDescription); } }
private void DoShowRightClick(OptButton self) { if (tooltipRightClick != null) { Tooltip.instance.SetText(tooltipRightClick); Tooltip.instance.Show(self.transform as RectTransform, tooltipPosition, tooltipOffset); } }
void Decr(OptButton op) { if (current > Min) { WillChange(true); current--; Changed(true); } }
void Incr(OptButton op) { if (current < Max) { WillChange(); current++; Changed(); } }
public override void Start() { base.Start(); OptButton opt = GetComponent <OptButton> (); opt.OnOptMousedOver += IndicateDroppable; opt.OnOptMousedOut += UnindicateDroppable; }
void SelectedHalfOrc(OptButton opt) { //@switchin characterCustomization.character.race = new Race(RaceName.HALF_ORC); // characterCustomization.manager.infoWindow.SetTitle("Half-Orc"); // characterCustomization.manager.infoWindow.ClearContent (); // characterCustomization.manager.infoWindow.AddTextContent(Race.Description (RaceName.HALF_ORC)); SelectFeatures(characterCustomization.character.race.features); }
public OptButton AddButton(string text) { GameObject btn = Instantiate(UIPrefabs.instance.optButtonPrefab); OptButton opt = btn.GetComponent <OptButton> (); opt.optText.text = text; btn.transform.SetParent(Content, false); return(opt); }
void SelectedHuman(OptButton opt) { characterCustomization.character.race = new Race(RaceName.HUMAN); //@switchin // characterCustomization.manager.infoWindow.SetTitle("Human"); // characterCustomization.manager.infoWindow.ClearContent (); // Tooltip.instance.SetText (Race.Description(RaceName.HUMAN)); // characterCustomization.manager.infoWindow.AddTextContent(Race.Description (RaceName.HUMAN)); SelectFeatures(characterCustomization.character.race.features); }
public void TakeItem(OptButton btn) { if (character == InventoryView.instance.currentCharacter) { return; } if (ItemSlot.currentlyDraggingSlot != null) { NoTakeItemReason reason = GetNoTakeItemReason(); switch (reason) { case NoTakeItemReason.GIVER_NO_INTERACTION: Debug.LogError("Giver needs interaction!"); break; case NoTakeItemReason.TAKER_NO_INTERACTION: Debug.LogError("TAKER needs interaction!"); break; case NoTakeItemReason.TAKER_NO_ROOM: Debug.LogError("TAKER has no room left!"); break; case NoTakeItemReason.GIVER_OR_TAKER_NOT_ACTING: Debug.LogError("Giver or taker must be acting."); break; case NoTakeItemReason.OUT_OF_RANGE: Debug.LogError("Giver and taker must be within " + GiveItem.GIVE_DISTANCE + " squares of each other."); break; case NoTakeItemReason.NO_REASON__CAN_TAKE: Debug.Log("You may add, my son!"); //do action if (InventoryView.instance.IsBattleMode) { GiveItem act = GiveAndTakeAction(); act.Perform(); } else { character.inventory.AddItem(ItemSlot.currentlyDraggingSlot.GiveUpItem()); } InventoryView.instance.RefreshUi(); break; default: break; } } }
public override void Confirm(OptButton opt) { if (doFinish) { Finish(); } else { StartOver(); } }
IEnumerator SetWindowRefs() { yield return(new WaitForEndOfFrame()); GameObject options = Instantiate(dialogWindowPrefab); //get the window out of it's own canvas Transform optionsTransform = options.transform.GetChild(0); //add it to the creation ui transform // optionsTransform.SetParent (ui,false); //finally set the ref to it's window component optionsWindow = optionsTransform.GetComponent <GenericDialog>(); optionsWindow.gameObject.SetActive(false); confirmSelection = optionsWindow.ConfirmBtn; backButton = optionsWindow.CancelBtn; //This should be a tooltip on each option that is created.... // GameObject descriptionWindow = Instantiate (descriptionWindowPrefab); //get the window out of it's own canvas // Transform descsTransform = descriptionWindow.transform.GetChild (0); //add it to the creation ui transform // descsTransform.SetParent (ui,false); //finally set the ref to it's window component // Utilities.UtilUnity.PasteValuesFromComponentAToB<GenericDialog>( // descriptionWindow.GetComponent<GenericDialog>(), // infoWindow = descsTransform.GetComponent<GenericDialog>(); GameObject runningSheet = Instantiate(inventoryViewPrefab); //get the window out of it's own canvas // Transform runningSheetTransform = runningSheet.transform.GetChild (0); //add it to the creation ui transform // runningSheetTransform.SetParent (ui,false); //finally set the ref to it's window component //finally set the ref to it's window component // Utilities.UtilUnity.PasteValuesFromComponentAToB<GenericDialog>( // runningSheet.GetComponent<GenericDialog>(), // ); InventoryView.instance.doStubCharacters = false; InventoryView.instance.interactivityDisabled = true; character = new Sheet(); character.Name = "New Character"; customizationController = new CharacterCreationController(this, character); customizationController.BeginCustomization(); StartCoroutine(ShowInv()); }
void Drag(OptButton button) { if (dragging) { } else { dragging = true; startHeight = Height; startMousePosY = (int)Input.mousePosition.y; } //private }
private void DoShowHoverTooltip(OptButton self) { if (tooltipHoverText != null) { if (tooltipRightClick != null) { Tooltip.instance.SetText(tooltipHoverText + "\n(Right-click for more details)"); } else { Tooltip.instance.SetText(tooltipHoverText); } Tooltip.instance.Show(self.transform as RectTransform, tooltipPosition, tooltipOffset); } }
void BeganDragging(OptButton slot) { if (InventoryView.instance.interactivityDisabled) { return; } if (currentItem != null) { currentlyDraggingSlot = this; Sprite s = IconDispenser.instance.SpriteFromIconName(currentItem.IconType); PanelImage().color = new Color(1f, 1f, 1f, .4f); Cursor.SetCursor(s.texture, new Vector2(s.texture.width / 2, s.texture.height / 2), CursorMode.Auto); } }
public void IndicateDroppable(OptButton self) { if (currentlyDraggingSlot != null) { NoDropReason reason = DropRestrictReasonEquipSlot(currentlyDraggingSlot.CurrentItem); switch (reason) { case NoDropReason.NONE__CAN_ACTUALLY_DROP: if (InventoryView.instance.IsBattleMode) { string tip = "Equip " + currentlyDraggingSlot.CurrentItem.Name; if (InventoryView.instance.CurrentActor.UsedInteraction()) { tip += " (Action)"; } else { tip += " (Interaction)"; } UIManager.instance.Tooltip.SetText(tip); UIManager.instance.Tooltip.Show(transform as RectTransform); } break; case NoDropReason.NOT_EQUIPMENT: UIManager.instance.Tooltip.SetText(currentlyDraggingSlot.CurrentItem.Name + " is not equipment"); UIManager.instance.Tooltip.Show(transform as RectTransform); break; case NoDropReason.NO_FIT: UIManager.instance.Tooltip.SetText(currentlyDraggingSlot.CurrentItem.Name + " doesn't fit here"); UIManager.instance.Tooltip.Show(transform as RectTransform); break; case NoDropReason.NOT_YOUR_TURN: UIManager.instance.Tooltip.SetText("Not " + InventoryView.instance.CurrentActor.CharSheet.Name + "'s turn"); UIManager.instance.Tooltip.Show(transform as RectTransform); break; case NoDropReason.NO_ACTION_LEFT: UIManager.instance.Tooltip.SetText("No actions left"); UIManager.instance.Tooltip.Show(transform as RectTransform); break; } } }
public override void Entered(State s, State fromPrevious) { base.Entered (s, fromPrevious); characterCustomization.manager.optionsWindow.SetTitle("Choose Class"); OptButton fighter = characterCustomization.manager.optionsWindow.AddButton ("Fighter"); fighter.OnOptMousedOver += (button) => { int lvl; if(lastClassChosen != null && lastClassChosen.classType == ClassType.FIGHTER) { lvl = characterCustomization.character.ClassLevelIn(ClassType.FIGHTER) - 1; } else { lvl = characterCustomization.character.ClassLevelIn(ClassType.FIGHTER); } ClassLevel5e fgterStub = new ClassLevel5e(ClassType.FIGHTER, lvl); fgterStub.InitDefaultFeatures(); Tooltip.instance.SetText(fgterStub.TooltipHoverText()); Tooltip.instance.Show(fighter.transform as RectTransform, Tooltip.TooltipPosition.RIGHT); }; fighter.OnOptMousedOut += (button) => { Tooltip.instance.Hide(); }; fighter.OnOptLeftClicked += SelectedFighter; OptButton wizard = characterCustomization.manager.optionsWindow.AddButton ("Wizard"); wizard.OnOptMousedOver += (button) => { int lvl; if(lastClassChosen != null && lastClassChosen.classType == ClassType.WIZARD) { lvl = characterCustomization.character.ClassLevelIn(ClassType.WIZARD) - 1; } else { lvl = characterCustomization.character.ClassLevelIn(ClassType.WIZARD); } ClassLevel5e wizardStub = new ClassLevel5e(ClassType.WIZARD, lvl); wizardStub.InitDefaultFeatures(); Tooltip.instance.SetText(wizardStub.TooltipHoverText()); Tooltip.instance.Show(wizard.transform as RectTransform, Tooltip.TooltipPosition.RIGHT); }; wizard.OnOptMousedOut += (button) => { Tooltip.instance.Hide(); }; wizard.OnOptLeftClicked += SelectedWizard; fighter.WasLeftClicked (); }
public virtual void Confirm(OptButton tbn = null) { if (featuresSelected == null) { return; } // Debug.Log("Okay now " + this.GetType().ToString()); // Debug.Log("-> " + this.destination.GetType().ToString()); //check features for feature pointers. wire them into to be the next state, with the last customization state //pointing to this destination... List <CharacterCustomizationStep> steps = new List <CharacterCustomizationStep>(); foreach (GenericFeature f in featuresSelected) { if (f is FeaturePointer) { FeaturePointer pointer = (FeaturePointer)f; steps.Add(pointer.GetCustomizationStep(characterCustomization)); } } if (steps.Count > 0) { CharacterCustomizationStep nextStep = steps [0]; CharacterCustomizationStep nextPrevious = this; for (int i = 1; i < steps.Count; i++) { nextStep.destination = steps [i]; nextStep.previous = nextPrevious; nextPrevious = nextStep; nextStep = steps [i]; } nextStep.destination = destination; nextStep.previous = nextPrevious; characterCustomization.SwitchState(steps [0]); } else { characterCustomization.SwitchState(destination); } }
void PageRight_OnOptClicked(OptButton button) { if (toTheRight.Count >= adjustedMaxPerPage) { toTheLeft = toTheLeft.Concat(currentActionNodesShown).ToList(); currentActionNodesShown = toTheRight.GetRange(0, adjustedMaxPerPage); toTheRight.RemoveRange(0, adjustedMaxPerPage); } else { toTheLeft = toTheLeft.Concat(currentActionNodesShown.GetRange(0, toTheRight.Count)).ToList(); currentActionNodesShown.RemoveRange(0, toTheRight.Count); currentActionNodesShown = currentActionNodesShown.Concat(toTheRight).ToList(); toTheRight = new List <ActionButtonNode> (); } UpdatePeripheralActions(); Populate(currentActionNodesShown); }
void SelectedOption(OptButton opt) { GenericFeature f; if (buttonsToFeatureOpts.TryGetValue(opt, out f)) { featurePointer.parent.features.Remove(lastChosen); lastChosen = f; featurePointer.parent.features.Add(lastChosen); // Tooltip.instance.SetText (f.Description ()); //@switchin // characterCustomization.manager.infoWindow.ClearContent (); // characterCustomization.manager.infoWindow.AddTextContent (f.Description()); // characterCustomization.manager.infoWindow.SetTitle(f.Name()); //this adds the features to the character. apply features shouldn't be called SelectFeatures(new List <GenericFeature> { lastChosen }); } }
public override void SyncUiWithCharacter(Sheet character) { Clear(); str = AddOptButton("Str:" + character.Strength + " " + ModifierValue("strength")); dex = AddOptButton("Dex:" + character.Dexterity + " " + ModifierValue("dexterity")); con = AddOptButton("Con:" + character.Constitution + " " + ModifierValue("constitution")); intl = AddOptButton("Int:" + character.Intelligence + " " + ModifierValue("intelligence")); wis = AddOptButton("Wis:" + character.Wisdom + " " + ModifierValue("wisdom")); cha = AddOptButton("Cha:" + character.Charisma + " " + ModifierValue("charisma")); str.SetTooltipInfo(Tooltip.TooltipPosition.LEFT, 15, "Strength\n" + ModifierValue("strength") + " to melee hit and damage roll\nCarry weight:" + character.CarryWeight, "Strength\nThe modifier, " + ModifierValue("strength") + ", affects all melee weapon hit rolls, and damage rolls (main hand only).\nWeight carried is 15 x Strength score of " + GaugeValue("strength")); dex.SetTooltipInfo(Tooltip.TooltipPosition.LEFT, 15, "Dexterity\n" + ModifierValue("dexterity") + " to ranged/finesse hit and damage roll\nAC bonus:" + ModifierValue("dexterity"), "Dexterity\nThe modifier, " + ModifierValue("dexterity") + ", affects all ranged weapon hit rolls, and damage rolls. The same applies to melee weapons that have the finesse property.\nAlso, affects Armour Class by the modifier; this is restricted at +2 when wearing medium armour, and completely when wearing heavy armour."); con.SetTooltipInfo(Tooltip.TooltipPosition.LEFT, 15, "Constitution\n" + ModifierValue("constitution") + " to hit points per level", "The modifier, " + ModifierValue("constitution") + " is multiplied by character level " + character.CharacterLevel); intl.SetTooltipInfo(Tooltip.TooltipPosition.LEFT, 15, "Intelligence\nWizards prepare more spells, and increase their effectiveness with them.", "Intelligence\nThe modifier, " + ModifierValue("intelligence") + " increases/decreases spells a wizard can have prepared in a day. The base value is the wizard level of the caster.\nThe modifier also affects spell hit rolls when called for, and make a cleric's spells harder to resist."); wis.SetTooltipInfo(Tooltip.TooltipPosition.LEFT, 15, "Wisdom\nClerics prepare more spells, and increase their effectiveness with them.", "Wisdom\nThe modifier, " + ModifierValue("wisdom") + " increases/decreases spells a cleric can have prepared in a day. The base value is the cleric level of the caster.\nThe modifier also affects spell hit rolls when called for, and make a wizard's spells harder to resist."); cha.SetTooltipInfo(Tooltip.TooltipPosition.LEFT, 15, "Charisma\nGain more favor with the crowd.", "Charisma\n(Long description needed)"); }
public virtual void Start() { OptButton opt = GetComponent <OptButton> (); opt.OnOptBeganDrag += BeganDragging; opt.OnOptDropped += DroppedItem; opt.OnOptEndedDrag += EndedDraggin; RefreshPanelSprite(); if (InventoryView.instance == null) { Debug.LogError("Inventory slot requires that there be an active " + typeof(InventoryView).ToString() + " singleton in the scene."); } if (EquipmentAnimationDispenser.instance == null) { Debug.LogError("Inventory slot requires that there be an active " + typeof(EquipmentAnimationDispenser).ToString() + " singleton in the scene."); } if (IconDispenser.instance == null) { Debug.LogError("Inventory slot requires that there be an active " + typeof(IconDispenser).ToString() + " singleton in the scene."); } }