private void LateUpdate() { if (this.currentTask == null && this.taskQueue.Count > 0) { this.currentTask = this.taskQueue[0]; this.taskQueue.RemoveAt(0); UIAssets.LoadWindowAsync(this.currentTask.windowName, (bool ok, UnityEngine.Object _resource) => { try { if (this.currentTask != null) { this.currentTask.Done(ok, _resource); this.currentTask = null; } } catch (Exception ex) { DebugEx.Log(ex); } finally { PleaseWait.Instance.Hide(PleaseWait.WaitType.WindowLoad); } }); } }
private void Awake() { if (instance == null) { instance = this; } }
public static HeadUpGuild Get() { if (pool == null) { pool = GameObjectPoolUtil.Create(UIAssets.LoadPrefab("HeadUpGuild")); } var gameObject = pool.Get(); return(gameObject.GetComponent <HeadUpGuild>()); }
public static void SetSprite(this Image image, int id) { if (image == null) { return; } var config = IconConfig.Get(id); if (config != null) { image.overrideSprite = UIAssets.LoadSprite(config.folder, config.assetName); } }
public static GameObject CreateElement(string sourceName, string name) { var prefab = UIAssets.LoadPrefab(sourceName); if (prefab == null) { return(null); } var instance = GameObject.Instantiate(prefab); instance.name = string.IsNullOrEmpty(name) ? sourceName : name; return(instance); }
public static DamageNum Get(DamageNum.Pattern pattern) { var intPattern = (int)pattern; if (pools.ContainsKey(intPattern)) { pools[intPattern] = GameObjectPoolUtil.Create(UIAssets.LoadPrefab("DamageNum_" + intPattern)); } var pool = pools[intPattern]; var gameObject = pool.Get(); return(gameObject.GetComponent <DamageNum>()); }
private void GetInstance(WindowType type) { if (!this.windows.ContainsKey(type)) { var name = StringUtil.Contact(type, "Win"); var prefab = UIAssets.LoadWindow(name); var instance = GameObject.Instantiate(prefab); instance.name = name; var window = instance.GetComponent <Window>(); if (window != null) { this.windows[type] = window; } } }
public override View GetView(int position, View convertView, ViewGroup parent) { View v = convertView; if (v == null) { v = ((LayoutInflater)Context.GetSystemService(Context.LayoutInflaterService)).Inflate(Resource.Layout.WhiteCard, null); } if (_list.Count() > position) { var item = _list.ElementAt(position); UIAssets.PrepareWhiteCard(v, item); } return(v); }
private void UpdateCurrentQuestion() { var currentQuestion = CardsAgainstHumility.CurrentQuestion; if (CurrentQuestionView != null) { if (currentQuestion == null || CardsAgainstHumility.GameOver) { CurrentQuestionView.Visibility = ViewStates.Invisible; } else { UIAssets.PrepareBlackCard(CurrentQuestionView, currentQuestion); CurrentQuestionView.Visibility = ViewStates.Visible; } } }
private void ShowWinnerModal() { var RoundWinner = (CardsAgainstHumility.RoundWinner == CardsAgainstHumility.PlayerName ? "You" : CardsAgainstHumility.RoundWinner); var currentQuestion = CardsAgainstHumility.CurrentQuestion; var winningAnswer = new WhiteCard(CardsAgainstHumility.WinningCard, 20); RunOnUiThread(() => { // Prepare the builder var dlg = new Dialog(this); var view = LayoutInflater.Inflate(Resource.Layout.RoundWinnerAnnouncement, null); // Show the winner's name var winnerName = view.FindViewById <TextView>(Resource.Id.wm_Winner); winnerName.SetTypeface(UIAssets.AppFont, TypefaceStyle.Normal); winnerName.Text = $"{RoundWinner} won the round"; winnerName.SetTextSize(ComplexUnitType.Dip, 16); // Prepare the black card var blackCard = view.FindViewById <View>(Resource.Id.wm_BlackCard); UIAssets.PrepareBlackCard(blackCard, currentQuestion); // Prepare the white card var whiteCard = view.FindViewById <FrameLayout>(Resource.Id.wm_WhiteCard); UIAssets.PrepareWhiteCard(whiteCard, winningAnswer); // Place the white card just below the bottom of the black card's text PlaceWhiteCardBelowBlackCardText(whiteCard, blackCard); // Link up the close button var closeBtn = view.FindViewById <Button>(Resource.Id.wm_closeBtn); closeBtn.SetTypeface(UIAssets.AppFont, TypefaceStyle.Normal); closeBtn.Click += (owner, args) => { dlg.Dismiss(); }; // Show the modal dlg.AddContentView(view, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent)); dlg.Window.SetBackgroundDrawable(new ColorDrawable(Color.Transparent)); dlg.Show(); }); }
private void UpdateSelectedCardView() { bool showSelectedCardView = false; WhiteCard whiteCard = _selectedCard; if (CardsAgainstHumility.GameStarted) { if (CardsAgainstHumility.IsCardCzar) { if (CardsAgainstHumility.WinningCard != null) { if (whiteCard == null) { whiteCard = new WhiteCard(CardsAgainstHumility.WinningCard, 20); } showSelectedCardView = true; } } else { if (CardsAgainstHumility.SelectedCard != null) { showSelectedCardView = true; } } } if (CardsAgainstHumility.GameOver) { showSelectedCardView = false; } if (showSelectedCardView) { UIAssets.PrepareWhiteCard(SelectedAnswerView, whiteCard); // Place the white card just below the bottom of the black card's text PlaceWhiteCardBelowBlackCardText(SelectedAnswerView, CurrentQuestionView); SelectedAnswerView.Visibility = ViewStates.Visible; } else { SelectedAnswerView.Visibility = ViewStates.Invisible; } }
private void OnLoadWidget(bool ok, UnityEngine.Object @object) { if (ok && @object != null) { var prefab = @object as GameObject; var name = prefab.name; var exist = this.widgets.Exists((x) => { return(x != null && x.name == name); }); if (!exist) { var instance = GameObject.Instantiate(prefab); var widget = instance.GetComponent <Widget>(); this.widgets.Add(widget); instance.name = name; UIAssets.UnLoadWindowAsset(name); widget.rectTransform.MatchWhith(this.setting.content); widget.SetActive(true); } } else { DebugEx.LogFormat("{0}资源不存在,请检查!", this.name); } }
public void SetWidgetActive <T>(bool value) where T : Widget { var widget = this.widgets.Find((x) => { return(x != null && x is T); }); if (value) { if (widget != null) { widget.SetActive(true); } else { var name = typeof(T).Name; UIAssets.LoadWindowAsync(name, this.OnLoadWidget); } } else { if (widget != null) { widget.SetActive(false); } } }
protected override void OnCreate(Bundle bundle) { CardsAgainstHumility.InitDefaultValues(new SettingsLoader(this), new NetServices.NetServices()); dialogBuilder = new AlertDialog.Builder(this, 0); base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); UIAssets.Initialize(Assets); var tv = FindViewById <TextView>(Resource.Id.main_logo1); if (tv != null) { tv.SetTypeface(UIAssets.AppFont, TypefaceStyle.Normal); try { tv.StartAnimation(logo1Animation); } catch (Exception ex) { Console.Error.WriteLine("Error occurred while animating the logo: {0}", ex.Message); } } tv = FindViewById <TextView>(Resource.Id.main_logo2); if (tv != null) { tv.SetTypeface(UIAssets.AppFont, TypefaceStyle.Normal); try { tv.StartAnimation(logo2Animation); } catch (Exception ex) { Console.Error.WriteLine("Error occurred while animating the logo: {0}", ex.Message); } } tv = FindViewById <TextView>(Resource.Id.main_logo3); if (tv != null) { tv.SetTypeface(UIAssets.AppFont, TypefaceStyle.Normal); try { tv.StartAnimation(logo3Animation); } catch (Exception ex) { Console.Error.WriteLine("Error occurred while animating the logo: {0}", ex.Message); } } tv = FindViewById <TextView>(Resource.Id.main_logo4); if (tv != null) { tv.SetTypeface(UIAssets.AppFont, TypefaceStyle.Normal); try { tv.StartAnimation(logo4Animation); } catch (Exception ex) { Console.Error.WriteLine("Error occurred while animating the logo: {0}", ex.Message); } } tv = FindViewById <TextView>(Resource.Id.main_logo5); if (tv != null) { tv.SetTypeface(UIAssets.AppFont, TypefaceStyle.Normal); try { tv.StartAnimation(logo4Animation); } catch (Exception ex) { Console.Error.WriteLine("Error occurred while animating the logo: {0}", ex.Message); } } createButton = FindViewById <Button>(Resource.Id.main_btnCreateGame); joinButton = FindViewById <Button>(Resource.Id.main_btnJoinGame); settingsButton = FindViewById <Button>(Resource.Id.main_btnSettings); quitButton = FindViewById <Button>(Resource.Id.main_btnQuitGame); if (createButton != null) { createButton.Click += delegate { StartActivity(typeof(CreateGameActivity)); }; } else { Console.WriteLine("Unable to get Create Button"); } if (joinButton != null) { joinButton.Click += delegate { StartActivity(typeof(GameBrowserActivity)); }; } else { Console.WriteLine("Unable to get Join Button"); } if (settingsButton != null) { settingsButton.Click += delegate { StartActivity(typeof(SettingsActivity)); }; } else { Console.WriteLine("Unable to get Settings Button"); } if (quitButton != null) { quitButton.Click += delegate { Finish(); }; } else { Console.WriteLine("Unable to get Quit Button"); } }