Example #1
0
    public void Step()
    {
        if (toggledOn && hasRock)
        {
            hasRock = false;
            Vector2 nextPosition = transform.position + transform.up;
            Rock.transform.position = nextPosition;

            Collider2D collide = Physics2D.OverlapPoint(nextPosition);
            if (collide == null)
            {
                Rock.SendMessage("SetSolid", true);
            }
            else
            {
                IDroppable droppable = collide.GetComponent(typeof(IDroppable)) as IDroppable;
                if (droppable != null && droppable.CanDrop())
                {
                    StepManager.OnEndOfStep += () => DropLate(droppable);
                }
                else
                {
                    Game.Fail();
                }
            }
        }
    }
Example #2
0
    private void DropStep()
    {
        if (!isDropping)
        {
            return;
        }
        isDropping = true;

        Collider2D collide = Physics2D.OverlapPoint(stepState.DropTarget);

        isHolding = false;

        if (collide == null)
        {
            Rock.SendMessage("SetSolid", true);
        }
        else
        {
            IDroppable droppable = collide.GetComponent(typeof(IDroppable)) as IDroppable;
            if (droppable != null)
            {
                StepManager.OnEndOfStep += (Action)(() =>
                {
                    GameObject.Destroy(Rock.gameObject);
                    droppable.OnDrop();
                });
            }
            else
            {
                Game.Fail();
            }
        }
    }
Example #3
0
 public void Drop(IDroppable item)
 {
     if (item is ItemSlot)
     {
         ItemSlot slot = (ItemSlot)item;
         if (slot.Item != null && this.Item != null)
         {
             switch (slot.SlotType)
             {
             case ItemSlotType.Item:
             case ItemSlotType.Equipment:
                 // Find an open slot and drop the item.
                 if (slot.EquipmentSlot != EquipmentSlot.None && slot.Item.Properties.GetValue <bool>("IsEquipped"))
                 {
                     // Unequip the item.
                     slot.Item.OwnerID = this.Item.ID;
                     slot.Item.Properties.SetValue("IsEquipped", false);
                     ServerManager.Instance.SendCommand(new RdlCommand("UNEQUIP", slot.Item.ID, slot.EquipmentSlot, this.Item.ID));
                 }
                 else
                 {
                     ServerManager.Instance.SendCommand(new RdlCommand("GIVE", slot.Item.ID, this.Item.ID, 1));
                 }
                 break;
             }
         }
     }
 }
Example #4
0
        /// <summary>
        /// Begins a drag operation for the specified IDroppable instance starting at the specified mousePosition.
        /// </summary>
        /// <param name="droppable">The IDroppable instance to being dragging.</param>
        /// <param name="mousePosition">The Point at which the drag operation will begin.</param>
        public void BeginDrag(IDroppable droppable, Point mousePosition)
        {
            if (droppable != null && this.Host != null)
            {
                Logger.LogDebug("Begin Drag: X={0}, Y={1}", mousePosition.X, mousePosition.Y);
                this.Item = droppable;

                this.DragCursor                   = droppable.GetDragCursor();
                this.DragCursor.LostFocus        += new RoutedEventHandler(OnDragCursorLostFocus);
                this.DragCursor.LostMouseCapture += new MouseEventHandler(OnDragCursorLostMouseCapture);

                // Add the drag cursor to the host control and set the z-index very high.
                this.DragCursor.SetValue(Canvas.ZIndexProperty, 5000);
                this.Host.Children.Add(this.DragCursor);
                this.Host.Cursor = Cursors.Hand;

                this.MousePosition = mousePosition;
                this.DragCursor.SetValue(Canvas.LeftProperty, this.MousePosition.X);
                this.DragCursor.SetValue(Canvas.TopProperty, this.MousePosition.Y);
                this.DragCursor.Visibility = Visibility.Visible;

                this.HasProcessedEndDrag = false;

                this.DragCursor.CaptureMouse();

                this.DragCursor.MouseLeftButtonUp += new MouseButtonEventHandler(OnDragCursorMouseLeftButtonUp);
                this.DragCursor.MouseMove         += new MouseEventHandler(OnDragCursorMouseMove);
            }
        }
 public void Drop(IDroppable item)
 {
     if (item is ItemListItem)
     {
         RdlActor actor = (item as ItemListItem).Actor;
         if (actor.Properties.GetValue <ObjectType>("ObjectType") == ObjectType.Quest)
         {
             QuestFacilitatorDialog diag = new QuestFacilitatorDialog();
             diag.Tag = actor;
             diag.QuestFacilitatorTypeSelected += new QuestFacilitatorTypeSelectedEventHandler(diag_QuestFacilitatorTypeSelected);
             PopupManager.Add(diag, new Point(354, 57));                     // Admin screen position.
         }
         else
         {
             actor.OwnerID = this.Actor.ID;
             this.ActorDrop(this, new ActorEventArgs {
                 Actor = actor
             });
             //// Args:
             //// 0 = Item
             //// 1 = Target
             //ServerManager.Instance.SendCommand("ADMINDROPITEM", actor.Name, this.Actor.ID);
         }
     }
 }
 public void Drop(IDroppable item)
 {
     if (item is ItemSlot)
     {
         ItemSlot slot = (ItemSlot)item;
         if (slot.Item != null)
         {
             switch (slot.SlotType)
             {
             case ItemSlotType.Item:
             case ItemSlotType.Equipment:
                 // If the destination item is not of equipLocation spell then it can not be dropped here.
                 if (!slot.Item.Properties.GetValue <string>("EquipLocation").Equals(EquipLocation.Spell.ToString(), StringComparison.InvariantCultureIgnoreCase))
                 {
                     // Can not drop this item in the spellbook, it is not a spell.
                     MessageBox.Show("You can not drop this item here, it is not a Spell!", "Invalid Spellbook Item", MessageBoxButton.OK);
                 }
                 else
                 {
                     slot.Item.Properties.SetValue("IsEquipped", true);
                     ServerManager.Instance.SendCommand(new RdlCommand("EQUIP", slot.Item.ID, EquipmentSlot.None));
                 }
                 break;
             }
         }
     }
 }
