상속: MonoBehaviour, IDropHandler, IPointerEnterHandler, IPointerExitHandler
    public void Stock()
    {
        dh      = GameObject.FindWithTag("GameController").GetComponent <GameManager>().dh;
        toStock = new ShopItemButton[2];
        GameObject[] ts = GameObject.FindGameObjectsWithTag("ShopItem");
        int          i  = 0;

        foreach (GameObject t in ts)
        {
            toStock[i] = t.GetComponent <ShopItemButton>();
            i++;
        }
        foreach (ShopItemButton item in toStock)
        {
            string itemToStock = "Ring Of Health";
            if (dh.dropsLeft.Count > 0)
            {
                int randomIdx = (int)Mathf.Floor(UnityEngine.Random.Range(0f, dh.dropsLeft.Count));
                //Debug.Log(randomIdx);
                //Debug.Log(dh.dropsLeft.Count);
                itemToStock = dh.dropsLeft[randomIdx];
            }
            item.Stock(itemToStock);
            item.UpdateSprite();
        }
    }
예제 #2
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();
        }
    }
예제 #3
0
파일: CellDrop.cs 프로젝트: Deprion/LiteRPG
 public void DeleteCell(DropHandler handler) // подбор предмета
 {
     if (handler.AddItemToInventory(item))
     {
         Destroy(gameObject);
     }
 }
예제 #4
0
    public void GenerateQuestion()
    {
        GenerateRandomList();
        for (int i = 0; i < questions.Length; i++)
        {
            random = UnityEngine.Random.Range(0, 3);
            int staticI = i;
            int Index   = RandomList.ElementAt(staticI);
            questions[staticI].sprite = tartgetSprites[Index];
            DropHandler drop = questions[staticI].GetComponent <DropHandler>();
            drop.sprite = sh[Index].sprites[random];
            drop.id     = Index;

            int aIndex = RandomIndex.ElementAt(staticI);
            answers[aIndex].color  = Color.white;
            answers[aIndex].sprite = sh[Index].sprites[random];
            DragHandler drag = answers[aIndex].GetComponent <DragHandler>();
            drag.id = Index;

            if (startPos == null)
            {
                startPos = new Vector3[]  {
                    answers[0].gameObject.transform.position,
                    answers[1].gameObject.transform.position,
                    answers[2].gameObject.transform.position,
                    answers[3].gameObject.transform.position,
                };
            }
            answers[aIndex].gameObject.transform.position = questions[staticI].gameObject.transform.position;
        }
    }
예제 #5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnDragOverEvent(object sender, DragEventArgs e)
 {
     if (DropHandler != null)
     {
         DropHandler.OnDragOver(sender, e);
     }
 }
예제 #6
0
        public void InsertToken(GameObject token, GameObject target)
        {
            DropHandler dropHandler = target.GetComponent <DropHandler>();

            if (dropHandler.token == null)
            {
                foreach (Transform box in this.boxes)
                {
                    if (box.GetComponent <DropHandler>().token == null)
                    {
                        box.GetComponent <DropHandler>().DropNew(token);
                        break;
                    }
                }
            }
            else
            {
                for (int i = this.maxLength - 1; i > dropHandler.id; i--)
                {
                    GameObject boxToken = this.boxes[i - 1].GetComponent <DropHandler>().token;
                    if (boxToken != null)
                    {
                        this.boxes[i].GetComponent <DropHandler>().Drop(boxToken);
                    }
                }
                target.GetComponent <DropHandler>().DropNew(token);
            }
        }
