Inheritance: MonoBehaviour
        /// <summary>
        /// Sets the draggable attr.
        /// </summary>
        /// <param name="draggable">The draggable.</param>
        /// <returns>
        /// The VTag instance
        /// </returns>
        public VTag SetDraggableAttr(Draggable draggable)
        {
            if (!string.IsNullOrWhiteSpace(draggable.ToString()))
            {
                return this.AddAttribute(WellKnownXNames.Draggable, draggable.ToString());
            }

            return this.RemoveAttribute(WellKnownXNames.Draggable);
        }
 private void entered(GameObject a_Go)
 {
     if (a_Go.layer == m_LmLookFor)
     {
         Draggable dragScript = a_Go.GetComponent <Draggable>();
         if (dragScript.m_IsBeingDragged)
         {
             return;
         }
         a_Go.layer = m_LmChangeTo;
         Destroy(dragScript);
         a_Go.AddComponent <Pickupable>();
     }
 }
    // Update is called once per frame
    void Update()
    {
        gameObject.layer = 8;

        //if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer) {

        //} else {
        if (Input.GetMouseButtonUp(0))
        {
            if (selected != null)
            {
                selected.dragging = false;
                selected          = null;
            }
            if (selected == this)
            {
                dragging = false;
                selected = null;
            }
        }

        if (Input.GetMouseButtonDown(0))
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit rayhit;
            if (Physics.Raycast(ray, out rayhit, 50, 1 << 8))
            {
                if (rayhit.collider == collider)
                {
                    dragging = true;
                    selected = this;
                }
            }
        }
        //}



        if (selected == null || selected == this)
        {
            UpdateTouchDrag();

            if (dragging && Application.platform != RuntimePlatform.Android)
            {
                Vector2 pos = Input.mousePosition;
                pos.y = Screen.height - pos.y;
                Drag(Input.mousePosition);
            }
        }
    }
 public void SetUp()
 {
     _driver            = new ChromeDriver(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
     _basePage          = new BasePage(_driver);
     _slider            = new Slider(_driver);
     _accordion         = new Accordion(_driver);
     _automateThePlanet = new AutomateThePlanet(_driver);
     _driver.Manage().Window.Maximize();
     _draggable = new Draggable(_driver);
     _droppable = new Droppable(_driver);
     _user      = UserFactory.GenerateRegUser();
     _regPage   = new RegistrationPage(_driver);
     _sortPage  = new SortablePage(_driver);
 }
Beispiel #5
0
 protected override void RemovedEvent(Draggable d)
 {
     if (target != null)
     {
         CardDisplay card = d.gameObject.GetComponent <CardDisplay>();
         card.effect.RemoveTarget(target);
         FSM.singleton.nextTurnButton.interactable = false;
         if (myCard != null)
         {
             GameInfo.singleton.unresolvedCards.Remove(myCard.gameObject.GetComponent <CardDisplay>());
             myCard = null;
         }
     }
 }
Beispiel #6
0
 protected override void DroppedEvent(Draggable d)
 {
     if (this.transform.childCount < 2 && target != null)
     {
         d.parentToReturnTo = this.transform;
         myCard             = d;
         CardDisplay card = d.gameObject.GetComponent <CardDisplay>();
         GameInfo.singleton.unresolvedCards.Add(card);
     }
     else
     {
         RemovedEvent(d);
     }
 }
Beispiel #7
0
    public void OnDrop(PointerEventData eventData)
    {
        Debug.Log(eventData.pointerDrag.name + " was dropped on " + gameObject.name);

        Draggable d = eventData.pointerDrag.GetComponent <Draggable>();

        if (d != null)
        {
            d.parentToReturnTo = this.transform;
            var player = GetComponent <PlayerGameObject>();
            var card   = eventData.pointerDrag.GetComponent <CardGameObject>();
            player?.TargetWithCard(card.Id, card.UUID);
        }
    }
Beispiel #8
0
    //Es llamado cuando se suelta un objeto en el GameObject (Antes que OnEndDrag())
    public void OnDrop(PointerEventData eventData)
    {
        Debug.Log(eventData.pointerDrag.name + " was dropped on " + gameObject.name);

        Draggable d = eventData.pointerDrag.GetComponent <Draggable>();

        if (d != null)
        {
            //Si tenemos que distinguir que tipo de carta es
            //if (typeOfItem == d.typeOfItem || typeOfItem == Draggable.Slot.INVENTORY)

            d.parentToReturnTo = this.transform;//Establecemos el nuevo padre del objeto dropeado
        }
    }
Beispiel #9
0
    public void OnPointerExit(PointerEventData eventData)
    {
        if (eventData.pointerDrag == null)
        {
            return;
        }

        Draggable d = eventData.pointerDrag.GetComponent <Draggable>();

        if (d != null && d.placeholderParent == this.transform)
        {
            d.placeholderParent = d.parentToReturnTo;             // Set parent when you drag out of previous parent
        }
    }
Beispiel #10
0
 void OnMouseDown()
 {
     Debug.Log("CanDrag: " + da.CanDrag);
     if (da != null && da.CanDrag)
     {
         dragging = true;
         // when we are dragging something, all previews should be off
         //HoverPreview.PreviewsAllowed = false;
         _draggingThis = this;
         da.OnStartDrag();
         zDisplacement       = -Camera.main.transform.position.z + transform.position.z;
         pointerDisplacement = -transform.position + MouseInWorldCoords();
     }
 }
Beispiel #11
0
 void Clicked()
 {
     if (Physics.Raycast(ray, out hit, 100))
     {
         if (hit.transform.gameObject.tag == "Draggable")
         {
             temp_drag_object            = hit.transform.gameObject;
             draggable_original_position = temp_drag_object.transform.position;
             draggable = temp_drag_object.GetComponent <Draggable>();
             drag_slot = draggable.linked_slot;
             dragging  = true;
         }
     }
 }
Beispiel #12
0
 public void DiscardAll()
 {
     Debug.Log("[PlH] Discarding Hand");
     if (AssociatedDiscard)
     {
         while (CardsInZone.Count > 0)
         {
             Draggable drag = CardsInZone[0];
             CardsInZone.RemoveAt(0);
             drag.Locked = true;
             AssociatedDiscard.AddCard(drag.GetComponent <CardManager>());
         }
     }
 }
Beispiel #13
0
 //get tilename from children
 public string updateAnswer()
 {
     finalAnswer = "";
     for (int i = 0; i < this.transform.childCount; i++)
     {
         Draggable child = this.transform.GetChild(i).gameObject.GetComponent <Draggable>();
         if (child != null)
         {
             char c = child.tilename;
             finalAnswer += c;
         }
     }
     return(finalAnswer);
 }
Beispiel #14
0
 void PinOthers(Draggable dragged)
 {
     foreach (var piece in PieceSet.Pieces)
     {
         if (piece.GetInstanceID() == dragged.GetInstanceID())
         {
             piece.Draggable.Unpin();
         }
         else
         {
             piece.Draggable.Pin();
         }
     }
 }
Beispiel #15
0
    /// <summary>
    /// Add an object to the used dictionary and start dragging it
    /// </summary>
    /// <param name="touchID">The touch associated with the object</param>
    /// <param name="obj">Object to be dragged</param>
    public void addObject(int touchID, Draggable obj)
    {
        //Add to the used dictionary
        used.Add(touchID, obj);

        //Get the touch and its world position
        Touch   touch    = Input.GetTouch(touchID);
        Vector3 touchPos = Camera.main.ScreenToWorldPoint(new Vector3(touch.position.x, touch.position.y, 10));

        touchPos.y = touchPos.z;

        //Move the object to that position
        obj.OnTouchDrag(touchPos);
    }
Beispiel #16
0
    public void OnPointerExit(PointerEventData eventData)
    {
        if (eventData.pointerDrag == null)
        {
            return;
        }

        Draggable d = eventData.pointerDrag.GetComponent <Draggable>();

        if (d != null && d.placeHolderParent == transform)
        {
            d.placeHolderParent = d.parentToReturnTo;
        }
    }
Beispiel #17
0
    public void OnDrop(PointerEventData eventData)
    {
        Debug.Log("Dropped");
        Draggable   d  = eventData.pointerDrag.GetComponent <Draggable>();
        CardManager cm = eventData.pointerDrag.GetComponent <CardManager>();



        if (gm.ValidMove(cm.card, gm.GetPlayer().hand))
        {
            gm.PlayMove(gm.GetPlayer().hand);
        }
        //d.returnToParent = this.transform;
    }
Beispiel #18
0
    public void Spawn()
    {
        GameObject thing = Instantiate(ThingToSpawn);

        thing.transform.position = gameObject.transform.position;

        Draggable draggable = thing.GetComponent <Draggable>();

        if (draggable != null)
        {
            _dragger.ThingBeingDragged = draggable;
            draggable.DraggedBy        = _dragger;
        }
    }
Beispiel #19
0
    public void OnDrop(PointerEventData eventData)
    {
        var dragged = Draggable.FindDragging(eventData.pointerId);

        if (dragged != null &&
            dragged.IsHoveringOver == this)
        {
            dragged.DropOn(this);
            foreach (var handler in dropHandlers)
            {
                handler.OnDropped(dragged);
            }
        }
    }
Beispiel #20
0
    public void OnPointerEnter(PointerEventData eventData)
    {
        var dragged = Draggable.FindDragging(eventData.pointerId);

        if (dragged != null &&
            CanDrop(dragged) &&
            dragged.TryHover(this))
        {
            foreach (var handler in hoverHandlers)
            {
                handler.OnHoverStart(dragged);
            }
        }
    }
Beispiel #21
0
    public void OnPointerExit(PointerEventData eventData)
    {
        if (eventData.pointerDrag == null)
        {
            return;
        }

        Draggable drag = eventData.pointerDrag.GetComponent <Draggable> ();

        if (drag != null && drag.parentPlaceholder == this.transform)
        {
            drag.parentPlaceholder = drag.originalParent;
        }
    }
Beispiel #22
0
    /** Manages the drag of the pawns and their physical movement */
    public void MovePawn(object sender, object args)
    {
        Draggable draggablePawn = (Draggable)sender;
        PawnData  pawn          = draggablePawn.gameObject.GetComponent <PawnData>();

        if (!IsPawnTypeValid(pawn, humanPlayer))
        {
            return;
        }
        GameObject obj = pawn.gameObject;
        Vector3    pos = (Vector3)args;

        pawn.gameObject.transform.localPosition = pos;         // moves the pawn locally (client side)
    }
Beispiel #23
0
    public void OnPointerEnter(PointerEventData eventData)
    {
        if (eventData.pointerDrag == null)
        {
            return;
        }

        Draggable drag = eventData.pointerDrag.GetComponent <Draggable> ();

        if (drag != null)
        {
            drag.parentPlaceholder = this.transform;
        }
    }
    public void OnDrop(PointerEventData eventData)
    {
        //Gets the name of the object that was dragged on top
        Debug.Log(eventData.pointerDrag.name + " was dropped on" + gameObject.name);

        Draggable d = eventData.pointerDrag.GetComponent <Draggable>();

        //it's good to check if there is a draggable object at all here for error handlign
        if (d != null)
        {
            //override the parent to return to and set it to this dropzone
            d.parentToReturnTo = this.transform;
        }
    }
Beispiel #25
0
    public void OnPointerEnter(PointerEventData eventData)
    {
        if (eventData.pointerDrag == null)
        {
            return;
        }

        Draggable d = eventData.pointerDrag.GetComponent <Draggable>();

        if (d != null)
        {
            d.placeHolderParent = this.transform;
        }
    }
Beispiel #26
0
    public void OnDrop(PointerEventData eventData)
    {
        Draggable d = eventData.pointerDrag.GetComponent <Draggable>();

        if (d != null)
        {
            myItem = eventData.pointerDrag.GetComponent <InventorySlot>().getItem();
            if (myItem != null && myItem.type == "crafing")
            {
                d.parentToReturnTo = this.transform;
                checkeForMatch();
            }
        }
    }
Beispiel #27
0
    public void DrawCardToHand()
    {
        Shuffle();

/*		if(transform.childCount <= 0) {
 *                      // Really, the only deck for which this should ever be called
 *                      // on is the, well, draw deck.  Therefore, this is a good time
 *                      // to reshuffle the discards into ourselves.
 *
 *                      GameObject discardDeck = Utilities.PlayerDiscard();
 *
 *                      if(discardDeck.transform.childCount == 0) {
 *                              Debug.Log("Draw deck is empty...as is the discard pile!");
 *                              return null;
 *                      }
 *
 *                      // Move everything into this deck.
 *                      while(discardDeck.transform.childCount > 0) {
 *                              discardDeck.transform.GetChild( Random.Range(0, discardDeck.transform.childCount) ).SetParent( this.transform );
 *                      }
 *
 *              }
 */
        if (transform.childCount <= 0)
        {
            Debug.Log("your deck is empty!");
            return;
        }
        GameObject hand = GameObject.Find("Hand");

//		Debug.Log(hand.transform.childCount);
        if (hand.transform.childCount >= 5)
        {
            Debug.Log("Your Hand is Full");
            return;
        }
        Draggable card = transform.GetChild(0).GetComponent <Draggable>();

//		c.StopMoveAnimation();
        card.gameObject.SetActive(true);
        card.transform.SetParent(playerHand.transform);          // This is no child of ours!
        card.transform.SetSiblingIndex(0);
        card.transform.localScale = Vector3.one;
//		if(c.onDrawn != null) {
//			c.onDrawn(c);
//		}

//		return c;
    }
Beispiel #28
0
    protected void FixedUpdate()
    {
        if (!IsValidDraggableTarget(target))
        {
            SetTractorTarget(null);       // Make sure that you are still allowed to tractor the target
        }
        if (target && !owner.GetIsDead()) // Update tractor beam physics
        {
            Rigidbody2D rigidbody = target.GetComponent <Rigidbody2D>();
            if (rigidbody)
            {
                //get direction
                Vector3 dir = transform.position - target.transform.position;
                //get distance
                float dist = dir.magnitude;
                //DebugMeter.AddDataPoint((dir.normalized * (dist - 2F) * 10000f * Time.fixedDeltaTime).magnitude);

                if (target.GetComponent <EnergySphereScript>() || owner as Yard)
                {
                    if (dir.sqrMagnitude <= 0.36F)
                    {
                        rigidbody.position = transform.position;
                        rigidbody.velocity = Vector2.zero;
                        target             = null;
                    }
                    else
                    {
                        rigidbody.position += (Vector2)dir.normalized * 0.6F;
                    }
                    if (owner.IsInvisible)
                    {
                        target = null;
                    }
                }
                else if (dist > 2f)
                {
                    if (!owner.tractorSwitched)
                    {
                        rigidbody.AddForce(dir.normalized * (dist - 2F) * rigidbody.mass * tractorStrength / Time.fixedDeltaTime);
                    }
                    else
                    {
                        owner.GetComponent <Rigidbody2D>().AddForce(-dir.normalized * (dist - 2F) *
                                                                    rigidbody.mass * tractorStrength / Time.fixedDeltaTime);
                    }
                }
            }
        }
    }
Beispiel #29
0
    /// <summary> Returning cards placeholder parent to its former parent on cursor exit. </summary>
    virtual public void OnPointerExit(PointerEventData eventData)
    {
        if (eventData.pointerDrag == null)
        {
            return;
        }

        // Returning dragged cards placeholder parent to its original parent.
        Draggable draggable = eventData.pointerDrag.GetComponent <Draggable>();

        if (draggable != null && draggable.placeholderParent == this.transform)
        {
            draggable.placeholderParent = draggable.parentToReturnTo;
        }
    }
    void OnPointerDown()
    {
        cam.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(cam.ScreenPointToRay(Input.mousePosition), out hit))
        {
            Draggable script = hit.collider.GetComponent <Draggable>();
            if (script != null)
            {
                ItemBeingDragged = script;
                ItemBeingDragged.OnPointerDown();
            }
        }
    }
