Beispiel #1
0
    IEnumerator GameSetup()
    {
        yield return(new WaitForSeconds(1.0f));

        Drop.Invoke();
        Drop.Invoke();
    }
Beispiel #2
0
 void Update()
 {
     if (Input.GetButtonDown("Left") && 1 < playerPos)
     {
         Move.Invoke(--playerPos);
     }
     if (Input.GetButtonDown("Right") && playerPos < 5)
     {
         Move.Invoke(++playerPos);
     }
     if (Input.GetButtonDown("Capture"))
     {
         Manipulate.Invoke();
     }
     if (Input.GetButtonDown("Drop"))
     {
         Drop.Invoke();
         dropTimer = 0f;
     }
     dropTimer += Time.deltaTime;
     if (spawnRateMs <= dropTimer)
     {
         Drop.Invoke();
         dropTimer = 0f;
     }
 }
Beispiel #3
0
 public virtual void RegisterEventHandlersForTerminal(ITerminal terminal)
 {
     terminal.OutgoingCall += (sender, arg) =>
     {
         State = PortState.Busy;
         OutgoingCall?.Invoke(this, arg);
         Console.WriteLine(arg.SourceNumber + " is calling " + arg.TargetNumber);
     };
     terminal.IncomingCall += (sender, arg) =>
     {
         State = PortState.Busy;
         terminal.CallEventArgs = arg;
         Console.WriteLine(arg.SourceNumber + " is calling " + arg.TargetNumber);
     };
     terminal.Answer += (sender, arg) =>
     {
         Console.WriteLine(arg.TargetNumber + " answered " + arg.SourceNumber);
         Answer?.Invoke(this, arg);
     };
     terminal.Drop += (sender, arg) =>
     {
         State = PortState.Free;
         Drop?.Invoke(this, arg);
     };
     this.IncomingCall += (sender, arg) =>
     {
         terminal.IncomingCallFromPort(arg);
     };
 }
 protected void RaiseDrop(object sender, object drop)
 {
     if (Drop != null)
     {
         Drop.Invoke(sender, new DragDropArgs(drop));
     }
 }
Beispiel #5
0
        public void PhoneEventsInit(IPhone phone)
        {
            phone.IncomingCall += (sender, args) =>
            {
                State            = PortState.Call;
                phone.Connection = args;
            };

            phone.OutgoingCall += (sender, args) =>
            {
                State = PortState.Call;
                Call?.Invoke(this, args);
            };

            phone.Answer += (sender, args) =>
            {
                Answer?.Invoke(this, args);
            };

            phone.Drop += (sender, args) =>
            {
                State = PortState.Busy;
                Drop?.Invoke(this, args);
            };

            this.IncomingCall += (sender, args) =>
            {
                phone.GetIncomingCall(args);
            };
        }
Beispiel #6
0
        public void RemoveItemFromInventory_GivenCarried()
        {
            // Arrange
            var inventory = new Inventory();

            var fakePlayer = A.Fake <IAdventurePlayer>();

            A.CallTo(() => fakePlayer.Inventory).Returns(inventory);

            var fakeGame = A.Fake <IReadonlyAdventureGame>();
            var fakeFood = A.Fake <IAdventureItem>();

            A.CallTo(() => fakeFood.ItemId).Returns(Item.FoodRation);
            A.CallTo(() => fakeFood.Nouns).Returns(new List <string> {
                "food"
            });
            A.CallTo(() => fakeFood.IsPortable).Returns(true);
            A.CallTo(() => fakeFood.IsMatch("food")).Returns(true);
            inventory.AddItem(fakeFood);

            var args = new ChatCommandEventArgs("!adv", new List <string> {
                "drop", "food"
            }, string.Empty, "Bill", "Player1", string.Empty);

            // Act
            var cmd = new Drop(fakeGame, "drop");

            cmd.Invoke(fakePlayer, args);

            // Assert
            Assert.IsFalse(inventory.Has(Item.FoodRation));
        }
Beispiel #7
0
        private void ListViewOnDrop(object sender, DragEventArgs e)
        {
            _listView.Drop -= ListViewOnDragOver;
            _listView.Drop -= ListViewOnDrop;

            var items = (List <string>)e.Data.Properties["items"];

            Drop?.Invoke(items);
        }
