예제 #1
0
    /// <summary>
    /// 地图上的英雄node的实例化
    /// </summary>
    /// <param name="heroData"></param>
    /// <param name="setDragIcon"></param>
    /// <returns></returns>
    GameObject InsHeroNode(HeroData heroData, bool setDragIcon)
    {
        GameObject go        = Instantiate(_heroNodeModel);
        UINode     uiNode    = go.GetComponent <UINode>();
        Image      nodeImage = uiNode.GetRef("Image").GetComponent <Image>();

        nodeImage.sprite = GameResSys.Instance.GetCard(heroData.Icon);

        Button btn = uiNode.GetRef("Image").GetComponent <Button>();

        if (btn == null)
        {
            btn = uiNode.GetRef("Image").gameObject.AddComponent <Button>();
        }
        btn.onClick.AddListener(() => { OnHerNodeClicked(heroData.Id); });

        Dragable drag = uiNode.GetRef("Image").gameObject.AddComponent <Dragable>();

        drag.ActionId    = heroData.Id;
        drag.OnDragStart = OnDrag;
        drag.Canv        = _stageCanvas;
        if (setDragIcon)
        {
            drag.DragIcon = GameResSys.Instance.GetItem(heroData.FightIcon);
        }
        drag.HasTail       = true;
        drag.TailSprite    = GameResSys.Instance.GetMask(GameConstants.CommonDragTail);
        drag.TailColor     = heroData.TheColor;
        drag.TailWidth     = 20;
        drag.IsDisableGray = true;

        return(go);
    }
 private void FillSpot(Dragable part)
 {
     part.transform.position = transform.position;
     part.disabled           = true;
     ps.Stop();
     filled = true;
 }
예제 #3
0
    void OnFightStateMapping(object p1, object p2)
    {
        CatDebug.LogFunc();

        Transform hsl = _stageNode.GetRef("HeroSelectList");

        hsl.gameObject.SetActive(false);

        Transform readyBtn = _stageNode.GetRef("ButtonReady");

        readyBtn.gameObject.SetActive(false);

        foreach (KeyValuePair <int, Transform> pair in _nodeUIs)
        {
            Dropable dropable = pair.Value.GetComponentInChildren <Dropable>();
            dropable.enabled = true;
        }

        Dictionary <int, FightHero> heroes = (Dictionary <int, FightHero>)p1;

        foreach (KeyValuePair <int, Transform> pair in _fightHeroNodes)
        {
            Dragable dragable = pair.Value.GetComponentInChildren <Dragable>();
            HeroData hd       = (HeroData)heroes[pair.Key].CreatureData;
            dragable.DragIcon = GameResSys.Instance.GetItem(hd.FightIcon);
        }

        //create hero show list
        CreateHeroShowList(heroes);
    }
예제 #4
0
    void RefreshItem(FightHero fh)
    {
        _itemNodeRoot.DestroyChildren();
        foreach (var pair in fh.Items)
        {
            Item       item = pair.Value;
            GameObject go   = Instantiate(_modelNode.GetNode("Item").gameObject);
            go.transform.SetParent(_itemNodeRoot);

            UINode itemNode = go.GetComponent <UINode>();
            Image  image    = itemNode.GetRef("Image").GetComponent <Image>();
            image.sprite = GameResSys.Instance.GetItem(item.Icon);
            Button btn = image.gameObject.AddComponent <Button>();
            btn.onClick.AddListener(() => { EventSys.Instance.AddEvent(InputEvent.FightItemClicked, item.Id); });
            Text num = itemNode.GetRef("Text").GetComponent <Text>();
            num.text          = item.Count.Value.ToString();
            num.raycastTarget = false;//避免遮挡
            if (item.UsableInFight)
            {
                if (item.JobLimited > 0 && item.JobLimited != ((HeroData)fh.CreatureData).Job)
                {
                    continue;
                }

                Dragable dragable = image.gameObject.AddComponent <Dragable>();
                dragable.HasTail     = true;
                dragable.TailSprite  = GameResSys.Instance.GetMask(GameConstants.CommonDragTail);
                dragable.TailColor   = item.TheColor;
                dragable.TailWidth   = 20;
                dragable.Canv        = _rootNode.GetComponent <Canvas>();
                dragable.ActionId    = item.Id;
                dragable.OnDragStart = OnDragFromItem;
            }
        }
    }