Beispiel #31
0
    public void OnDrop(PointerEventData eventData)
    {
        // Debug.Log(eventData.pointerDrag.name + " was dropped on " + gameObject.name);

        Debug.Log("DROP");
        Draggable d = eventData.pointerDrag.GetComponent <Draggable>();

        if (d != null)
        {
            if (typeOfCard == d.typeOfCard)
            {
                d.parentToReturnTo = this.transform;
            }
        }
    }
	// Update is called once per frame
	void Update() {
		gameObject.layer = 8;
		
		//if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer) {
			
		//} else {
			if (Input.GetMouseButtonUp(0)) {
			if (selected != null) {
				selected.dragging = false;
				selected = null;
			}
			if (selected == this) {
				dragging = false;
				selected = null;
			}
		}
		
		if (Input.GetMouseButtonDown(0)) {
			Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
			RaycastHit rayhit;
			if (Physics.Raycast(ray, out rayhit, 50, 1 << 8)) {
				if (rayhit.collider == collider) {
					dragging = true;
					selected = this;
				}
			}
			
			
		}
		//}
		
		
		
		
		
		
			
		if (selected == null || selected == this) {
			UpdateTouchDrag();
			
			if (dragging && Application.platform != RuntimePlatform.Android) {
				Vector2 pos = Input.mousePosition;
				pos.y = Screen.height - pos.y;
				Drag(Input.mousePosition);
				
			}
		}
	}
        public void Initialize(Canvas control)
        {
            behavior = new Draggable();
            dragElement = new Placeholder();

            control.Width = 500;
            control.Height = 500;
            control.Background = StyleResources.Colors["Brush.Black.005"] as Brush;
            control.Children.Add(dragElement);

            Behaviors.SetDraggable(dragElement, behavior);

            behavior.IsDraggingChanged += delegate { Debug.WriteLine("!! IsDraggingChanged - IsDragging: " + behavior.IsDragging); };
            behavior.DragStarted += delegate { Debug.WriteLine("!! DragStarted"); };
            behavior.DragStopped += delegate { Debug.WriteLine("!! DragStopped"); };
        }
        public void Initialize(Canvas control)
        {
            element = new Placeholder();
            dragBehavior = new Draggable();
            sliderBehavior = new PositionSlider{Duration = 1};

            control.Width = 500;
            control.Height = 500;
            control.Background = StyleResources.Colors["Brush.Black.005"] as Brush;
            control.Children.Add(element);

            control.SetPosition(element, 50, 50);

            Behaviors.SetDraggable(element, dragBehavior);
            Behaviors.SetPositionSlider(element, sliderBehavior);

            sliderBehavior.SlideStarted += delegate { Debug.WriteLine("!! SlideStarted"); };
            sliderBehavior.SlideComplete += delegate { Debug.WriteLine("!! SlideComplete"); };
        }