예제 #7
0
        private void ImageEditorWindow_Drop(object sender, DragEventArgs e)
        {
            //Caso sejam arquivos de imagem
            string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
            if (files != null)
            {
                AddLayer(DropHandler.HandleFilesDrop(files), e.GetPosition(layersGrid));
                return;
            }

            //Caso seja uma url arrastada do browser
            object dropedFromBrowser = e.Data.GetData(DataFormats.Html);

            if (dropedFromBrowser != null)
            {
                LoadingSpiner loading = new LoadingSpiner {
                    Margin = new Thickness(e.GetPosition(layersGrid).X, e.GetPosition(layersGrid).Y, 0, 0)
                };
                mainGrid.Children.Add(loading);
                Task.Run(() =>
                {
                    byte[] imageBytes = DropHandler.GetImageBytes(dropedFromBrowser);
                    Dispatcher.Invoke(() =>
                    {
                        AddLayer(DropHandler.HandleHtmlDrop(imageBytes), e.GetPosition(layersGrid));
                        mainGrid.Children.Remove(loading);
                    });
                });
            }
        }
예제 #8
0
        public App()
        {
            _userSettings = new UserSettings();

            ProcessSettings();

            DropHandler.RegisterDataHandlers();
        }
예제 #9
0
        public void SwitchToken(GameObject source, GameObject target)
        {
            GameObject  token             = target.GetComponent <DropHandler>().token;
            DropHandler targetDropHandler = target.GetComponent <DropHandler>();
            DropHandler sourceDropHandler = source.GetComponent <DropHandler>();

            targetDropHandler.Drop(sourceDropHandler.token);
            sourceDropHandler.Drop(token);
        }
예제 #10
0
 public void DropAllOfType(CollectibleItem.ItemType itemType, DropHandler handler = null)
 {
     if (handler != null)
     {
         foreach (CollectibleItem item in items.FindAll(i => i.itemType == itemType))
         {
             Drop(item, handler);
         }
     }
 }
예제 #11
0
 public void SetUp()
 {
     _eventAggregator = new UnitTestEventAggregator();
     _dispatcher      = new UnitTestDispatcher();
     _ops             = new MockLibraryOperations(_eventAggregator);
     _errorHandler    = new MockErrorHandler();
     _fileValidator   = new MockFileValidator();
     _view            = new MockLibraryView(_dispatcher.Dispatcher, _ops, _errorHandler, _fileValidator, "", _eventAggregator);
     _dropHandler     = new DropHandler();
 }
예제 #12
0
        /// <summary>Forwards the DragEnter event to the first handler that says it handles it</summary>
        private void HandleDragEnter(object sender, DragEventArgs args)
        {
            args.Effect = DragDropEffects.None;
            m_preferred = null;

            foreach (var handler in m_handlers)
            {
                if (!handler(sender, args, EDrop.Enter))
                {
                    continue;
                }
                m_preferred = handler;
                return;
            }
        }
예제 #13
0
    void Update()
    {
        foreach (KeyValuePair <KeyCode, GameObject> pair in buttonsDict)
        {
            if (Input.GetKeyDown(pair.Key))
            {
                OnKeyPress(pair.Value);
            }
        }

        disableInactive();

        if (Input.GetKeyDown(KeyCode.Q) && activeButton)
        {
            DropHandler.Drop(activeButton.GetComponentInChildren <ItemStack>(), ObjectHelper.getParentGameObject(activeButton, "Player"));
        }
    }
예제 #14
0
    public void Switch(DropHandler other, bool notify = true)
    {
        Dragable ownDragable = GetComponentInChildren <Dragable>();

        ownDragable.transform.SetParent(other.transform);
        ownDragable.GetComponent <RectTransform>().localPosition = Vector3.zero;
        Dragable otherDragable = other.GetComponentInChildren <Dragable>();

        otherDragable.transform.SetParent(transform);
        otherDragable.GetComponent <RectTransform>().localPosition = Vector3.zero;
        if (notify)
        {
            OnDropEvent.Invoke(other.transform.gameObject, index);
            other.OnDropEvent.Invoke(ownDragable.gameObject, other.index);
            OnSwapEvent.Invoke(other.index, index);
        }
    }
예제 #15
0
    static public bool Drop(ItemStack stack, GameObject player)
    {
        if (!DropHandler.OnDropBegin(stack, player))
        {
            return(false);
        }
        if (!DropHandler.OnDrop(stack, player))
        {
            return(false);
        }
        if (!DropHandler.OnDropEnd(stack, player))
        {
            return(false);
        }

        return(true);
    }