예제 #5
0
    public void OnDrop(PointerEventData eventData)
    {
        Transform target = eventData.pointerDrag.transform;

        while (target.parent && target.parent.GetComponent <Dragable>())
        {
            target = target.parent;
        }
        Dragable dragable = target.GetComponent <Dragable>();

        if (!dragable)
        {
            return;
        }
        if (dragable.dragTag == dragTag && isFree)
        {
            AcceptDrag(dragable);
        }
        else if (dragable.dragTag == dragTag && !isFree) //Switch
        {
            DropHandler otherParent = target.GetComponentInParent <DropHandler>();
            Switch(otherParent);
        }
        else
        {
            dragable.AbortDrag();
        }
    }
예제 #6
0
    public void OnDrop(PointerEventData eventData)
    {
        Dragable d = eventData.pointerDrag.GetComponent <Dragable>();

        if (d == null)
        {
            var dForClone = eventData.pointerDrag.GetComponent <DragableForClone>();

            if (dForClone != null)
            {
                if (dForClone.origParent == this.transform)
                {
                    dForClone.dropOnParent = true;
                }
                else
                {
                    dForClone.dropZoneToReturn = this.transform;
                }
            }
        }
        else
        {
            var child = this.transform.childCount;
            if (child == 2)
            {
                return;
            }
            d.parentToReturn = this.transform;
            ApplicationModel.orderedAnimalsCount += 1;
        }
    }
예제 #7
0
    private void OnMouseUp()
    {
        RaycastHit2D Feld;
        Platzhalter  platzhalter = null;

        feldPalette.isDragging       = false;
        feldPalette.gameObject.layer = 0;
        feldPalette.currentDragged.GetComponent <SpriteRenderer>().sortingOrder = 1;
        Dragable fPCurrentDragged = feldPalette.currentDragged.GetComponent <Dragable>();

        changePaletteVisibility();

        Feld = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), new Vector3(0, 0, 0), 1000f, 1024);
        if (Feld)
        {
            platzhalter = Feld.transform.GetComponent <Platzhalter>();
        }

        if (platzhalter)
        {
            string currentFieldTag;
            if (platzhalter.currentField == null)
            {
                currentFieldTag = "leer";
            }
            else
            {
                currentFieldTag = platzhalter.currentField.tag;
            }

            if (currentFieldTag == "leer" && feldPalette.currentTag != "leer")
            {
                feldPalette.increaseComplexity();
            }
            if (currentFieldTag != "leer" && feldPalette.currentTag == "leer")
            {
                feldPalette.decreaseComplexity();
            }

            if (currentFieldTag == "Ziel" && feldPalette.currentTag != "Ziel")
            {
                platzhalter.transform.parent.GetComponent <Board>().zielCount--;
            }
            if (currentFieldTag != "Ziel" && feldPalette.currentTag == "Ziel")
            {
                platzhalter.transform.parent.GetComponent <Board>().zielCount++;
            }

            Destroy(platzhalter.currentField);
            platzhalter.currentField = feldPalette.currentDragged;
            platzhalter.currentField.transform.position = platzhalter.anchorPoint;
            platzhalter.tellBoard(feldPalette.currentTag);

            fPCurrentDragged.myPlatzhalter = platzhalter;
        }
        else
        {
            Destroy(feldPalette.currentDragged);
        }
    }
예제 #8
0
    // 检查当前时间条上所有步骤是否合法,不合法变红色
    public void CheckDepend()
    {
        var OnTimeHolder = (from x in CookingSteps where x.Belong != null select x).ToList();

        OnTimeHolder.ForEach((cookingStep) => {
            Dragable dragable      = cookingStep.GetComponent <Dragable>();
            RectTransform dragRect = dragable.dragRect;
            bool f1 = (from x in cookingStep.Depend
                       where x.Belong != null && x != cookingStep
                       select x.GetComponent <RectTransform>())
                      .Any((x) => x.anchoredPosition.x + x.sizeDelta.x > dragRect.anchoredPosition.x);
            Rect t  = new Rect(dragRect.anchoredPosition.x, 0, dragRect.sizeDelta.x, 1);
            bool f2 = CookingSteps
                      .Where((x) => x.Belong != null && x != cookingStep && (!x.CanParallel && !cookingStep.CanParallel))
                      .Select((x) => x.GetComponent <RectTransform>())
                      .Select((x) => new Rect(x.anchoredPosition.x, 0, x.sizeDelta.x, 1))
                      .Any((x) => x.Overlaps(t));
            bool f3 = cookingStep.Depend.Any((x) => x.Belong == null);
            if (f1 || f2 || f3)
            {
                dragable.frameImage.GetComponent <Image>().color = Color.red;
            }
            else
            {
                if (cookingStep.CanParallel)
                {
                    dragable.frameImage.GetComponent <Image>().color = Color.green;
                }
                else
                {
                    dragable.frameImage.GetComponent <Image>().color = Color.white;
                }
            }
        });
    }