Beispiel #35
0
	public void MeshObject(Draggable item)
	{
		objectsUsed.Add (item.type);
		if (item.itemBehavior == ItemBehavior.sticky) {
			item.gameObject.transform.SetParent (meshedParent.transform);
			item.GetComponent<Collider2D> ().enabled = false;

			if (SoundManager.instance) {
				SoundManager.instance.PlayDropOnTableSfx();
			}
		} else {
			if(SoundManager.instance)
				SoundManager.instance.PlayPotionSfx ();
			SpriteRenderer[] sprites = meshedParent.GetComponentsInChildren<SpriteRenderer> ();
			foreach (SpriteRenderer s in sprites) {
				s.color = item.sprinkleColor;
			}
            if(item.sprinkleAnim)
    	    	item.sprinkleAnim.Play();
		}
	}
 void Update()
 {
     bool dragStart = false;
     if (Input.GetMouseButtonDown(0)) {
         Ray ray = mainCamera.ScreenPointToRay(Input.mousePosition);
         Debug.Log (ray);
         RaycastHit hit;
         if (Physics.Raycast(ray, out hit, mainCamera.farClipPlane)) {
             var draggable = hit.collider.gameObject.GetComponent<Draggable>();
             if (draggable != null) {
                 grabbedObject = draggable;
                 lastPosition = grabbedObject.transform.position;
                 dragPosDiffOnScreen = Input.mousePosition - mainCamera.WorldToScreenPoint(lastPosition);
                 dragStart = true;
                 Debug.Log(grabbedObject.name);
             }
         }
     }
     if (grabbedObject) {
         Ray ray = mainCamera.ScreenPointToRay(Input.mousePosition - dragPosDiffOnScreen);
         RaycastHit hit;
         if (Physics.Raycast(ray, out hit, mainCamera.farClipPlane, 1<<LayerMask.NameToLayer("TransparentFX"))) {
             if (!dragStart) {
                 var prev = grabbedObject.transform.position;
                 var curr = grabbedObject.transform.position += hit.point - lastPosition;
                 var coll = grabbedObject.GetComponent<CapsuleCollider>();
                 var radius = grabbedObject.transform.TransformVector(Vector3.right * coll.radius).x;
                 oceanSurfaceRenderer.BeginForce();
                 oceanSurfaceRenderer.AddCircleMovement(prev, curr, grabbedObject.oceanSurfaceWaveStrength, radius, 1<<grabbedObject.oceanSurfaceMaskIndex);
                 oceanSurfaceRenderer.EndForce();
             }
             lastPosition = hit.point;
         }
     }
     if (Input.GetMouseButtonUp(0)) {
         grabbedObject = null;
     }
 }
	bool CheckForDrag(Draggable drag){
		BlockGroup group = drag.GetComponent<BlockGroup> ();

		if (group == null)
			return false;

		foreach(DropZone d in group.GetAnyBlock().draggable.dropZones){
			if(CanDropHere(group, d)){
				if (OnSuccessfulDrag != null) {
					OnSuccessfulDrag (group, d);
				} else {
					DropHere (group, d);
				}

				DoneDragging ();
				return true;
			}
		}
		if (OnFailDrag != null)
			OnFailDrag (group);

		return false;
	}