예제 #16
0
    public bool Drop(CollectibleItem item, DropHandler handler = null)
    {
        if (item != null)
        {
            if (handler != null)
            {
                handler.Invoke(item);
            }
            UpdateInventoryLabel(item.itemType, -1);

            items.Remove(item);
            return(true);
        }
        else
        {
            return(false);
        }
    }
예제 #17
0
    public void OnDrop(PointerEventData eventData)
    {
        GameObject box  = eventData.pointerDrag;
        GameObject slot = gameObject;

        //Debug.Log(box.name + " was dropped on " + slot.name);

        GameObject  dropArea    = transform.parent.gameObject;
        DropHandler dropHandler = dropArea.GetComponent <DropHandler>();

        // checks that box is in DropArea or has a DropArea

        if (dropHandler != null)
        {
            if (box != null && slot != null)
            {
                dropHandler.HandleDrop(box, slot);
            }
        }
    }
예제 #18
0
        /// <summary>Forwards the DragOver event to the handler that handled DragEnter if it exists.
        /// Otherwise, forwards to the first handler that says it can handle it, which then becomes the preferred handler</summary>
        private void HandleDragOver(object sender, DragEventArgs args)
        {
            args.Effect = DragDropEffects.None;

            // If we have a preferred handler, let it handle it
            if (m_preferred != null)
            {
                m_preferred(sender, args, EDrop.Over);
                return;
            }

            // Otherwise, look for one that handles it
            foreach (var handler in m_handlers)
            {
                if (!handler(sender, args, EDrop.Over))
                {
                    continue;
                }
                m_preferred = handler;
                return;
            }
        }
        public void OnDrop(PointerEventData eventData)
        {
            var cardModel = CardModel.GetPointerDrag(eventData);

            if (cardModel == null ||
                cardModel.ParentCardZone != null && cardModel.ParentCardZone.type != CardZoneType.Area ||
                cardModel.PlaceHolderCardZone != null && cardModel.PlaceHolderCardZone.type != CardZoneType.Area)
            {
                return;
            }

            var drawerViewer = DropHandler as DrawerViewer;

            if (drawerViewer != null && Index != null)
            {
                drawerViewer.AddCard(cardModel.Value, Index ?? 0);
            }
            else
            {
                DropHandler.OnDrop(cardModel);
            }
        }
예제 #20
0
    public void SwtichMap(ulong areaId, Vector3 worldPos)
    {
        StateChangeHandler.HandleChangeState();
        DropHandler.HandleSyncDrop();
        SkillBroadCastRPCNet.Handle();

        LoadingPanelParamere loadingPanelParamere = MessageSingleton.Get <LoadingPanelParamere>();

        loadingPanelParamere.OnShown = () =>
        {
            GameplayProxy gameplayProxy = GameFacade.Instance.RetrieveProxy(ProxyName.GameplayProxy) as GameplayProxy;
            if (gameplayProxy != null)
            {
                GameplayManager.Instance.Clear();
                gameplayProxy.SetCurrentAreaUid(areaId);
                Vector3 gameWorldPos = gameplayProxy.WorldPositionToServerAreaOffsetPosition(worldPos);
                Map.MapManager.GetInstance().SetPlayerPosition(worldPos, gameWorldPos);
            }
            OnSwitchMapLoadingPanelShown();
        };
        UIManager.Instance.OpenPanel(UIPanel.LoadingSecondPanel, loadingPanelParamere);

        CfgEternityProxy cfgEternityProxy = GameFacade.Instance.RetrieveProxy(ProxyName.CfgEternityProxy) as CfgEternityProxy;
        uint             lastGamingMapId  = cfgEternityProxy.GetLastGamingMapId();
        uint             gamingMapId      = cfgEternityProxy.GetCurrentGamingMapId();

        if (lastGamingMapId != Map.Constants.NOTSET_MAP_UID)
        {
            int lastMapType = cfgEternityProxy.GetMapByKey(lastGamingMapId).Value.GamingType;
            int mapType     = cfgEternityProxy.GetMapByKey(gamingMapId).Value.GamingType;
            if (lastMapType == 4 && mapType == 4)
            {
                WwiseUtil.PlaySound(WwiseManager.voiceComboID, WwiseMusicSpecialType.SpecialType_Voice_StartCrossingTheGate, WwiseMusicPalce.Palce_1st, false, null);
            }
        }
    }