예제 #9
0
    void OnCreateHeroStartNode(object p1, object p2)
    {
        CatDebug.LogFunc();

        HeroData heroData     = (HeroData)p1;
        int      targetNodeId = (int)p2;

        if (_heroSelectNodes.ContainsKey(heroData.Id))
        {
            Dragable d = _heroSelectNodes[heroData.Id].GetComponentInChildren <Dragable>();
            d.SetEnable(false);
        }

        GameObject go = InsHeroNode(heroData, false);//这里的英雄还可能与其他英雄交换,故不添加特殊dragicon

        go.transform.SetParent(_stageNodeRootTrans);
        //go.GetComponent<Button>().onClick.AddListener(() => { });

        Dropable drop = go.AddComponent <Dropable>();

        drop.ActionId = heroData.Id;
        drop.OnDroped = DropOnHero;

        Transform target     = _nodeUIs[targetNodeId];
        UINode    targetNode = target.GetComponent <UINode>();

        go.transform.SetParent(targetNode.GetRef("HeroRoot"));

        _fightHeroNodes.Add(heroData.Id, go.transform);
    }
예제 #10
0
    /// <summary>
    /// Create new instances of this game object
    /// </summary>
    void InstantiateClones()
    {
        if (placeableMgrScript.CheckCanClone(gameObject))
        {
            if (Mathf.Floor(positionToMouse().magnitude / objectWidth) > nInstances)
            {
                // Create a new instnace of this game object
                GameObject copy = Instantiate(gameObject);
                // Ensure all instantiated objects interpret a mouse click as their second mouse click as opposed to the first
                Dragable script = copy.GetComponent <Dragable>();
                script.isInitiallyPlaced = true;
                script.isClone           = true;

                /*
                 * Because Instantiate function creates an exact clone, the clone will intialise (in Awake)
                 * its material to the green material THIS object is intially set to.
                 * THEREFORE pass the clones the correct initial materials.
                 */
                script.matInitColours = matInitColours;
                // Number of instances in the scene has increased
                ++nInstances;
                clones.Add(copy);
            }
        }
    }
예제 #11
0
파일: Table.cs 프로젝트: paniivan/CardGame
    public void ProposeCard(GameObject cardGameObj)
    {
        Card     card    = cardGameObj.GetComponent <Card>();
        Dragable dagable = cardGameObj.GetComponent <Dragable>();

        if (offenceMode)
        {
            if (CanBePassed(card))
            {
                AddToTable(dagable);
                //TODO: some ivent
            }
            else
            {
                ReturnToHand(dagable);
            }
            //TODO: jdkfjakfjskfj
        }
        else
        {
            if (CardCanBeat(card))
            {
                AddToTable(dagable);
                //TODO: create/destroy table placeholder
                Debug.Log("Nice move!");
                //TODO: trigger some ivent mb
            }
            else
            {
                Debug.Log("Bad move!");
                ReturnToHand(dagable);
            }
        }
    }
예제 #12
0
    public void OnPointerExit(PointerEventData eventData)
    {
        //Debug.Log("PointerExit"+ gameObject.name);
        //print("PointerExit" + gameObject.name);

        if (eventData.pointerDrag == null)
        {
            return;
        }
        Dragable d = eventData.pointerDrag.GetComponent <Dragable>();

        if (d != null && d.placeholderparent == this.transform)
        {
            d.placeholderparent = d.parentToReturnTo;
        }
        if (gameObject.name == "Deck")
        {
            //temp = d.GetComponentInChildren<Transform>().Find("Image");
            //picture = temp.GetComponent<Image>().sprite;
            card_to_block = d;
            //Blockdata reciever = GameObject.Find("a_block").GetComponent<Blockdata>();
            //reciever.Recieve();
            //Destroy(d.gameObject);
            //Destroy(d.placeholder);
            // Debug.Log(picture.name);
        }
    }
예제 #13
0
    public void OnDrop(PointerEventData eventData)
    {
        Dragable dropedUnit = eventData.pointerDrag.GetComponent <Dragable>();

        dropedUnit.parentToReturn = transform;
        UnitList.instance.isOnBattleField[dropedUnit.IndexInUnitList] = false;
    }