Example #7
0
        private bool DropCard(StateController controller)
        {
            bool DropResult = false;

            RaycastHit2D[] hitAll;
            IDroppable     dropTarget = null;

            hitAll = Physics2D.RaycastAll(controller.transform.position, Vector2.zero, 20);
            foreach (RaycastHit2D hit in hitAll)
            {
                dropTarget = hit.collider.GetComponent <IDroppable>();
                if (dropTarget != null)
                {
                    DropResult = CheckDropResult(controller, dropTarget);
                    if (DropResult)
                    {
                        break;
                    }
                }
            }
            if (DropResult)
            {
                ActivateParent(controller);
                dropTarget.DoDrop(controller.GetComponent <CardGameObject>());
            }
            return(DropResult);
        }
Example #8
0
 void RemoveFromUpdateAndPlaceholders(IDroppable droppa)
 {
     RemoveFromUpdate();
     if (placeholders.Remove(droppa.GetLinkedPlaceholder()) == false)
     {
         throw new InvalidOperationException("Cannote remove the droppale");
     }
 }
Example #9
0
 public void Drop(IDroppable item)
 {
     if (item is IActorListItem)
     {
         this.ActorDrop(this, new ActorEventArgs {
             Actor = (item as IActorListItem).Actor
         });
     }
 }
        public virtual void Add(IDroppable entry, double weight)
        {
            if (entry == null)
            {
                throw new ArgumentNullException();
            }

            this.Add(entry, weight, entry.GuaranteedDrop);
        }
Example #11
0
 public void RemoveDraggables()
 {
     dragOnly = true;
     if (droppable != null)
     {
         droppable.StopDrag();
         droppable = null;
     }
 }
Example #12
0
 public void Drop(IDroppable item)
 {
     if (item is IActorListItem)
     {
         Logger.LogDebug("Dropped IActorListItem onto tile...");
         this.ActorDrop(this, new ActorEventArgs {
             Actor = (item as IActorListItem).Actor
         });
     }
 }
Example #13
0
 public void StopDragging(IDroppable droppable)
 {
     objectFlying = false;
     if (this.droppable == droppable && droppable != null)
     {
         audioManager.PlaySound(Sfx.UIPopup);
         RemoveFromUpdate();
         MoveStuffToPosition();
     }
 }