예제 #21
0
 public void Drop(IDropInfo dropInfo)
 {
     DropHandler.Drop(dropInfo);
     Messanger.Write();
     SpiritListDropEvent?.Invoke();
 }
예제 #22
0
 public void DragOver(IDropInfo dropInfo)
 {
     DropHandler.DragOver(dropInfo);
 }
예제 #23
0
 private void Awake()
 {
     instance = this;
 }
예제 #24
0
    public bool DropOneOfType(CollectibleItem.ItemType itemType, DropHandler handler = null)
    {
        CollectibleItem item = items.Find(i => i.itemType == itemType);

        return(Drop(item, handler));
    }
예제 #25
0
    public static void Display(List <string> Directories, List <string> Files, bool FromSearch)
    {
        // Delete all previous created GameObjects
        DestroyAll();

        // Scroll to top
        if (!FromSearch)
        {
            GameObject.Find("Files").GetComponent <ScrollRect> ().verticalScrollbar.value = 1;
        }

        // Combine directories and folders
        List <string> results       = new List <string> (Directories);
        int           lastDirectory = results.Count;

        results.AddRange(Files);

        // Get current GameObject
        GameObject gameObject = GameObject.Find("FileContent");

        // Create item for ech entry in results
        foreach (string item in results)
        {
            // Test if item is directory
            bool isDir = Directory.Exists(item);

            // Create GameObject
            GameObject obj = new GameObject(item);
            obj.transform.SetParent(gameObject.transform);

            // Add Horizontal Layout Group
            HorizontalLayoutGroup hlg = obj.AddComponent <HorizontalLayoutGroup> ();
            hlg.spacing                = 20;
            hlg.childAlignment         = TextAnchor.MiddleLeft;
            hlg.childForceExpandWidth  = false;
            hlg.childForceExpandHeight = true;

            // Set RectTransform
            RectTransform trans = obj.GetComponent <RectTransform> ();
            trans.localScale = Vector3.one;


            // Create image GameObject
            GameObject goImage = new GameObject("Image");
            goImage.transform.SetParent(obj.transform);

            // Add text
            TextUnicode textImage = goImage.AddComponent <TextUnicode> ();

            textImage.color     = Settings.GetColorFromRgb(180, 180, 180);
            textImage.text      = isDir ? IconFont.FOLDER : IconFont.MUSIC;
            textImage.alignment = TextAnchor.MiddleLeft;
            textImage.font      = IconFont.font;
            textImage.fontSize  = 30;

            // Add RectTransform
            RectTransform imageTrans = goImage.GetComponent <RectTransform> ();
            imageTrans.localScale = Vector3.one;

            // Add Layout Element
            LayoutElement imageLayout = goImage.AddComponent <LayoutElement> ();
            imageLayout.minWidth = 30;


            // Create text GameObject
            GameObject goText = new GameObject("Text");
            goText.transform.SetParent(obj.transform);

            // Add RectTransform element
            RectTransform textTrans = goText.AddComponent <RectTransform> ();
            textTrans.pivot      = new Vector2(0.5f, 0.5f);
            textTrans.localScale = Vector3.one;

            // Add Layout Element
            LayoutElement layoutElement = goText.AddComponent <LayoutElement> ();
            layoutElement.minHeight       = 30;
            layoutElement.preferredHeight = 30;

            // Add Drag Handler
            if (!isDir)
            {
                goText.AddComponent <DragHandler> ();
            }

            // Add Button
            Button button = goText.AddComponent <Button> ();
            button.transition = Selectable.Transition.Animation;

            Navigation nav = new Navigation();
            nav.mode          = Navigation.Mode.None;
            button.navigation = nav;

            // Add OnClick Handler
            string currentItem = item;
            if (isDir)
            {
                button.onClick.AddListener(delegate {
                    Initialize(currentItem);
                });
            }
            else
            {
                string currentFile = item;
                button.onClick.AddListener(delegate {
                    // Get reference to playlist object
                    Playlist pl = GameObject.Find("PlaylistContent").GetComponent <Playlist> ();

                    // Get file object if available
                    FileObj file = pl.GetFile(currentItem);

                    // Get source folder object
                    SourceFolder sf = GameObject.Find("FileContent").GetComponent <SourceFolder> ();

                    if (sf.DoubleClicked(goText))
                    {
                        // Get drop area
                        GameObject dropObj = GameObject.FindGameObjectWithTag("PlaylistDrop");

                        // Insert file
                        DropHandler.InsertFile(currentFile, dropObj, dropObj);
                    }
                });
            }

            // Add Animator
            Animator animator = goText.AddComponent <Animator> ();
            animator.runtimeAnimatorController = Resources.Load <RuntimeAnimatorController> ("Animations/MenuButtons");

            // Add Text
            Text text = goText.AddComponent <Text> ();

            text.color     = Color.white;
            text.font      = Resources.Load <Font> ("Fonts/FuturaStd-Book");
            text.text      = Path.GetFileName(item);
            text.fontSize  = 30;
            text.alignment = TextAnchor.MiddleLeft;
        }
    }
