public bool IsSpellInRange(ActionSlot actionSlot) { var range = _boxMgr.GetBoxByName("actionbars-IsInRange_" + (int)actionSlot) .ToBool(); return(range); }
private void InitializeGui() { ActionSlot.Register(Engine.GuiLoader); InventorySlot.Register(Engine.GuiLoader); HealthBar.Register(Engine.GuiLoader); ProgressBar.Register(Engine.GuiLoader); }
/// <summary> /// Clicked a skill button.</summary> public void ClickedSkillButton(ActionSlot slot) { slot.SlotTriggered(); if (!slot.IsFree) { PlayerController.ItemTriggered((InventoryItem)slot._item.Data); } }
public void ToggleTargeting(ActionSlot slot) { if (SelectingTargetFor == slot) { StopTargeting(); return; } StartTargeting(slot); }
public bool IsSpellReady(ActionSlot actionSlot) { if (_boxMgr.GetBoxByName("actionbars-Cooldown_" + (int)actionSlot) .HasValue()) { return(false); } return(GetSpellRemainingCooldown(actionSlot) > 0); }
private void ParryAction(ActionSlot slot) { string targetAnimation = slot.AnimationName; Debug.Log(targetAnimation); if (!string.IsNullOrEmpty(targetAnimation)) { ani.SetBool("mirror", slot.Mirror); ani.CrossFade(targetAnimation, 0.3f); } }
public void CastSpell(ActionSlot actionSlot) { try { Player.Attack(actionSlot); } catch (Exception e) { Console.WriteLine(e); } }
public Spell GetSpell(ActionSlot actionSlot) { try { return(Player.SpellHandler.Spells[(int)actionSlot]); } catch (Exception e) { Console.WriteLine(e); } return(null); }
private void DetectAction() { if (lt == false && lb == false && rt == false && rb == false) { return; } if (!canMove || usingItem || rolling) { return; } ActionSlot slot = null; if (lt) { slot = actionManager.GetActionSlot(ActionInputType.LT); } if (lb) { slot = actionManager.GetActionSlot(ActionInputType.LB); } if (rt) { slot = actionManager.GetActionSlot(ActionInputType.RT); } if (rb) { slot = actionManager.GetActionSlot(ActionInputType.RB); } if (slot == null) { return; } switch (slot.ActionType) { case ActionType.Attack: this.AttackAction(slot); break; case ActionType.Blocking: this.BlockAction(slot); break; case ActionType.Parry: this.ParryAction(slot); break; } }
public ActionBarItem(string item, KeyBindSender keyBindSender, ActionsReader actionsReader) { _keyBindSender = keyBindSender; _actionsReader = actionsReader; var data = item.Split(';'); ActionSlot = (ActionSlot)int.Parse(data[0]); SpellName = data[1]; SpellId = int.Parse(data[2]); SpellCost = data.Length < 4 ? 0 : int.Parse(data[3]); _keyBinding = (KeyBinding)Enum.Parse(typeof(KeyBinding), ActionSlot.ToString(), true); }
private void StartTargeting(ActionSlot actionSlot) { // If we were targeting something else we should stop StopTargeting(); SelectingTargetFor = actionSlot; // show it as toggled on to indicate we are currently selecting a target for it if (!actionSlot.ToggledOn) { actionSlot.ToggledOn = true; } }
private void UpdateActionSlot(ItemActionType itemlessActionType, ActionSlot actionSlot, ActionAssignment?assignedActionType) { if (_actionManager.TryGet(itemlessActionType, out var action)) { actionSlot.Assign(action); } else { Logger.ErrorS("action", "unrecognized actionType {0}", assignedActionType); actionSlot.Clear(); } actionSlot.Cooldown = null; }
public void UpdateLeftActionSlot(Weapon leftWeapon) { ActionSlot LTSlot = this.GetActionSlot(ActionInputType.LT); WeaponAction lw_lt = leftWeapon.GetAction(ActionInputType.LT); LTSlot.AnimationName = lw_lt.AniName; LTSlot.Mirror = lw_lt.Mirror; LTSlot.ActionType = lw_lt.ActionType; ActionSlot LBSlot = this.GetActionSlot(ActionInputType.LB); WeaponAction lw_lb = leftWeapon.GetAction(ActionInputType.LB); LBSlot.AnimationName = lw_lb.AniName; LBSlot.Mirror = lw_lb.Mirror; LBSlot.ActionType = lw_lb.ActionType; }
public void UpdateRightActionSlot(Weapon rightWeapon) { ActionSlot RTSlot = this.GetActionSlot(ActionInputType.RT); WeaponAction rw_rt = rightWeapon.GetAction(ActionInputType.RT); RTSlot.AnimationName = rw_rt.AniName; RTSlot.Mirror = rw_rt.Mirror; RTSlot.ActionType = rw_rt.ActionType; ActionSlot RBSlot = this.GetActionSlot(ActionInputType.RB); WeaponAction rw_rb = rightWeapon.GetAction(ActionInputType.RB); RBSlot.AnimationName = rw_rb.AniName; RBSlot.Mirror = rw_rb.Mirror; RBSlot.ActionType = rw_rb.ActionType; }
private void UpdateActionSlot(ActionType actionType, ActionSlot actionSlot, ActionAssignment?assignedActionType) { if (_actionManager.TryGet(actionType, out var action)) { actionSlot.Assign(action, true); } else { Logger.ErrorS("action", "unrecognized actionType {0}", assignedActionType); actionSlot.Clear(); return; } if (!_actionsComponent.TryGetActionState(actionType, out var actionState) || !actionState.Enabled) { // action is currently disabled // just revoked an action we were trying to target with, stop targeting if (SelectingTargetFor?.Action != null && SelectingTargetFor.Action == action) { StopTargeting(); } actionSlot.DisableAction(); actionSlot.Cooldown = null; } else { // action is currently granted actionSlot.EnableAction(); actionSlot.Cooldown = actionState.Cooldown; // if we are targeting for this action and it's now on cooldown, stop targeting if we're supposed to if (SelectingTargetFor?.Action != null && SelectingTargetFor.Action == action && actionState.IsOnCooldown(_gameTiming) && action.DeselectOnCooldown) { StopTargeting(); } } // check if we need to toggle it if (action.BehaviorType == BehaviorType.Toggle) { actionSlot.ToggledOn = actionState.ToggledOn; } }
private void UpdateActionSlot(EntityUid item, ItemActionType itemActionType, ActionSlot actionSlot, ActionAssignment?assignedActionType) { if (!_entityManager.TryGetEntity(item, out var itemEntity)) { return; } if (_actionManager.TryGet(itemActionType, out var action)) { actionSlot.Assign(action, itemEntity, true); } else { Logger.ErrorS("action", "unrecognized actionType {0}", assignedActionType); actionSlot.Clear(); return; } if (!_actionsComponent.TryGetItemActionState(itemActionType, item, out var actionState)) { // action is no longer tied to an item, this should never happen as we // check this at the start of this method. But just to be safe // we will restore our assignment here to the correct state Logger.ErrorS("action", "coding error, expected actionType {0} to have" + " a state but it didn't", assignedActionType); _actionsComponent.Assignments.AssignSlot(SelectedHotbar, actionSlot.SlotIndex, ActionAssignment.For(itemActionType)); actionSlot.Assign(action); return; } if (!actionState.Enabled) { // just disabled an action we were trying to target with, stop targeting if (SelectingTargetFor?.Action != null && SelectingTargetFor.Action == action) { StopTargeting(); } actionSlot.DisableAction(); } else { // action is currently granted actionSlot.EnableAction(); // if we are targeting with an action now on cooldown, stop targeting if we should if (SelectingTargetFor?.Action != null && SelectingTargetFor.Action == action && SelectingTargetFor.Item == itemEntity && actionState.IsOnCooldown(_gameTiming) && action.DeselectOnCooldown) { StopTargeting(); } } actionSlot.Cooldown = actionState.Cooldown; // check if we need to toggle it if (action.BehaviorType == BehaviorType.Toggle) { actionSlot.ToggledOn = actionState.ToggledOn; } }
public double GetSpellRemainingCooldown(ActionSlot actionSlot) { return(_boxMgr.GetBoxByName("actionbars-Cooldown_" + (int)actionSlot).ToInt()); }
public ActionWaitForAction(ICurio curio, ActionSlot slot) { Origin = curio; Slot = slot; }
public static ActionWrapper InSlot(this IAction action, ActionSlot slot) { return(new ActionWrapper(action, slot)); }
public Cooldown GetPlayerCooldown(ActionSlot actionSlot) { Type t = Player.AttackMap[actionSlot]().GetType(); return(Player.SpellHandler.Cooldowns[t]); }
public ActionsUI(ClientActionsComponent actionsComponent) { _actionsComponent = actionsComponent; _actionManager = IoCManager.Resolve <ActionManager>(); _entityManager = IoCManager.Resolve <IEntityManager>(); _gameTiming = IoCManager.Resolve <IGameTiming>(); _gameHud = IoCManager.Resolve <IGameHud>(); _menu = new ActionMenu(_actionsComponent, this); LayoutContainer.SetGrowHorizontal(this, LayoutContainer.GrowDirection.End); LayoutContainer.SetGrowVertical(this, LayoutContainer.GrowDirection.End); LayoutContainer.SetAnchorTop(this, 0f); LayoutContainer.SetAnchorBottom(this, 0.8f); LayoutContainer.SetMarginLeft(this, 13); LayoutContainer.SetMarginTop(this, 110); SizeFlagsHorizontal = SizeFlags.None; SizeFlagsVertical = SizeFlags.FillExpand; var resourceCache = IoCManager.Resolve <IResourceCache>(); // everything needs to go within an inner panel container so the panel resizes to fit the elements. // Because ActionsUI is being anchored by layoutcontainer, the hotbar backing would appear too tall // if ActionsUI was the panel container var panelContainer = new PanelContainer() { StyleClasses = { StyleNano.StyleClassHotbarPanel }, SizeFlagsHorizontal = SizeFlags.None, SizeFlagsVertical = SizeFlags.None }; AddChild(panelContainer); var hotbarContainer = new VBoxContainer { SeparationOverride = 3, SizeFlagsHorizontal = SizeFlags.None }; panelContainer.AddChild(hotbarContainer); var settingsContainer = new HBoxContainer { SizeFlagsHorizontal = SizeFlags.FillExpand }; hotbarContainer.AddChild(settingsContainer); settingsContainer.AddChild(new Control { SizeFlagsHorizontal = SizeFlags.FillExpand, SizeFlagsStretchRatio = 1 }); _lockTexture = resourceCache.GetTexture("/Textures/Interface/Nano/lock.svg.192dpi.png"); _unlockTexture = resourceCache.GetTexture("/Textures/Interface/Nano/lock_open.svg.192dpi.png"); _lockButton = new TextureButton { TextureNormal = _unlockTexture, SizeFlagsHorizontal = SizeFlags.ShrinkCenter, SizeFlagsVertical = SizeFlags.ShrinkCenter, SizeFlagsStretchRatio = 1, Scale = (0.5f, 0.5f) }; settingsContainer.AddChild(_lockButton); settingsContainer.AddChild(new Control { SizeFlagsHorizontal = SizeFlags.FillExpand, SizeFlagsStretchRatio = 2 }); _settingsButton = new TextureButton { TextureNormal = resourceCache.GetTexture("/Textures/Interface/Nano/gear.svg.192dpi.png"), SizeFlagsHorizontal = SizeFlags.ShrinkCenter, SizeFlagsVertical = SizeFlags.ShrinkCenter, SizeFlagsStretchRatio = 1, Scale = (0.5f, 0.5f) }; settingsContainer.AddChild(_settingsButton); settingsContainer.AddChild(new Control { SizeFlagsHorizontal = SizeFlags.FillExpand, SizeFlagsStretchRatio = 1 }); // this allows a 2 column layout if window gets too small _slotContainer = new GridContainer { MaxHeight = CalcMaxHeight() }; hotbarContainer.AddChild(_slotContainer); _loadoutContainer = new HBoxContainer { SizeFlagsHorizontal = SizeFlags.FillExpand, MouseFilter = MouseFilterMode.Stop }; hotbarContainer.AddChild(_loadoutContainer); _loadoutContainer.AddChild(new Control { SizeFlagsHorizontal = SizeFlags.FillExpand, SizeFlagsStretchRatio = 1 }); var previousHotbarIcon = new TextureRect() { Texture = resourceCache.GetTexture("/Textures/Interface/Nano/left_arrow.svg.192dpi.png"), SizeFlagsHorizontal = SizeFlags.ShrinkCenter, SizeFlagsVertical = SizeFlags.ShrinkCenter, SizeFlagsStretchRatio = 1, TextureScale = (0.5f, 0.5f) }; _loadoutContainer.AddChild(previousHotbarIcon); _loadoutContainer.AddChild(new Control { SizeFlagsHorizontal = SizeFlags.FillExpand, SizeFlagsStretchRatio = 2 }); _loadoutNumber = new Label { Text = "1", SizeFlagsStretchRatio = 1 }; _loadoutContainer.AddChild(_loadoutNumber); _loadoutContainer.AddChild(new Control { SizeFlagsHorizontal = SizeFlags.FillExpand, SizeFlagsStretchRatio = 2 }); var nextHotbarIcon = new TextureRect { Texture = resourceCache.GetTexture("/Textures/Interface/Nano/right_arrow.svg.192dpi.png"), SizeFlagsHorizontal = SizeFlags.ShrinkCenter, SizeFlagsVertical = SizeFlags.ShrinkCenter, SizeFlagsStretchRatio = 1, TextureScale = (0.5f, 0.5f) }; _loadoutContainer.AddChild(nextHotbarIcon); _loadoutContainer.AddChild(new Control { SizeFlagsHorizontal = SizeFlags.FillExpand, SizeFlagsStretchRatio = 1 }); _slots = new ActionSlot[ClientActionsComponent.Slots]; _dragShadow = new TextureRect { CustomMinimumSize = (64, 64), Stretch = TextureRect.StretchMode.Scale, Visible = false }; UserInterfaceManager.PopupRoot.AddChild(_dragShadow); LayoutContainer.SetSize(_dragShadow, (64, 64)); for (byte i = 0; i < ClientActionsComponent.Slots; i++) { var slot = new ActionSlot(this, _menu, actionsComponent, i); _slotContainer.AddChild(slot); _slots[i] = slot; } DragDropHelper = new DragDropHelper <ActionSlot>(OnBeginActionDrag, OnContinueActionDrag, OnEndActionDrag); }
/// <summary> /// Adds a new single action to the list of actions. If this exceeds the maximum /// number of concurrent actions, don't add it and throw a warning. /// </summary> /// <param name="slot">Single action to be added</param> public void AddActionSlot(ActionSlot slot) { if (currentSlots.Count < cMaxSlots) { currentSlots.Add(slot); Console.WriteLine("[WorldDirector INFO]: Adding " + slot.Action.ToString() + " to list."); slot.Complete += SlotHandler; } else { Console.WriteLine("[WorldDirector WARNING]: Cannot add another action slot. Currently full."); } }
public BehaviorActionHolder(Curio curio, ActionSlot type) { Curio = curio; Type = type; }
public ActionWrapper(IAction action, ActionSlot slot) { Slot = slot; Action = action; }
public Cooldown GetPlayerCooldown(ActionSlot actionSlot) { Type t = Player.AttackMap[actionSlot]().GetType(); return Player.SpellHandler.Cooldowns[t]; }
public void Attack(ActionSlot actionSlot) { SpellHandler.Cast(AttackMap[actionSlot]()); }
public string GetSpellName(ActionSlot actionSlot) { return(ActionBarItems.First(s => s.ActionSlot == actionSlot).SpellName); }
private void BlockAction(ActionSlot slot) { blocking = true; ani.SetBool("leftshield", slot.Mirror); }
public Spell GetSpell(ActionSlot actionSlot) { try { return Player.SpellHandler.Spells[(int)actionSlot]; } catch (Exception e) { Console.WriteLine(e); } return null; }
private void DrawActionSlot(Rect rFrame, Rect rIcon, ActionSlot s, int slot) { if (s == null) { GUI.Box(rFrame, GUIContent.none, gui.ActionIconEmpty); return; } if (s.IsEmpty) { GUI.Box(rFrame, GUIContent.none, gui.ActionIconEmpty); return; } // icon if (GUI.Button(rIcon, s.GetIcon(0, gui.txNoIcon), gui.ActionIconButton)) { // right mouse button is used to remove something from the slot if (Input.GetMouseButtonUp(1)) { UniRPGGlobal.Player.Actor.ClearActionSlot(slot); } else { UniRPGGlobal.Player.Actor.UseActionSlot(slot, (UniRPGGlobal.Player.TargetInteract == null ? null : UniRPGGlobal.Player.TargetInteract.gameObject)); } } // Cool down GFX if (s.IsSkill) { if (s.Skill.cooldownTimer > 0.0f && gui.txCooldown != null) { if (gui.showSkillCooldown) { int idx = Mathf.RoundToInt(gui.txCooldown.Count / s.Skill.cooldownTimeSetting * s.Skill.cooldownTimer) - 1; if (idx >= 0) GUI.DrawTexture(rIcon, gui.txCooldown[idx]); // fixme, add the cooldown number too? GUI.Label(rIcon, s.cooldownTimer.ToString("F1")); } } // invalid/out-of-range skill else if (gui.showWhenCantUseSkill) { if (!UniRPGGlobal.Player.IsSkillTargetInRange(s.Skill)) GUI.DrawTexture(rIcon, gui.txInvalid); } // Queue GFX if (gui.showSkillQueued && s.Skill == UniRPGGlobal.Player.Actor.nextSkill && queuedSkillShow) { GUI.DrawTexture(rIcon, gui.txQueued); } } // Frame GUI.Box(rFrame, GUIContent.none, gui.ActionIconFrame); }
public static BehaviorActionHolder GetActionHolder(this ICurio curio, ActionSlot type) { return(curio.GetBehaviors <BehaviorActionHolder>().FirstOrDefault(x => x.Type == type)); }