Beispiel #38
0
    /// <summary>
    /// Add an object to the used dictionary and start dragging it
    /// </summary>
    /// <param name="touchID">The touch associated with the object</param>
    /// <param name="obj">Object to be dragged</param>
    public void addObject(int touchID, Draggable obj)
    {
        //Add to the used dictionary
        used.Add(touchID, obj);

        //Get the touch and its world position
        Touch touch = Input.GetTouch(touchID);
        Vector3 touchPos = Camera.main.ScreenToWorldPoint(new Vector3(touch.position.x, touch.position.y, 10));
        touchPos.y = touchPos.z;

        //Move the object to that position
        obj.OnTouchDrag(touchPos);
    }
 public override void OnDrop(Draggable.DragInfo dragData, Draggable.DropInfo dropData)
 {
     Vector3 randomColor = Random.onUnitSphere;
     GetComponent<Renderer>().material.color = new Color(randomColor.x, randomColor.y, randomColor.z, 1);
     Debug.Log(dropData.Draggable.name + " was dropped in me");
 }
            private Draggable CreateDraggableBehavior(UIElement child)
            {
                var behavior = new Draggable();
                SyncDraggableProperties(behavior);

                Behaviors.SetDraggable(child, behavior);
                behavior.IsDraggingChanged += parent.Handle_Child_IsDraggingChanged;
                behavior.Dragging += parent.Handle_Child_Dragging;

                return behavior;
            }
 private void SyncDraggableProperties(Draggable behavior)
 {
     if (behavior == null) return;
     behavior.DragX = parent.Orientation == Orientation.Horizontal;
     behavior.DragY = parent.Orientation == Orientation.Vertical;
     behavior.DragContainment = parent.DragContainment;
 }
 public abstract void OnStopHover(Draggable.DragInfo dragData, Draggable.DropInfo dropData);
