public void showIcon(int tabindex) { int itemKey = tabIndexToItemType[tabindex]; for (int j = 0; j < _iconSumPerPage; j++) { int itemId = BackpackItemManager.Instance.GetId(itemKey, j); if (itemId <= 0) { UIEventManager.SendEvent(UIEventManager.ET_UI_UPDATE, j.ToString(), _uiType, "Image", "null", "", itemId); } else { UIEventManager.SendEvent(UIEventManager.ET_UI_UPDATE, j.ToString(), _uiType, "Image", "", IconResManager.getIconNameByMId(itemId), itemId); } } // string[] sp = { "," }; // string[] ms = _materialsDic[tabindex].ToString().Split(sp, _iconSumPerPage, System.StringSplitOptions.RemoveEmptyEntries); // for (int j = 0; j < ms.Length; j++) // { // _materials[j] = Int32.Parse(ms[j]); // updateItemIcon(j, IconResManager.getIconNameByMId(Int32.Parse(ms[j]))); // } // cleanIcons(ms.Length); }
public void start() { uiEvnMgr = UIEventManager.Instance(); uiEvnMgr.AddEvent(UIEventManager.EventType.NextTurn, OnNextTurn); effectPool = new GameObject("EffectPool").transform; effectPool.position = new Vector3(0, 50000, 0); }
/*** * @params: * iconsumperpage * iconname * materialdic * iconrespath* * iconprefabpath* * **/ public void initComponents(params object[] paras) { //暂时用同一个size _iconSumPerPage = BackpackItemManager.Instance.GetSize(tabIndexToItemType[0]); string iconName = Convert.ToString(paras[0]); _uiType = (UITypes)paras[1]; _iconResPath = paras[2] == null ? _iconResPath : Convert.ToString(paras[2]); _materials = new int[_iconSumPerPage]; _iconbases = new UIIcon[_iconSumPerPage]; _buttons = new GameObject[_iconSumPerPage]; _bagBtnGrid = this.transform.Find("Grid"); for (int i = 0; i < _iconSumPerPage; i++) { addItemIcon(i); } if (paras[3] != null) { _selectSprite = GameObject.Find(Convert.ToString(paras[3])); _selectSprite.SetActive(false); } GridLayoutGroup glg = _bagBtnGrid.GetComponent <GridLayoutGroup>(); float height = (glg.cellSize.y + glg.spacing.y) * (_iconSumPerPage / 6); RectTransform rtf = _bagBtnGrid.GetComponent <RectTransform>(); rtf.sizeDelta = new Vector2(rtf.sizeDelta.x, height); EventManager.RegisterEvent(UIEventMacro.CLICK_TAB, onClickTab); UIEventManager.RegisterEvent(UIEventManager.ET_UI_CLICK, _uiType.ToString(), onSelect); showIcon(0); }
void RegisterWordHit(ClickAreaCtrl cArea, WordGameObjectCtrl wrd) { if (wrd.isFake) { //Debug.Log("FAKE HIT"); ScoreCtrl.FakeClick(); UIEventManager.FakeWordHitEvent(); return; } hitFX = PoolManager.SpawnObject(successWordHitFX); HitWordFX hitWordFX = hitFX.GetComponent <HitWordFX>(); isPerfect = Mathf.Abs(currentAudioTime - wrd.hitTime) < Config.CLICK_PERFECT_TIME_OFFSET; if (isPerfect) { hitWordFX.perfect = true; } else { hitWordFX.perfect = false; } GameLogger.AddTap(wrd.hitTime, currentAudioTime, wrd.wordData.text); hitFX.transform.position = cArea.gameObject.transform.position; hitWordFX.runAnim(); ScoreCtrl.WordHit(wrd.orderIndex, currentAudioTime, wrd.hitTime, isPerfect); }
public void RandomUpdateItem(string id) { UIEventManager.SendEvent(UIEventManager.ET_UI_UPDATE, id, "Name", "text", "" + Random.Range(100, 99999)); string iconName = textureList[Random.Range(0, 3)]; UIEventManager.SendEvent(UIEventManager.ET_UI_UPDATE, id, "Icon", "", iconName); UIEventManager.SendEvent(UIEventManager.ET_UI_UPDATE, id, "HpBar", "", Random.Range(0f, 1f)); }
static int RemoveListener(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 1); string arg0 = LuaScriptMgr.GetLuaString(L, 1); UIEventManager.RemoveListener(arg0); return(0); }
public void start() { uiEvnMgr = UIEventManager.Instance(); uiEvnMgr.AddEvent(UIEventManager.EventType.NextTurn, OnNextTurn); charInfo = new GameObject[4]; charName = new GameObject[4]; charHP = new GameObject[4]; charVigor = new GameObject[4]; }
public void GenerateTrack() { if (string.IsNullOrEmpty(songDataJsonString) || !audioSource.clip) { UIEventManager.FireAlert("NOT ALL FILES PRESENT", "ERROR"); return; } //songPixelSize = Mathf.CeilToInt(audioSource.clip.length * secondInPixels); songPixelSize = Mathf.CeilToInt(audioSource.clip.length * TimetrackerPanelCtrl.SECOND_IN_PIXELS); int numOfChuncks = Mathf.CeilToInt(audioSource.clip.length / secondsPerWavImage); int samplesInChunk = (int)sampleRate * secondsPerWavImage; //int chunkPixelSize = secondsPerWavImage * secondInPixels; int chunkPixelSize = secondsPerWavImage * TimetrackerPanelCtrl.SECOND_IN_PIXELS; int startSample = 0; int endSample = 0; RawImage wavImageGO; for (int c = 0; c < numOfChuncks; c++) { startSample = samplesInChunk * c; endSample = Mathf.Min(samplesInChunk * (c + 1), audioSource.clip.samples); //chunkPixelSize = Mathf.FloorToInt((endSample - startSample) / (sampleRate / secondInPixels)); chunkPixelSize = Mathf.FloorToInt((endSample - startSample) / (sampleRate / TimetrackerPanelCtrl.SECOND_IN_PIXELS)); wavImageGO = Instantiate(wavImagePrefab, wavimagesPanel.transform, false) as RawImage; wavImageGO.rectTransform.sizeDelta = new Vector2(chunkPixelSize, wavImageHeight); wavImageGO.texture = AudioDrawer.CreateAudioTexturePiece(audioSource.clip, chunkPixelSize, wavImageHeight, Color.grey, startSample, endSample); } //wavImage.rectTransform.sizeDelta = new Vector2(songPixelSize, wavImageHeight); //wavImage.texture = AudioDrawer.CreateAudioTexture(audioSource.clip, songPixelSize, wavImageHeight, Color.grey); // wavImage.texture = AudioDrawer.CreateAudioTexturePiece(audioSource.clip, songPixelSize, wavImageHeight, Color.grey, 0, audioSource.clip.samples); float pozX = 0; float pozY = 0; int numOfwords = songDataFromJson.wordsList.Length; Image wordGO; Button btn; WordButton wordButtonCls; for (int i = 0; i < numOfwords; i++) { // pozX = float.Parse(songDataFromJson.wordsList[i].time) * secondInPixels; pozX = float.Parse(songDataFromJson.wordsList[i].time) * TimetrackerPanelCtrl.SECOND_IN_PIXELS; wordGO = Instantiate(wordPrefabClickable, wordsHolder.transform, false); btn = wordGO.transform.GetComponent <Button>(); wordButtonCls = wordGO.transform.GetComponent <WordButton>(); wordButtonCls.SetWordData(songDataFromJson.wordsList[i]); wordButtonCls.SetDurrationMarker(TimetrackerPanelCtrl.SECOND_IN_PIXELS); //wordButtonCls.wordData = songDataFromJson.wordsList[i]; //wordButtonCls.label.text = wordButtonCls.wordData.text.ToString(); wordGO.name = string.Format("{0}_{1}", songDataFromJson.wordsList[i].text, songDataFromJson.wordsList[i].time); pozY = (150) + ((i % 3) * 20); wordGO.rectTransform.anchoredPosition = new Vector3(pozX, pozY, 0); wordGO.tag = "word"; } }
static int SetEnable(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 2); string arg0 = LuaScriptMgr.GetLuaString(L, 1); bool arg1 = LuaScriptMgr.GetBoolean(L, 2); UIEventManager.SetEnable(arg0, arg1); return(0); }
private void InitEvents() { UIEventManager.RegisterEvent(UIEventManager.ET_UI_CLICK, UITypes.MAIN_BAG.ToString(), onSelectFromBag); EventManager.RegisterEvent(EventMacro.ON_CHANGE_HANDCUBE, onChangeHandeCube); _bagBtn.GetComponent <Button>().onClick.AddListener(delegate() { openBag(); }); }
IEnumerator ShowSaveDialogCoroutine(string jsonToSaveString) { yield return(FileBrowser.WaitForSaveDialog(false, null)); if (FileBrowser.Success) { File.WriteAllText(FileBrowser.Result, jsonToSaveString); UIEventManager.FireAlert("Saved to: " + FileBrowser.Result, "SAVE SUCCESS"); } }
// SAVING SONG public void OpenSaveDialog() { if (string.IsNullOrEmpty(songDataJsonString)) { UIEventManager.FireAlert("NO DATA TO SAVE", "SAVE ERROR"); return; } FileBrowser.SetDefaultFilter(".json"); StartCoroutine(ShowSaveDialogCoroutine()); }
public override void InitElements() { _imageTrans = mTrans.FindChild("Image"); _imageTrans.GetComponent <UGUIImage>().SetPath(_resPath); AddElement("Image", _imageTrans.GetComponent <UGUIImage>()); _button = gameObject.GetComponent <Button>(); _button.onClick.AddListener(delegate() { UIEventManager.SendEvent(UIEventManager.ET_UI_CLICK, _uiType.ToString(), "Image", "", IconResManager.getIconNameByMId(_materialId), _materialId, id); }); }
public static void AddHoldPoints(float timeToBegin, float timeStarted, float durationToHold, float currentTime) { float prc = Mathf.Clamp((currentTime - timeStarted) / durationToHold, 0, 1); float maxPoints = durationToHold * Config.STREAK_MULTIPLIER; if (prc < 1) { currentScore += Config.STREAK_MULTIPLIER * (Mathf.CeilToInt(prc * maxPoints)); UIEventManager.ScoreChangedEvent(); } }
public void PreviewSong() { if (songDataFromJson != null && audioSource.clip != null) { songPlayer.PreviewSong(audioSource, songDataFromJson, float.Parse(speedField.text)); } else { UIEventManager.FireAlert("Load JSON and WAV!", "ERROR"); } }
public void OnGenerateTrackButton() { if (string.IsNullOrEmpty(songDataJsonString) || !audioSource.clip) { UIEventManager.FireAlert("NOT ALL FILES PRESENT", "ERROR"); return; } // Clear the visual representatives for words and wav ResetTrack(); GenerateTrack(); }
public override IMemento <ControlPool> Restore(ControlPool target) { PropertyInfo p = getPropertyInfo(); //System.Reflection.PropertyInfo p = ((Control)selObject).GetType().GetProperty(propertyName); object newpropval = getPropertyValue(); //p.GetGetMethod().Invoke(selObject, null); setPropertyValue(); //p.GetSetMethod().Invoke(selObject, new object[] { propertyValue }); IMemento <ControlPool> inverse = new PropertyOldChangeMemento(propertyName, newpropval, selObject); UIEventManager.showProperty(); return(inverse); }
public void OnPressPlay(int difficulty) { if (string.IsNullOrEmpty(textUIJsonSelected.text) || string.IsNullOrEmpty(textUISongSelected.text)) { Debug.Log("NOT ALL FILES PRESENT"); return; } StaticDataManager.difficulty = difficulty; gameManager.SetActive(true); UIEventManager.PrepareGameFireEvent(); choosePanel.SetActive(false); }
/// <summary> /// 其他UI显示过快可以把这个API给截断,因为其他UI遮挡了Camera的射线检测 /// </summary> /// <param name="go"></param> private void OnPointerUp(GameObject go) { UIEventManager.PointUpEvent(); if (upType == UpEvnetType.OnZoomInPressRelease) { UIEventManager.OnZoomInPressRelease(); } else if (upType == UpEvnetType.OnZoomOutPressRelease) { UIEventManager.OnZoomOutPressRelease(); } }
private static void CheckStreak(int orderIndex) { if (orderIndex - lastOrderIndex == 1) { streak++; UIEventManager.StreakChangedEvent(); } else { ResetStreak(); } lastOrderIndex = orderIndex; }
private void OnPointerDown(GameObject go) { UIEventManager.PointDownEvent(); ChangeEvent(); if (downType == DownEventType.OnZoomInPress) { UIEventManager.OnZoomInPress(); } else if (downType == DownEventType.OnZoomOutPress) { UIEventManager.OnZoomOutPress(); } }
IEnumerator ShowLoadDialogCoroutine(string fileType) { yield return(FileBrowser.WaitForLoadDialog(false, null, "Open " + fileType, "Load")); if (FileBrowser.Success) { StartCoroutine(LoadFile(FileBrowser.Result, fileType)); } else { UIEventManager.FireAlert("Error opening file", "ERROR"); ResetFields(); } }
public XmlHandler(UIEventManager eventManager) { eventManager_m = eventManager; eventManager_m.OnNewCredentials += new UIEventManager.NewCredentialsEvent(eventManager_m_OnNewCredentials); eventManager_m.OnDirectoryChanged += new UIEventManager.DirectoryChangedEvent(eventManager_m_OnDirectoryChanged); if (!File.Exists(configFile_m)) { string xml = "<gitClient><credential><username></username>" + "<password></password></credential><lastLocation></lastLocation></gitClient>"; File.WriteAllText(configFile_m, xml); eventManager_m.TriggerUpdateCredentialsEvent(true); } }
public static void ResetScore() { currentScore = 0; UIEventManager.ScoreChangedEvent(); lastOrderIndex = 0; ResetStreak(); UIEventManager.StreakChangedEvent(); perfectCount = 0; nonPerfectCount = 0; missCount = 0; UIEventManager.PerfectTapCountChangedEvent(); UIEventManager.NonPerfectTapCountChangedEvent(); UIEventManager.MissWordCountChangedEvent(); }
public void CreateTracker() { if (string.IsNullOrEmpty(songDataJsonString) || !audioSource.clip) { UIEventManager.FireAlert("NOT ALL FILES PRESENT", "ERROR"); return; } trackView.SetActive(true); beatSynchroniser.bpm = (float)songDataFromJson.bpm; beatSynchroniser.startDelay = 1; beatCounter.beatValue = SynchronizerData.BeatValue.SixteenthBeat; sixteenNoteToSecondsSize = (60f / (float)songDataFromJson.bpm) / 4f; onePixelToSeconds = sixteenNoteToSecondsSize / sixteenNoteToPixelSize; Debug.Log("sixteenNoteToSecondsSize " + sixteenNoteToSecondsSize); Debug.Log("onePixelToSeconds " + onePixelToSeconds); //populate words //float pozX; //int numOfwords = songDataFromJson.words.Length; //for(int i = 0; i< numOfwords; i++) //{ // pozX = float.Parse(songDataFromJson.timestamps[i]) / onePixelToSeconds; // Debug.Log(pozX); // Instantiate(wordPrefab, wordsHolder.transform, false); // wordPrefab.text = songDataFromJson.words[i].ToString(); // wordPrefab.rectTransform.anchoredPosition= new Vector3(pozX, 0, 0); //} beatCounter.StartCountingBeats(); beatSynchroniser.StartSynchronisedMusic(); rawImg.texture = AudioWaveForm(audioSource.clip, (int)Mathf.Floor(rawImg.rectTransform.rect.width), (int)Mathf.Floor(rawImg.rectTransform.rect.height), new Color(210, 210, 210)); debugString = string.Empty; //float samplesPerQuarterNote = ((float)songDataFromJson.bpm / 60) * 44100; float samplesPerQuarterNote = Mathf.CeilToInt(44100 / ((float)songDataFromJson.bpm / 60)); float samplesPerBar = samplesPerQuarterNote * 4; float barInSong = Mathf.Ceil((float)audioSource.clip.samples / (float)samplesPerBar); debugString = string.Format("Song name: {0} \nSong BPM: {1} \nTotal Samples: {2} \nSamlpes per 1/4 note: {3} \nSamples per bar: {4} \nTotal Bar Count: {5} \nSong Time: {6} sec", songDataFromJson.songname, songDataFromJson.bpm, audioSource.clip.samples, samplesPerQuarterNote, samplesPerBar, barInSong, audioSource.clip.length); debugText.text = debugString; }
protected override void InitEvents() { UIEventManager.RegisterEvent(UIEventManager.ET_UI_CLICK, UITypes.MAIN_BAG.ToString(), onSelectFromBag); EventManager.RegisterEvent(EventMacro.ON_CHANGE_HANDCUBE, onChangeHandeCube); EventManager.RegisterEvent(EventMacro.CLOSE_UI, (object[] paras) => { if ((UITypes)paras[0] == UITypes.CROSS) { return; } if ((UITypes)paras[0] == UITypes.MAIN_BAG) { SetNormalBtnsActive(true); } else if ((UITypes)paras[0] != UITypes.MAIN_UI) { SetAllActive(true); } }); EventManager.RegisterEvent(EventMacro.SHOW_UI, (object[] paras) => { if ((UITypes)paras[0] == UITypes.CROSS) { return; } if ((UITypes)paras[0] == UITypes.MAIN_BAG) { SetNormalBtnsActive(false); } else if ((UITypes)paras[0] != UITypes.MAIN_UI && (UITypes)paras[0] != UITypes.TASK) { SetAllActive(false); } }); _bagBtn.GetComponent <Button>().onClick.AddListener(delegate() { UIManager.Instance.showUI <MaterialBag>(UITypes.MAIN_BAG); }); _systemBtn.GetComponent <Button>().onClick.AddListener(delegate() { OnClickSystemBtn(); }); EventTriggerListener.Get(_btnJump).onDown += On_JumpClickDown; EventTriggerListener.Get(_btnJump).onUp += On_JumpClickUp; }
/// <summary> /// Initialise a new object to access the git client. /// <param name="eventManager">Event manager used throughout app.</param> /// </summary> internal GitClientAccessor(UIEventManager eventManager) { eventManager_m = eventManager; eventManager_m.OnDirectoryChanged += new UIEventManager.DirectoryChangedEvent(eventManager_m_OnDirectoryChanged); eventManager_m.OnNewGitCommandIssued += new UIEventManager.NewGitCommandEvent(eventManager_m_OnNewGitCommandIssued); procInfo_m = new ProcessStartInfo { CreateNoWindow = true, RedirectStandardError = true, RedirectStandardOutput = true, RedirectStandardInput = true, UseShellExecute = false, FileName = "git" }; }
static int _CreateUIEventManager(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 0) { UIEventManager obj = new UIEventManager(); LuaScriptMgr.PushObject(L, obj); return(1); } else { LuaDLL.luaL_error(L, "invalid arguments to method: UIEventManager.New"); } return(0); }
static void InputSystemPage() { GUILayout.Label("Input System package detected", Styles.title); GUILayout.Space(12); GUILayout.Label(@"It seems that you have the Input System configured for your project. In order to make it work with the UI Event Manager, we can create a configured prefab for you.", Styles.body); GUILayout.Space(12); if (GUILayout.Button("Create/Replace", GUILayout.Width(180), GUILayout.Height(32))) { if (AssetDatabase.LoadAssetAtPath <GameObject>("Assets/Resources/UIEventManager.prefab") == null || EditorUtility.DisplayDialog("Prefab already present", "UIEventManager already exists, overwrite?", "Yes", "No")) { var go = UIEventManager.CreateManagerObject(); var prefab = PrefabUtility.SaveAsPrefabAsset(go, "Assets/Resources/UIEventManager.prefab"); DestroyImmediate(go); Selection.activeObject = prefab; } } }
// SAVING SONG public void OpenSaveDialog() { if (wordsHolder.transform.childCount < 1 || wavimagesPanel.transform.childCount < 1) { UIEventManager.FireAlert("Generate track first", "SAVE ERROR"); return; } if (string.IsNullOrEmpty(songDataJsonString)) { UIEventManager.FireAlert("NO DATA TO SAVE", "SAVE ERROR"); return; } FileBrowser.SetDefaultFilter(".json"); StartCoroutine(ShowSaveDialogCoroutine()); }
private static void AddScore(float hitTime, float wordTime, bool isPerfect) { if (isPerfect) { currentScore += Config.POINT_VALUE; perfectCount++; UIEventManager.PerfectTapCountChangedEvent(); } else { currentScore += Config.POINT_VALUE / 2; nonPerfectCount++; UIEventManager.NonPerfectTapCountChangedEvent(); } // ADD STREAK BONUS currentScore += streak * Config.STREAK_MULTIPLIER; UIEventManager.ScoreChangedEvent(); }
void OnEnable() { if (uiEventMgr == null) uiEventMgr = (FindObjectOfType(typeof(UIEventManager)) as UIEventManager); if (dm == null) dm = FindObjectOfType(typeof(DataManager)) as DataManager; currImageID = uiEventMgr.CurrClickImageID; showTestBtn = uiEventMgr.showTestBtn; if (currImageID != -1) { decLabel.text = dm.GetString("Image" + currImageID.ToString() + "Desc"); } TestButton.SetActive(showTestBtn); }
public void initComponents(params object[] paras) { _uiType = (UITypes)paras[0]; _iconContainer = GameObject.Find("BagSelectContainer"); UIEventManager.RegisterEvent(UIEventManager.ET_UI_CLICK, _uiType.ToString(), onSelect); _prefab = _prefab == null?Resources.Load(_iconPrefabPath) as GameObject : _prefab; GameObject icon = GameObject.Instantiate(_prefab) as GameObject; RectTransform rectTrans = icon.GetComponent <RectTransform>(); Vector3 localPosition = rectTrans.anchoredPosition3D; rectTrans.SetParent(_iconContainer.transform); rectTrans.anchoredPosition3D = localPosition; rectTrans.localScale = Vector3.one; icon.AddComponent <UIIcon>(); _iconBase = icon.GetComponent <UIIcon>(); _iconBase.Init("0", _uiType, _iconResPath); _iconBase.setEnable(false); }