Beispiel #8
0
        public async Task SendDrop(DropEventArgs args)
        {
            if (!AllowDrop)
            {
                return;
            }

            DropCommand?.Execute(DropCommandParameter);
            Drop?.Invoke(this, args);

            if (!args.Handled)
            {
                var         dataView           = args.Data;
                var         internalProperties = dataView.PropertiesInternal;
                IView       dragSource         = null;
                ImageSource sourceTarget       = await dataView.GetImageAsync();

                string text = await dataView.GetTextAsync();

                if (internalProperties.ContainsKey("DragSource"))
                {
                    dragSource = (IView)internalProperties["DragSource"];
                    if (sourceTarget == null && dragSource is IImageElement imageElement)
                    {
                        sourceTarget = imageElement.Source;
                    }

                    if (String.IsNullOrWhiteSpace(text))
                    {
                        text = dragSource.GetStringValue();
                    }
                }

                if (Parent is IImageElement && sourceTarget == null)
                {
                    sourceTarget = text;
                }

                if (Parent is Image image)
                {
                    image.Source = sourceTarget;
                }
                else if (Parent is ImageButton ib)
                {
                    ib.Source = sourceTarget;
                }
                else if (Parent is Button b)
                {
                    b.ImageSource = sourceTarget;
                }

                Parent?.TrySetValue(text);
            }
        }
Beispiel #9
0
        public void TryRelease()
        {
            if (HeldGrabbable != null && HeldGrabbable.CanBeDropped)
            {
                GrabbableEventArgs args = new GrabbableEventArgs(HeldGrabbable.GetComponent <Grabbable>(), this);
                HeldGrabbable.DropItem(this);
                Drop?.Invoke(args);
            }

            // No longer try to bring flying grabbable to us
            resetFlyingGrabbable();
        }
Beispiel #10
0
        public void RemoveItemFromInventory_GivenContainedItem()
        {
            // Arrange
            var inventory = new Inventory();

            var fakePlayer = A.Fake <IAdventurePlayer>();

            A.CallTo(() => fakePlayer.Inventory).Returns(inventory);

            var fakeGame = A.Fake <IReadonlyAdventureGame>();
            var fakeCage = A.Fake <IAdventureItem>();

            A.CallTo(() => fakeCage.ItemId).Returns(Item.Cage);
            A.CallTo(() => fakeCage.Nouns).Returns(new List <string> {
                "cage"
            });
            A.CallTo(() => fakeCage.IsPortable).Returns(true);
            A.CallTo(() => fakeCage.IsMatch("cage")).Returns(true);
            A.CallTo(() => fakeCage.IsContainer).Returns(true);
            A.CallTo(() => fakeCage.Contents).Returns(new List <IAdventureItem>());

            var fakeBird = A.Fake <IAdventureItem>();

            A.CallTo(() => fakeBird.ItemId).Returns(Item.Bird);
            A.CallTo(() => fakeBird.Nouns).Returns(new List <string> {
                "bird"
            });
            A.CallTo(() => fakeBird.IsPortable).Returns(true);
            A.CallTo(() => fakeBird.IsMatch("bird")).Returns(true);
            A.CallTo(() => fakeBird.ContainerRequired()).Returns(true);
            A.CallTo(() => fakeBird.MustBeContainedIn).Returns(Item.Cage);

            inventory.AddItem(fakeCage);

            fakeCage.Contents.Add(fakeBird);
            inventory.AddItem(fakeCage);

            var args = new ChatCommandEventArgs("!adv", new List <string> {
                "drop", "bird"
            }, string.Empty, "Bill", "Player1", string.Empty);

            // Act
            var cmd = new Drop(fakeGame, "drop");

            cmd.Invoke(fakePlayer, args);

            // Assert
            Assert.IsFalse(inventory.Has(Item.Bird));
            Assert.IsTrue(inventory.Has(Item.Cage));
        }