Beispiel #43
0
	void Awake(){
		spR = GetComponent<SpriteRenderer> ();
		draggable = GetComponent<Draggable> ();
	}
Beispiel #44
0
 public DragCommand(Draggable source, Targetable destination)
 {
     Source = source;
     Destination = destination;
 }
	bool CheckForDrag(Draggable drag, DropZone dropedOn){
		if (onDragEnded != null)
			return onDragEnded (drag);

		return false;
	}
Beispiel #46
0
    /// <summary>
    /// Set the parent object of this panel checker
    /// </summary>
    /// <param name="p">Parent Object</param>
	public void setParent(Draggable p)
    {
        parent = p;
    }
 public static void SetDraggable(UIElement element, Draggable value) { element.SetValue(DraggableProperty, value); }
 public override void OnHover(Draggable.DragInfo dragData, Draggable.DropInfo dropData)
 {
     transform.localScale = originalScale * (1.2f + Random.Range (-0.1f, 0.1f));
 }
 public override void OnStopHover(Draggable.DragInfo dragData, Draggable.DropInfo dropData)
 {
     transform.localScale = originalScale;
     Debug.Log(dropData.Draggable.name + " stopped hovering me");
 }
 protected override void OnDrop(Draggable.DragInfo dragData, Draggable.DropInfo dropData)
 {
     Debug.Log("I was dropped into " + dropData.Container.name);
     transform.position = Vector3.zero;
 }
 protected override void OnHovering(Draggable.DragInfo dragData, Draggable.DropInfo dropData)
 {
 }
 protected override void OnStopHovering(Draggable.DragInfo dragData, Draggable.DropInfo dropData)
 {
     Debug.Log("I stopped hovering " + dropData.Container.name);
 }