Example #14
0
        // ALL NEEDED EVENTS ARE HERE
        public void StartDragging(IDroppable droppable)
        {
            if (this.droppable != null)
            {
                return;
            }

            audioManager.PlaySound(Sfx.UIPopup);
            this.droppable = droppable;
            droppable.StartDrag(x => RemoveFromUpdateAndPlaceholders(x));
        }
Example #15
0
        public void Dispose()
        {
            foreach (IControl control in Subscribed)
            {
                control.RemoveHandler(DragDrop.DragOverEvent, DragOver);
                control.RemoveHandler(DragDrop.DropEvent, Drop);
            }

            Subscribed = null;
            Host       = null;
        }
Example #16
0
        // ALL NEEDED EVENTS ARE HERE
        public void StartDragging(IDroppable droppable)
        {
            if (this.droppable != null)
            {
                return;
            }

            objectFlying = true;
            audioManager.PlaySound(Sfx.UIPopup);
            this.droppable = droppable;
            droppable.StartDrag(x => RemoveFromUpdate());
        }
Example #17
0
 public void StopDragging(IDroppable droppable)
 {
     if (this.droppable == droppable && droppable != null)
     {
         audioManager.PlaySound(Sfx.UIPopup);
         if (dragOnly == false)
         {
             CheckCollidedWithPlaceholder(droppable);
         }
         RemoveFromUpdate();
     }
 }
Example #18
0
        // ALL NEEDED EVENTS ARE HERE
        public void StartDragging(IDroppable droppable)
        {
            if (this.droppable != null)
            {
                return;
            }

            audioManager.PlayUIPopup();

            this.droppable = droppable;
            PutDroppableOnTopOfList(droppable);
            droppable.StartDrag(x => RemoveFromUpdateAndPlaceholders(x));
        }
Example #19
0
        private static object GetDropData(IDataObject data, IDroppable dropTarget, out Type dataType)
        {
            foreach (var type in dropTarget.DroppableTypes)
            {
                if (data.GetDataPresent(type))
                {
                    dataType = type;
                    return(data.GetData(type));
                }
            }

            dataType = null;
            return(null);
        }
Example #20
0
    public void Setup(IDroppable dropInfo)
    {
        this.dropInfo = dropInfo;
        print(this.dropInfo);
        var s = dropInfo.GetSprite();

        print(s);
        print(sprend);
        sprend.sprite = s;
        var bounds = sprend.sprite.bounds;
        var factor = TARGET_HEIGHT / bounds.size.y;

        transform.localScale = new Vector3(factor, factor, factor);
        transform.position  += Quaternion.Euler(0, 0, rnd.Next() % 360) * new Vector3(INIT_DISTANCE, 0);
    }
Example #21
0
        public void StopDragging(IDroppable droppable)
        {
            foreach (var p in placeholders)
            {
                p.gameObject.GetComponent <StillLetterBox>().FarSlot();
            }
            if (this.droppable == droppable && droppable != null)
            {
                audioManager.PlayUIPopup();

                if (dragOnly == false)
                {
                    CheckCollidedWithPlaceholder(droppable);
                }
                RemoveFromUpdate();
            }
        }
Example #22
0
        private void CheckCollidedWithPlaceholder(IDroppable droppable)
        {
            foreach (var p in placeholders)
            {
                if (NearEnoughToDrop(p.transform))
                {
                    droppable.Detach(false);
                    droppable.LinkToPlaceholder(p);
                    var set = p.Placeholder.GetQuestion().GetAnswerSet();
                    set.OnDroppedAnswer(droppable.GetAnswer());
                    return;
                }
            }

            // In case we just moved out a LL
            droppable.Detach(false);
        }
Example #23
0
        private void PutDroppableOnTopOfList(IDroppable droppable)
        {
            DroppableBehaviour dropped = (DroppableBehaviour)droppable;

            answers.Remove(dropped);
            answers.Insert(0, dropped);

            float ZMin  = 2;
            float ZMax  = 4.9f;
            int   count = answers.Count;
            int   i     = 0;

            foreach (var answer in answers)
            {
                answer.SetZ(ZMin + (i++) * (ZMax - ZMin) / count);
            }
        }
Example #24
0
        public DragDropManager(IDroppable control)
        {
            Host = control;

            foreach (KeyValuePair <string, DropHandler> entry in Host.DropHandlers)
            {
                DropHandlers.Add(
                    entry.Key,
                    entry.Value ?? ((entry.Key == DataFormats.FileNames)
                        ? new DropHandler(FileDrop)
                        : DefaultDrop
                                    )
                    );
            }

            Subscribe(Host);
        }