Beispiel #11
0
        public TodoControl(Todo todo, bool isDragEnabled)
        {
            this.Todo    = todo;
            this.Content = todo;

            this.Loaded += (s, e) =>
            {
                //Gets the DataTemplate defined for the Todo objects.
                var template = this.ContentTemplate;

                //Looks for an ExtendedRichTextBox with an x:Name="rtb" attribute from the logical children of the generated ContentPresenter which has the DataTemplate applied to it.
                if (VisualTreeHelper.GetChildrenCount(this) == 0)
                {
                    return;
                }

                var rtb = (ExtendedRichTextBox)template?.FindName("rtb", (FrameworkElement)VisualTreeHelper.GetChild(this, 0));

                if (rtb == null)
                {
                    return;
                }

                extendedRTB = rtb;

                //If an ExtendedRichTextBox is found, hooks to the BackspacePressedWhileEmpty event.
                rtb.BackspacePressedWithAltShiftModifiers += (o, a) =>
                {
                    this.BackspacePressedWithAltShiftModifiers?.Invoke(this, new RoutedEventArgs());
                };

                rtb.TextChanged += (o, a) =>
                {
                    TextChanged?.Invoke(o, a);
                };

                rtb.Drop += (o, a) =>
                {
                    Drop?.Invoke(o, a);
                };
            };

            this.IsDragEnabled = isDragEnabled;
        }
Beispiel #12
0
        internal protected void RaiseDragEvent(string ev, DragEventArgs e)
        {
            switch (ev)
            {
            case "DragEnter":
                DragEnter?.Invoke(this, e);
                break;

            case "DragOver":
                DragOver?.Invoke(this, e);
                break;

            case "DragLeave":
                DragLeave?.Invoke(this, e);
                break;

            case "Drop":
                Drop?.Invoke(this, e);
                break;

            case "PreviewDragEnter":
                PreviewDragEnter?.Invoke(this, e);
                break;

            case "PreviewDragOver":
                PreviewDragOver?.Invoke(this, e);
                break;

            case "PreviewDragLeave":
                PreviewDragLeave?.Invoke(this, e);
                break;

            case "PreviewDrop":
                PreviewDrop?.Invoke(this, e);
                break;

            default:
                break;
            }
        }
Beispiel #13
0
 public void Destroy(GameObject gameObject)
 {
     Drop?.Invoke(this, new RemoveGameObjectEventArgs(gameObject));
 }
Beispiel #14
0
 protected void OnDrop(object sender, EventArgs args)
 {
     Drop?.Invoke(this, args);
 }
        private void RegisterStates()
        {
            mStateMachin = new StateMachin();

            mStateMachin.RegisterState(MousToken.Pickup, new MousState[] { MousState.Normal }, MousState.PickedUp, delegate { PickUp?.Invoke(); mTarget.SetTocken(BugToken.PickUp); });
            mStateMachin.RegisterState(MousToken.Drop, new MousState[] { MousState.PickedUp }, MousState.Normal, delegate { Drop?.Invoke(); mTarget.SetTocken(BugToken.Drop); });
            mStateMachin.RegisterState(MousToken.DeletBug, new MousState[] { MousState.PickedUp }, MousState.Normal, delegate { mTarget = null; });
            mStateMachin.RegisterState(MousToken.EnterInfo, new MousState[] { MousState.PickedUp }, MousState.OverInfo, null);
            mStateMachin.RegisterState(MousToken.ExitInfo, new MousState[] { MousState.OverInfo }, MousState.PickedUp, null);
            mStateMachin.RegisterState(MousToken.InfoClick, new MousState[] { MousState.OverInfo }, MousState.Scaning, delegate { OpenScan?.Invoke(); mTarget.SetTocken(BugToken.OpenScan); });
            mStateMachin.RegisterState(MousToken.InfoClick, new MousState[] { MousState.Scaning }, MousState.PickedUp, delegate { CloseScan?.Invoke(); mTarget.SetTocken(BugToken.CloseScan); });
        }
Beispiel #16
0
 public void DropItem()
 {
     Drop?.Invoke();
 }
Beispiel #17
0
 protected virtual void OnDrop(object?sender, DragEventArgs e)
 => Drop?.Invoke(sender, e);
Beispiel #18
0
 protected virtual void OnDrop(object sender, CallEventArgs args)
 {
     Drop?.Invoke(sender, args);
 }