Beispiel #53
0
	void Awake(){
		draggable = GetComponent<Draggable> ();
		color = BoxColor.RandomColor ();
		blocks = new Block[positions.Length];
	}
Beispiel #54
0
 private static DropContainer GetHoveredContainerScreenRay3D(PointerEventData data, Draggable draggable)
 {
     Ray ray = data.pressEventCamera.ScreenPointToRay(data.pressEventCamera.WorldToScreenPoint(draggable.transform.position));
     int numHits = Physics.RaycastNonAlloc(ray, RaycastHits, draggable._droppableConfig.collisionDistance, draggable._droppableConfig.dropContainerLayers);
     #if UNITY_EDITOR
     Debug.DrawLine(ray.GetPoint(0), ray.GetPoint(draggable._droppableConfig.collisionDistance), Color.blue);
     #endif
     DropContainer nowHoveredContainer = null;
     float closestDist;
     DropContainer container;
     for (int i = 0; i < numHits; i++)
     {
         closestDist = float.PositiveInfinity;
         if ((container = RaycastHits[i].collider.gameObject.GetComponent<DropContainer>()) != null)
         {
             float containerDist = Vector3.Distance(container.transform.position, draggable.transform.position);
             if (containerDist < closestDist)
             {
                 nowHoveredContainer = container;
             }
         }
     }
     return nowHoveredContainer;
 }
Beispiel #55
0
 internal static DropContainer GetHoveredContainer(DroppablePhysics physics, PointerEventData eventData, Draggable draggable)
 {
     return GET_HOVERED_CONTAINER_FUNCTIONS[physics](eventData, draggable);
 }
