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(); } }
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(); } }
public void DeleteCell(DropHandler handler) // подбор предмета { if (handler.AddItemToInventory(item)) { Destroy(gameObject); } }
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; } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnDragOverEvent(object sender, DragEventArgs e) { if (DropHandler != null) { DropHandler.OnDragOver(sender, e); } }
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); } }
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); }); }); } }
public App() { _userSettings = new UserSettings(); ProcessSettings(); DropHandler.RegisterDataHandlers(); }
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); }
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); } } }
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(); }
/// <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; } }
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")); } }
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); } }
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); }
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); } }
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); } } }
/// <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); } }
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); } } }
public void Drop(IDropInfo dropInfo) { DropHandler.Drop(dropInfo); Messanger.Write(); SpiritListDropEvent?.Invoke(); }
public void DragOver(IDropInfo dropInfo) { DropHandler.DragOver(dropInfo); }
private void Awake() { instance = this; }
public bool DropOneOfType(CollectibleItem.ItemType itemType, DropHandler handler = null) { CollectibleItem item = items.Find(i => i.itemType == itemType); return(Drop(item, handler)); }
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; } }
public EpiPlanViewModel() { dropHandler = new DragDropHandler(); DropHandler.AddHandler(typeof(ScheduleTasksPresenter), typeof(BookedOrder), AddOrder); }
// Start is called before the first frame update void Start() { dh = GameObject.FindWithTag("GameController").GetComponent <GameManager>().dh; }
/* ============================================================================ 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"); } } }
public bool Drop(int index, DropHandler handler = null) { CollectibleItem item = items[index]; return(Drop(item, handler)); }
private void Awake() { dropHandler = GetComponent <DropHandler>(); dropHandler.zc = this; }