Example #25
0
    /// <summary>
    /// Helper function to drop the given droppedPrefab.
    /// </summary>
    public virtual void DropItem()
    {
        IDroppable dropIface = droppedPrefab.GetComponent <IDroppable> ();


        if (dropIface != null)
        {
            // If droppedPrefab has component IDroppable, use its DropAt () function.
            dropIface.DropAt(Shop.Instance(), GetLocation());
        }
        else
        {
            // Otherwise, just use a default dropping animation.

            var clone = GameObject.Instantiate(droppedPrefab, transform.parent) as GameObject;

            clone.transform.position = transform.position;
        }
    }
Example #26
0
        public DefaultDragDropProvider(ModelMapper mapper)
        {
            var model = mapper.Model;

            if (model is IIDItem)
            {
                FIdItem = model as IIDItem;
            }

            if (model is IDraggable)
            {
                FDraggable = model as IDraggable;
            }

            if (model is IDroppable)
            {
                FDroppable = model as IDroppable;
            }
        }
        public virtual void Add(IDroppable entry, double weight, bool guaranteedDrop)
        {
            if (entry == null)
            {
                throw new ArgumentNullException();
            }

            entry.Weight         = weight;
            entry.GuaranteedDrop = guaranteedDrop;

            // TODO: put in another check for NullDrops because it is the only exception where adding a droppable can exceed the drop amount
            if (contents.Count != 0 && contents.Count + 1 > DropAmount)
            {
                throw new Exception("Attempting to add a drop in excess of the drop table's drop amount");
            }

            if (!contents.Add(entry))
            {
                throw new Exception(entry + " already exists in the drop table");
            }
        }
Example #28
0
        public ProjectViewProvider(IProject project, ModelMapper mapper)
        {
            FProject = project;

            FDocumentsMapper = mapper.CreateChildMapper(FProject.Documents);
            if (FDocumentsMapper.CanMap <IDroppable>())
            {
                FDroppable = FDocumentsMapper.Map <IDroppable>();
            }

            // Create a fake model, which shows documents in folders
            FFolderMap = new Dictionary <string, Folder>();

            // First create our root folder.
            FRootFolder = new Folder(string.Empty);
            FFolderMap[FRootFolder.Name] = FRootFolder;

            // Now create all folders.
            foreach (var doc in FProject.Documents)
            {
                FProject_Documents_Added(FProject.Documents, doc);
            }

            // Keep changes in project in sync with our folder model.
            FProject.Documents.Added       += FProject_Documents_Added;
            FProject.Documents.Removed     += FProject_Documents_Removed;
            FProject.Documents.ItemRenamed += FProject_ItemRenamed;
            FProject.References.Added      += HandleProjectReferenceAdded;
            FProject.References.Removed    += HandleProjectReferenceRemoved;

            // Keep us in sync with the root folder.
            FRootFolder.Added        += FRootFolder_Added;
            FRootFolder.Removed      += FRootFolder_Removed;
            FRootFolder.OrderChanged += FRootFolder_OrderChanged;

            FProject.Renamed += FProject_Renamed;
        }
Example #29
0
 void RemoveFromUpdate()
 {
     droppable.StopDrag();
     droppable = null;
 }
Example #30
0
 private IEnumerator DropLate(IDroppable droppable)
 {
     yield return(new WaitForEndOfFrame());
 }
 /// <summary>
 /// Removes a droppable from the list
 /// </summary>
 /// <param name="projectileToRemove">The droppable to remove</param>
 public void RemoveDroppable(IDroppable droppableToRemove)
 {
     droppableList.RemoveAll(x => x.Equals(droppableToRemove));
 }
Example #32
0
 public void AddCleanup(IDroppable toDrop)
 {
     _toDrop.Add(toDrop);
 }
 /// <summary>
 /// Adds a new droppable to the game
 /// </summary>
 /// <param name="newProjectile">The new projectile to add</param>
 public void AddDroppable(IDroppable newDroppable)
 {
     if (droppableList.Exists(x => x.IsActive == false))
     {
         int index = droppableList.FindIndex(x => x.IsActive == false);
         droppableList[index] = newDroppable;
     }
     else
         droppableList.Add(newDroppable);
 }