Beispiel #56
0
    public void dieDropped(Zone z)
    {
        bool soundPlayed = false;
        Die d = draggedObject.GetComponent<Die>();

        string dropFrom = "", areaFrom = "";
        if (z)
        {
            dropFrom = z.zoneName;
            areaFrom = z.holders.areaHolder.name;
        }
        string dropTo = draggedObject.getParentZone().zoneName;

        gameLayout.checkZoneColor();

        // Special Zone Cases (If drop is valid)

        //switch (draggedObject.transform.parent.parent.name)
        switch (dropTo)
        {
            case "zoneStored":
                if (dropFrom == "zoneSummoned")
                {
                    playerLogic.defendAttack(d);
                    Debug.Log("Defending!");
                } else if (areaFrom == "areaMarket")
                {
                    playerLogic.updateEnergy(-d.card.cardInfo.cost);
                    GameState.hasBought = true;
                }
                break;
            case "zoneSpent":
                if (dropFrom == "zoneServicable")
                {
                    playerLogic.updateEnergy(d.getSideValue(Side.eValueTypes.ENERGY));
                    Debug.Log("Unlimited Powwwer!");
                }
                break;
            case "zoneSummoned":
                if (dropFrom == "zoneServicable")
                {
                    playerLogic.updateEnergy(-d.getSideValue(Side.eValueTypes.COST));
                    Debug.Log("Summoning!");
                }
                break;
            case "zoneSupply":
                //draggedObject
                d.toggleVisibility(false);
                SoundControl.instance.playAudio("dice", "drop_cup");
                soundPlayed = true;
                break;
            default:
                break;
        }

        if (!soundPlayed) SoundControl.instance.playAudio("dice", "drop_table");

        draggedObject = null;
    }
        /// <summary>
        /// Lets the game respond to player input. Unlike the Update method,
        /// this will only be called when the gameplay screen is active.
        /// </summary>
        public void HandleInput(InputState input)
        {
            if (input == null)
                throw new ArgumentNullException("input");

            /*if (gamePadState.Buttons.Y == ButtonState.Pressed)
                this.missionRunning = false;*/

            IEnumerable<Draggable> actions = null;
            if (this.gameMode == GameMode.REALTIME)
            {
                actions = GetRealDraggables();
            }
            else
            {
                actions = GetDecisionDraggble();
            }

            if (currentState == DragState.Idle)
            {
                if (input.GetMouseDown())
                {
                    //Check if mouse is within any of the dropoff boxes
                    foreach (Draggable draggable in actions)
                    {
                        if (draggable.AttemptBeginDrag(input.GetMousePosition()))
                        {
                            currentState = DragState.Dragging;
                            currentlyDragging = draggable;
                            break;
                        }
                    }
                }
            }
            else if (currentState == DragState.Dragging)
            {
                if (input.GetMouseDown())
                {
                    //Move the one we are dragging
                    Point? gridPoint = grid.GetGridPointFromMousePosition(input.GetMousePosition());
                    Rectangle? lockedRectangle = null;
                    if (gridPoint.HasValue)
                    {
                        lockedRectangle = grid.GetGridRectangleFromGridPoint(gridPoint.Value);
                    }
                    currentlyDragging.UpdateDrag(input.GetMouseDelta(), lockedRectangle);
                }
                else
                {
                    Point? gridPoint = grid.GetGridPointFromMousePosition(input.GetMousePosition());
                    if (gridPoint.HasValue)
                    {
                        //Drop the dropoff in this grid#
                        Rectangle cellRect = grid.GetGridRectangleFromGridPoint(gridPoint.Value);
                        currentlyDragging.EndDrag(cellRect);
                        currentState = DragState.Idle;
                        /*this.buckets.addWater(cellRect.X + (cellRect.Width / 2),
                            cellRect.Y + (cellRect.Height / 2));*/
                        //this.buckets.addWater(cellRect.X + (cellRect.Width / 2),
                        //    cellRect.Y + (cellRect.Height / 2));

                        if (gameMode == GameMode.REALTIME)
                        {
                            ActionPlaced((Actions.GameAction)currentlyDragging, gridPoint.Value, cellRect);
                        }
                        else
                        {
                            DropoffPlaced((Dropoffs.Dropoff)currentlyDragging, cellRect, gridPoint.Value);
                        }
                    }
                    else
                    {
                        EndDrag();
                    }
                }
            }

            if (gameMode == GameMode.REALTIME)
            {
                HandleInputReal(input);
            }
            else
            {
                HandleInputDecision(input);
            }
        }