예제 #14
0
 void OnMouseOver()
 {
     if (Input.GetMouseButtonDown(0) && !Functions.IsDraggingAnything())
     {
         Dragable.draggedObject = this;
         isDragging             = true;
     }
 }
예제 #15
0
    public void OnDrop(PointerEventData eventData)
    {
        //Debug.Log (eventData.pointerDrag.name + " OnDrop to " + gameObject.name);

        Dragable dropedObject = eventData.pointerDrag.GetComponent <Dragable>();

        if (dropedObject != null && !occupied)
        {
            // removing the object from the previous DropZone && unregistering it
            if (dropedObject.GetDropZoneParentK() != null)
            {
                DropZone_Katakana dod = dropedObject.GetDropZoneParentK(); // Droped Object Dropzone
                int dodsn             = dod.GetSlotNumber();               // Droped Object Dropzone Slot Number
                dod.objectInThisSpot = null;
                GCDnD.unsetInputKatakana(dodsn);
            }

            dropedObject.parentToReturnTo = this.transform;
            objectInThisSpot = eventData.pointerDrag;

            int slotNum = this.GetSlotNumber();
            GCDnD.setInputHirgana(slotNum, eventData.pointerDrag.name);

            this.transform.GetComponent <Image>().color = colorWhite;
        }
        else if (dropedObject != null && occupied)
        {
            int slotNum = -1;

            // Object In this spot handler for moving to new spot
            Transform         parentTransform = dropedObject.parentToReturnTo;
            DropZone_Katakana parentDropZone  = parentTransform.GetComponent <DropZone_Katakana>();
            if (parentDropZone != null)
            {
                parentDropZone.objectInThisSpot = objectInThisSpot;
            }

            objectInThisSpot.GetComponent <Dragable>().parentToReturnTo = dropedObject.parentToReturnTo;
            objectInThisSpot.transform.SetParent(dropedObject.parentToReturnTo);
            objectInThisSpot.transform.SetSiblingIndex(dropedObject.GetPlaceholderSiblingIndex());
            if (dropedObject.GetDropZoneParentK() != null)
            {
                slotNum = dropedObject.GetDropZoneParentK().GetSlotNumber();
                GCDnD.setInputHirgana(slotNum, objectInThisSpot.name);
            }
            dropedObject.parentToReturnTo.transform.GetComponent <Image>().color = colorWhite;

            // Object coming into this spot handler
            dropedObject.parentToReturnTo = this.transform;
            eventData.pointerDrag.transform.SetParent(this.transform);
            objectInThisSpot = eventData.pointerDrag;
            slotNum          = this.GetSlotNumber();
            GCDnD.setInputHirgana(slotNum, eventData.pointerDrag.name);
            this.transform.GetComponent <Image>().color = colorWhite;
        }

        //Debug.Log("Occupied = " + occupied);
    }
예제 #16
0
 public void AcceptDrag(Dragable target, bool notify = true)
 {
     target.transform.SetParent(transform);
     target.GetComponent <RectTransform>().localPosition = Vector3.zero;
     if (notify)
     {
         OnDropEvent.Invoke(target.gameObject, index);
     }
 }
예제 #17
0
        public void SetData(RectTransform dragableArea, Vector3 pos)
        {
            GetComponent<RectTransform>().localPosition = pos;

            myArea = dragableArea;
            dragableInterface = GetComponent<Dragable>();
            if (dragableInterface)
                dragableInterface.SetData(myArea);
        }
예제 #18
0
    public void OnDrop(PointerEventData eventData)
    {
        Dragable d = eventData.pointerDrag.GetComponent <Dragable>();

        if (d != null && this.transform.childCount > 0)
        {
            d.parentToReturnTo = this.transform;
        }
    }
예제 #19
0
    public void OnDrop(PointerEventData pointerData)
    {
        Dragable d = pointerData.pointerDrag.GetComponent <Dragable> ();

        if (d != null)
        {
            d.parentReturn = this.transform;
        }
    }
예제 #20
0
    /// <summary>
    /// Finalise and place this object and all subsequent clones.
    /// </summary>
    void FinalisePositions()
    {
        PlaceObject();

        foreach (GameObject clone in clones)
        {
            Dragable script = clone.GetComponent <Dragable>();
            script.PlaceObject();
        }
    }