예제 #26
0
 public EpiPlanViewModel()
 {
     dropHandler = new DragDropHandler();
     DropHandler.AddHandler(typeof(ScheduleTasksPresenter), typeof(BookedOrder), AddOrder);
 }
예제 #27
0
 // Start is called before the first frame update
 void Start()
 {
     dh = GameObject.FindWithTag("GameController").GetComponent <GameManager>().dh;
 }
예제 #28
0
    /*
    ============================================================================
    Init functions
    ============================================================================
    */
    public void Init()
    {
        this.ClearData();
        this.partyHandler = new PartyHandler();

        if(Application.isPlaying)
        {
            if(this.levelHandler == null)
            {
                GameObject tmp = new GameObject("LevelHandler");
                if(GUISystemType.ORK.Equals(DataHolder.GameSettings().guiSystemType))
                {
                    this.levelHandler = (LevelHandler)tmp.AddComponent("LevelHandler");
                }
                else
                {
                    this.levelHandler = (LevelHandlerGUI)tmp.AddComponent("LevelHandlerGUI");
                }
            }
            if(this.musicHandler == null)
            {
                GameObject tmp = new GameObject("MusicHandler");
                this.musicHandler = (MusicHandler)tmp.AddComponent("MusicHandler");
            }
            if(this.dropHandler == null)
            {
                GameObject tmp = new GameObject("DropHandler");
                this.dropHandler = (DropHandler)tmp.AddComponent("DropHandler");
                this.dropHandler.ClearData();
            }
            if(this.dragHandler == null)
            {
                GameObject tmp = new GameObject("DragHandler");
                this.dragHandler = (DragHandler)tmp.AddComponent("DragHandler");
            }
            if(this.windowHandler == null)
            {
                this.windowHandler = new WindowHandler();
            }
            if(this.guiHandler == null)
            {
                GameObject tmp = new GameObject("GUIHandler");
                this.guiHandler = (GUIHandler)tmp.AddComponent("GUIHandler");
            }
        }
    }
예제 #29
0
    public bool Drop(int index, DropHandler handler = null)
    {
        CollectibleItem item = items[index];

        return(Drop(item, handler));
    }
예제 #30
0
 private void Awake()
 {
     dropHandler    = GetComponent <DropHandler>();
     dropHandler.zc = this;
 }