Beispiel #58
0
    public bool isValidDrag(Draggable drag)
    {
        bool canDrag = false;

        string zoneFrom, areaFrom;

        Die d = drag.GetComponent<Die>();

        try {
            Debug.Log("Area: " + drag.getParentArea().name + " - " + getCurrentAreaS());
            // If draggable not in current player's area or the market, then do not allow to drag.
            //      --- Won't work if want Defender to discard during STRIKE step ---
            if (drag.getParentArea().name != getCurrentAreaS() && drag.getParentArea().name != "areaMarket")
            {
                //return false;
            }
            // Depending on step and zone, allow draggability

            zoneFrom = drag.getParentZone().zoneName;
            areaFrom = drag.getParentArea().name;
            Debug.Log("Zone: " + zoneFrom);
            switch ((int)stepLogic.currentStep)
            {
                case 0:  // SCORE
                    // Clicked die in zoneSummoned dice

                    if (zoneFrom.Equals("zoneSummoned") && areaFrom.Equals(getCurrentAreaS()))
                    {
                        // Know Dice exist in zone...so get them and score them
                        playerLogic.scoreDice();
                        moveDice(getCurrentZoneS("zoneSummoned"),
                                 getCurrentZoneS("zoneStored"));

                        if (playerLogic.currentPlayer().score == GameState.winCondition) {

                            Debug.Log(playerLogic.currentPlayer().getPlayerName() + " Wins!");

                            GameMenu[] menus = GameObject.Find("GameMenu").GetComponents<GameMenu>();

                            foreach (GameMenu item in menus ) {
                                if (item.menuPanel.name == "GameOver") {
                                    item.menuPanel.SetActive(true);
                                    break;
                                }
                            }
                            GameObject.Find("txtGameOver").GetComponent<Text>().text = playerLogic.currentPlayer().getPlayerName() + " Wins!";
                            GameState.isPaused = true;
                        }
                        canDrag = false;
                    }
                    break;
                case 1:  // SCRY
                    break;
                case 2:  // SPIN
                    // If draggable clicked is in the rolled zone, then move the dice to proper spot.
                    if (zoneFrom.Equals("zoneRoll") && areaFrom.Equals(getCurrentAreaS()))
                    {
                        moveDice(getCurrentZoneS("zoneRoll"),
                                 getCurrentZoneS("zoneServicable"));
                        canDrag = false;
                    }
                    if (zoneFrom.Equals("zoneSupport") && areaFrom.Equals(getCurrentAreaS()))
                    {
                        if (Input.GetKey(KeyCode.LeftShift))
                        {
                            rollSimilarDice(drag.GetComponent<Die>());
                        }
                        else
                        {
                            SoundControl.instance.setAudio("dice", "rollS");
                            DieLogic.rollDie(drag.GetComponent<Die>());
                        }
                        canDrag = false;
                    }
                    break;
                case 3:  // SPEND
                    if (drag.getParentArea().name == "areaMarket" &&
                        playerLogic.affordEnergy(d.card.cardInfo.cost) &&
                        !GameState.hasBought)
                    {
                        canDrag = true;
                    }

                    // Will only ever have Dice in this zone during current players turn
                    if (zoneFrom.Equals("zoneServicable"))
                        canDrag = true;
                    break;
                case 4:  // STRIKE
                    //Debug.Log(playerLogic.startAttack());
                    if (zoneFrom.Equals("zoneSummoned") && !areaFrom.Equals(getCurrentAreaS()))
                        canDrag = true;
                    break;
                case 5:  // SECURE
                    if (zoneFrom.Equals("zoneServicable") ||
                        zoneFrom.Equals("zoneSpent"))
                    {
                        if (Input.GetKey(KeyCode.LeftShift))
                        {
                            moveDice(getCurrentZoneS("zoneServicable"),
                                     getCurrentZoneS("zoneStored"));
                            moveDice(getCurrentZoneS("zoneSpent"),
                                     getCurrentZoneS("zoneStored"));
                            canDrag = false;
                        }
                        else
                        {
                            canDrag = true;
                        }
                    }
                    break;
                default:
                    break;
            }
        }
        catch (Exception e)
        {
            Debug.Log("isValidDrag err:/n" + e);
        }
        finally
        {
            if (canDrag)
                draggedObject = drag;
                //draggedObject = drag.gameObject;
        }

        if (canDrag)
        {
            // HARD: Assume Drag is die?
            SoundControl.instance.playAudio("dice", "pickup");
            return true;
        }
        return false;

        switch (drag.tag)
        {
            case "Die":
                break;
            case "Card":
                break;
            case "Token":
                break;
            default:
                // Not a legit dragged item
                break;
        }
    }
Beispiel #59
0
 private static DropContainer GetHoveredContainerPosition2D(PointerEventData data, Draggable draggable)
 {
     int numHits = Physics2D.OverlapPointNonAlloc(draggable.transform.position, hits2D, draggable._droppableConfig.dropContainerLayers);
     #if UNITY_EDITOR
     Debug.DrawLine(draggable.transform.position + new Vector3(draggable._droppableConfig.collisionDistance, 0, 0), draggable.transform.position - new Vector3(draggable._droppableConfig.collisionDistance, 0, 0), Color.blue);
     Debug.DrawLine(draggable.transform.position + new Vector3(0, draggable._droppableConfig.collisionDistance, 0), draggable.transform.position - new Vector3(0, draggable._droppableConfig.collisionDistance, 0), Color.blue);
     #endif
     DropContainer nowHoveredContainer = null;
     float closestDist;
     DropContainer container;
     for (int i = 0; i < numHits; i++)
     {
         closestDist = float.PositiveInfinity;
         if ((container = hits2D[i].gameObject.GetComponent<DropContainer>()) != null)
         {
             float containerDist = Vector2.Distance(container.transform.position, draggable.transform.position);
             if (containerDist < closestDist)
             {
                 nowHoveredContainer = container;
             }
         }
     }
     return nowHoveredContainer;
 }
 public abstract void OnDrop(Draggable.DragInfo dragData, Draggable.DropInfo dropData);