예제 #21
0
    public void OnDrop(PointerEventData eventData)
    {
        Dragable d = eventData.pointerDrag.GetComponent <Dragable>();

        if (d != null)
        {
            d.parentToReturnTo = this.transform;
            Hand[d.placeholder.transform.GetSiblingIndex()] = d.imagename;
        }
    }
예제 #22
0
    public void OnDrop(PointerEventData eventData)
    {
        Debug.Log("on drop" + eventData.pointerDrag.name + "Was drop on " + gameObject.name);
        Dragable d = eventData.pointerDrag.GetComponent <Dragable>();

        if (d != null)
        {
            d.parremtToReturnTo = this.transform;
        }
    }
예제 #23
0
    public void OnDrop(PointerEventData eventData)
    {
        Dragable block = eventData.pointerDrag.GetComponent <Dragable>();

        if (block != null)
        {
            block.parentToReturnTo = this.transform;
            block.transform.Rotate(0, 0, 90);
            // or -90
        }
    }
예제 #24
0
 private void Update()
 {
     if (Input.GetMouseButtonUp(0) || TimeController.Running)
     {
         Target = null;
     }
     else if (Input.GetMouseButton(0))
     {
         Drag();
     }
 }
예제 #25
0
    public void OnDrop(PointerEventData evenData)
    {
        Dragable drag = evenData.pointerDrag.GetComponent <Dragable>();

        if (drag != null)
        {
            if (this.transform.childCount < slotDisponibles)
            {
                drag.ObjetoPadreReturn = this.transform;
            }
        }
    }
예제 #26
0
    public void OnDrop(PointerEventData eventData)
    {
        Debug.Log(eventData.pointerDrag.name + " was dropped on " + gameObject.name);

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

        if (d != null)
        {
            d.parentToReturnTo = this.transform;
            // CheckAfterDrop();
        }
    }
예제 #27
0
    public int GetUniqueID(Dragable dObject, Card tempCardScript, Dropzone tempDropZone, Controler Tcontrol)
    {
        //dObject.returnParent.gameObject.GetComponent<Hand>().cards.Remove(tempCardScript);
        dObject.returnParent = this.transform;
        tempDropZone.AddCard(tempCardScript);
        Hand THand = Tcontrol.hands[Tcontrol.turn];
        int  UID   = GetCard(THand, tempCardScript);

        Remove(tempCardScript, THand);
        Tcontrol.ifDisplay.setText(Tcontrol.UpdateInfo(0));
        return(UID);
    }
        public async void GivenDragableEntity_WhenINvokingDragCommand_ThenItRaisesEvent()
        {
            DialogViewModelBaseFixture dialogVmSubject = new DialogViewModelBaseFixture();
            Dragable dragable = new Dragable();
            string   response = null;

            dragable.DragActionEvent += e => response = e.Message;
            await Task.Run(() => dragable.DragMove());


            Assert.Equal(dragable.GetHashCode().ToString(), response);
            dragable.DragActionEvent -= e => response = e.Message;
        }
예제 #29
0
    public void OnPointerEnter(PointerEventData pointerData)
    {
        if (pointerData.pointerDrag == null)
        {
            return;
        }
        Dragable d = pointerData.pointerDrag.GetComponent <Dragable> ();

        if (d != null)
        {
            d.parentTemp = this.transform;
        }
    }
예제 #30
0
    public void OnPointerExit(PointerEventData eventData)
    {
        if (eventData.pointerDrag == null)
        {
            return;
        }

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

        if (d != null)
        {
            d.overTable = false;
        }
    }
    void PickupArtefact()
    {
        draggedObject = hitInfo.collider.gameObject.GetComponent<Dragable>();
        if(draggedObject.IsDragging) return;

        isDraggingArtefact = true;
        draggedObject.hitPoint = hitInfo.point;

        draggedObject.playerTransform = this.transform;
        draggedObject.StartDragging();
        CmdChangeAuthority(draggedObject.GetComponent<NetworkIdentity>().netId, GetComponent<NetworkIdentity>().netId, true);

        rotateArtefactIcon.PopUp();
        dropArtefactIcon.PopUp();
    }
예제 #32
0
	public void DragBind(Dragable drag)
	{
		if (drag != null) {
			if(drag.Meta != null)
			{
				if(drag.Meta.Data != null)
				{
				Item i = (Item)drag.Meta.Data;
				Debug.LogWarning(i.Name);
				}
			}
		}
		//Debug.Log ("The drag is: "+drag);
	}