private void CheckContradictingTriggers()
 {
     if (Triggers.Contains(TooltipTrigger.Click) && Triggers.Contains(TooltipTrigger.Focus))
     {
         throw new ArgumentException($"The tooltip has contradicting triggers, you cannot use the {nameof(TooltipTrigger.Focus)} and {nameof(TooltipTrigger.Click)} at the same time, choose one.");
     }
 }
 public async Task HandleFocusOut(FocusEventArgs args)
 {
     if (Triggers.Contains(TooltipTrigger.Focus) || Triggers.Contains(TooltipTrigger.Click))
     {
         await Hide();
     }
 }
Example #3
0
        public override void RunBehaviorTree()
        {
            if (Triggers.Contains(LocalTriggers.RESET))
            {
                ClearAllTasks();
                Triggers.ClearAll();
                return;
            }

            if (Triggers.Contains(LocalTriggers.INTERACT))                              // If tosser was ordered to interact with something...
            {
                ClearAllTasks();                                                        // ...clear all tasks...
                Target      = Triggers.Take(LocalTriggers.INTERACT) as Entity;          // ...find out what the target is...
                Destination = Target.Position;                                          // ...then set their destination to the target's position.
            }
            else if (Triggers.Contains(LocalTriggers.DROP_CURSOR))                      // If tosser was ordered to drop something instead...
            {
                DropCursor  = true;                                                     // ...let they know they're on their way to drop something...
                Destination = Triggers.Take <Vector2>(LocalTriggers.DROP_CURSOR);       // ... and set their destination to the clicked spot in the world.
            }
            else if (Triggers.Contains(LocalTriggers.WALK_MOUSE))                       // If tosser was ordered to just walk via mouse click instead...
            {
                ClearAllTasks();                                                        // ...clear all tasks...
                Destination = Triggers.Take <Vector2>(LocalTriggers.WALK_MOUSE);        // ...set their destination to the clicked spot in the world.
            }

            if (Destination != null)                                                    // If tosser has a set destination...
            {
                bool arrived = GoTo(Destination.Value);                                 // ...walk towards the destination.

                if (Target != null)                                                     // If tosser has an interaction target...
                {
                    if (Target.Interaction.IsInInteractingRange(Me))                    // ...if they are in range...
                    {
                        arrived = true;                                                 // ...if they are, tell them they arrived,
                        Target.Interaction.RunInteraction(Me);                          // run the interaction,
                        Target = null;                                                  // and clear the target as well.
                    }
                }
                else if (DropCursor)                                                    // If tosser has to drop something...
                {
                    if (Vector2.Distance(Me.Position, Destination.Value) <= 0.5f)       // ...if they're close enough...
                    {
                        arrived = true;                                                 // ...tell them they arrived,
                        UICursor.Cursor.DropAttachedEntity(Destination.Value);          // and drop the cursor entity.
                    }
                }

                if (arrived)                                                            // If tosser arrived at his destination...
                {
                    Destination = null;                                                 // ...clear it.
                }
            }
            else                                                                        // If there was no input or destination at all...
            {
                Stop();                                                                 // ...stop all movement
            }
        }
        public async Task HandleFocusIn(FocusEventArgs args)
        {
            if (!Triggers.Contains(TooltipTrigger.Focus))
            {
                return;
            }

            await Show();
        }
        public async Task HandleMouseLeave()
        {
            if (!Triggers.Contains(TooltipTrigger.Hover))
            {
                return;
            }

            await Hide();
        }
        public async Task HandleMouseEnter()
        {
            if (!Triggers.Contains(TooltipTrigger.Hover))
            {
                return;
            }

            await Show();
        }
Example #7
0
 public void Trigger(Event gameEvent, int positionInLinkIfTriggered)
 {
     ValidTargets.Clear();
     if (!AreaOfEffects.Contains(Card.Zone))
     {
         return;
     }
     if (Triggers.Count > 0 && !Triggers.Contains(gameEvent.Identity))
     {
         return;
     }
     Triggered      = _Trigger(gameEvent);
     PositionInLink = positionInLinkIfTriggered;
     History.Add(new Trigger(Card, Card, this));
 }
        public async Task HandleClick(MouseEventArgs args)
        {
            if (!Triggers.Contains(TooltipTrigger.Click))
            {
                return;
            }

            if (Visible)
            {
                await Hide();
            }
            else
            {
                await Show();
            }
        }
Example #9
0
        public void SetUp(Event gameEvent)
        {
            ValidTargets.Clear();
            if (!AreaOfEffects.Contains(Card.Zone))
            {
                return;
            }

            if (Triggers.Count > 0 && !Triggers.Contains(gameEvent.Identity))
            {
                return;
            }

            CanBeUsed = _SetUp();
            if (CanBeUsed && Card is Support)
            {
                Card.State = Card.States.CanBeActivated;
            }
        }
Example #10
0
        public override void RunBehaviorTree()
        {
            if (Me.IsChild)
            {
                return;
            }

            // Check if DG has been attacked
            if (Triggers.Contains("Agressor"))
            {
                // Forget current focus and remember the agressor
                ClearStatus();

                Aggressor = Triggers.Take <Entity>("Agressor");
                ResetTimer();
            }

            // If DG has an aggressor
            if (Aggressor != null)
            {
                // Execute combat routine
                CombatRoutine();
                return;
            }

            // If DG is hurt
            if (Me.Stats.Health.PercentAt < 0.7f)
            {
                // Execute healing routine
                HealingRoutine();
                return;
            }

            // If there's nothing else to do, execute looking for food routine
            LookForFoodRoutine();
        }
Example #11
0
 /// <summary>
 /// True if the given trigger's IP is for a trigger that
 /// is currently active, or is about to become active.
 /// </summary>
 /// <param name="trigger"></param>
 /// <returns></returns>
 public bool ContainsTrigger(TriggerInfo trigger)
 {
     return(Triggers.Contains(trigger) || TriggersToInsert.Contains(trigger));
 }
Example #12
0
 /// <summary>
 /// True if the given trigger's IP is for a trigger that
 /// is currently active, or is about to become active.
 /// </summary>
 /// <param name="instructionPointer"></param>
 /// <returns></returns>
 public bool ContainsTrigger(int instructionPointer)
 {
     return(Triggers.Contains(instructionPointer) || TriggersToInsert.Contains(instructionPointer));
 }