void Awake() { if (Instance) { Destroy(this.gameObject); return; } Instance = this; m_UiCameraHolder = new GameObject("UI Camera"); m_UiCameraHolder.AddComponent <Camera>(); m_UiCamera = m_UiCameraHolder.GetComponent <Camera>(); m_UiCamera.clearFlags = CameraClearFlags.Depth; m_UiCamera.nearClipPlane = 0.3f; m_UiCamera.farClipPlane = 600.0f; m_UiCamera.depth = DrawDepth; m_UiCamera.rect = new Rect(0.0f, 0.0f, 1.0f, 1.0f); m_UiCamera.orthographic = true; m_UiCamera.orthographicSize = Screen.height * 0.5f; m_UiCamera.cullingMask = UILayer; m_UiCamera.transform.position = new Vector3(0.0f, 0.0f, -100.0f); // hash table of GUI Renderers m_GUIRenderers = new Dictionary <ulong, MFGuiRenderer>(); m_CachedScreenSize = new Vector2(Screen.width, Screen.height); }
protected override void OnViewShow() { base.OnViewShow(); RegisterButtonDelegate(CLOSE_BUTTON, () => { ForceClose(); }, null); RegisterButtonDelegate(SKIPANIM_BUTTON, () => { MFGuiManager.FlushAnimations(); }, null); m_IsPremiumAccountActive = CloudUser.instance.isPremiumAccountActive; }
void OnDestroy() { MFGuiManager guiManager = MFGuiManager.Instance; if (guiManager) { guiManager.UnregisterPlatform(this); } }
void AnimateWidget(GUIBase_Label label, float source, float target, string format = null) { var animation = MFGuiManager.AnimateWidget(label, source, target); if (animation != null) { animation.Duration = 0.5f; animation.AudioClip = CountDownSound; } }
void AnimateWidget(GUIBase_Label label, string text) { var animation = MFGuiManager.AnimateWidget(label, text); if (animation != null) { animation.Duration = 0.5f; animation.AudioClip = CountDownSound; } }
protected override void OnViewShow() { base.OnViewShow(); // register delegate for close button m_CloseButton.RegisterTouchDelegate(() => { Owner.Back(); SendResult(E_PopupResultCode.Cancel); }); RegisterButtonDelegate(SKIPANIM_BUTTON, () => { MFGuiManager.FlushAnimations(); }, null); // enable social buttons m_FacebookButton.SetDisabled(false); m_TwitterButton.SetDisabled(false); }
// PUBLIC METHODS public void SetData(int rank, int points) { //bool isMajorRank = PlayerPersistantInfo.IsMajorRank(rank); GUIBase_MultiSprite sprite = GuiBaseUtils.GetControl <GUIBase_MultiSprite>(Layout, PLAYERRANKPIC); sprite.State = string.Format("Rank_{0}", Mathf.Min(rank, sprite.Count - 1).ToString("D2")); GUIBase_Label label = GuiBaseUtils.GetControl <GUIBase_Label>(Layout, POINTS_LABEL); var animation = MFGuiManager.AnimateWidget(label, 0, points); if (animation != null) { animation.Duration = m_CountDownDuration; animation.AudioClip = m_CountDownSound; } #if (!UNITY_EDITOR) && (UNITY_ANDROID || UNITY_IPHONE) // set visibility of info text Layout.GetWidget(WOULDPOSTIT_NOTIFY).Show(true, true); string postMessage = string.Format(TextDatabase.instance[01150011], CloudUser.instance.nickName, rank); // register delegate for facebook button m_FacebookButton.Widget.Show(true, true); m_FacebookButton.RegisterTouchDelegate(() => { m_FacebookButton.SetDisabled(true); StartCoroutine(sendMessage(rank.ToString())); }); m_TwitterButton.Widget.Show(true, true); m_TwitterButton.RegisterTouchDelegate(() => { m_TwitterButton.SetDisabled(true); TwitterUtils.PostMessage(postMessage, (success) => { if (m_TwitterButton.Widget.Visible == true) { m_TwitterButton.SetDisabled(!success); } }); }); #else m_FacebookButton.Widget.Show(false, true); m_TwitterButton.Widget.Show(false, true); #endif }
void SetButtonValue(GUIBase_Button button, int oldValue, int newValue, bool animate) { if (oldValue == newValue) { return; } if (animate == false) { button.SetNewText(newValue.ToString()); } else { var animation = MFGuiManager.AnimateWidget(button, oldValue, newValue); if (animation != null) { animation.AudioClip = m_CountDownSound; } } }
//--------------------------------------------------------- void Start() { m_IsInitialized = false; MFGuiManager guiManager = MFGuiManager.Instance; if (guiManager) { // // Platformu nemuzeme registrovat v Awake, protoze v Awake vznika GUIManager.Instance // guiManager.RegisterPlatform(this); m_PlayingAnims = new ArrayList(); m_AnimsToRemove = new ArrayList(); } else { gameObject.SetActive(false); Debug.LogWarning("GuiManager prefab is not present!"); } }
void FlushAnimations() { MFGuiManager.FlushAnimations(); }
static void OnLanguageChange() { // Debug.Log("Language is: " + language); TextDatabase.SetLanguage(convertLanguageToSysLanguage[(int)language]); MFGuiManager.OnLanguageChanged(convertLanguageToFullName[(int)language]); }
public void Update() { if (m_Player == null) { return; } m_Root.Show(true, true); var animation = MFGuiManager.AnimateWidget(m_Root); animation.Duration = 0.15f; animation.Scale = 1.1f; animation.Alpha = 0.0f; bool isFriend = GameCloudManager.friendList.friends.FindIndex(obj => obj.PrimaryKey == m_Player.PrimaryKey) != -1; m_FriendIcon.Show(isFriend, true); int rank = PlayerPersistantInfo.GetPlayerRankFromExperience(m_Player.Experience); Color color = m_TeamColors[(int)m_Player.Team]; color.a = m_LocalPlayer == true ? 1.0f : 0.5f; m_Root.Color = color; m_NicknameLabel.SetNewText(GuiBaseUtils.FixNameForGui(m_Player.NickName)); m_StandLabel.SetNewText(m_Index.ToString()); m_ScoreLabel.SetNewText(m_Player.Score.ToString()); m_KillsLabel.SetNewText(m_Player.Kills.ToString()); m_DeadsLabel.SetNewText(m_Player.Deaths.ToString()); m_RankLabel.SetNewText(rank.ToString()); m_RankIcon.State = string.Format("Rank_{0}", Mathf.Min(rank, m_RankIcon.Count - 1).ToString("D2")); string platform; switch (m_Player.Platform) { case RuntimePlatform.Android: platform = "Plat_Andro"; break; case RuntimePlatform.IPhonePlayer: platform = "Plat_Apple"; break; case RuntimePlatform.WindowsPlayer: platform = "Plat_Pc"; break; case RuntimePlatform.OSXPlayer: platform = "Plat_Mac"; break; case RuntimePlatform.WindowsWebPlayer: platform = "Plat_Fb"; break; case RuntimePlatform.OSXWebPlayer: platform = "Plat_Fb"; break; default: platform = "Plat_Skull"; break; } m_PlatformIcon.State = platform; }
IEnumerator UpdateList(List <RoundFinalResult.PlayerResult> players, E_Team winners) { GUIBase_List list = GuiBaseUtils.GetControl <GUIBase_List>(Layout, "Table"); GUIBase_Widget outline = GuiBaseUtils.GetChild <GUIBase_Widget>(list, "MyPlayer"); Row[] rows = new Row[list.numOfLines]; outline.Show(false, true); // sort player by score RoundFinalResult.PlayerResult[] score = players.ToArray(); System.Array.Sort(score, (x, y) => { int res = y.Score.CompareTo(x.Score); if (res == 0) { // descending by kills res = y.Kills.CompareTo(x.Kills); if (res == 0) { // increasing by deaths res = x.Deaths.CompareTo(y.Deaths); if (res == 0) { // increasing by names res = x.NickName.CompareTo(y.NickName); } } } return(res); }); // prepare rows E_Team team = E_Team.Last; for (int idx = 0; idx < list.numOfLines; ++idx) { RoundFinalResult.PlayerResult player = idx < players.Count ? players[idx] : null; if (player != null && player.Team != team) { team = player.Team; } int stand = player != null?System.Array.FindIndex(score, obj => obj.PrimaryKey == player.PrimaryKey) + 1 : -1; rows[idx] = new Row(stand, list.GetWidgetOnLine(idx), player, player != null && player.PrimaryKey == m_PrimaryKey); } yield return(new WaitForSeconds(0.2f)); // show rows for (int idx = 0; idx < list.numOfLines; ++idx) { rows[idx].Update(); do { if (m_SkipAnimations == true) { MFGuiManager.FlushAnimations(); } yield return(new WaitForEndOfFrame()); } while (MFGuiManager.IsAnimating == true); if (rows[idx].PrimaryKey == m_PrimaryKey) { outline.transform.position = list.GetWidgetOnLine(idx).transform.position; outline.SetModify(); outline.Show(true, true); } MFGuiManager.Instance.PlayOneShot(m_ShowRowSound); } }
// PRIVATE MEMBERS IEnumerator ShowResults(RoundFinalResult results) { results = results ?? new RoundFinalResult(); List <RoundFinalResult.PlayerResult> players = results.PlayersScore ?? new List <RoundFinalResult.PlayerResult>(); E_Team enemy = results.Team == E_Team.Good ? E_Team.Bad : E_Team.Good; E_Team winners = results.Winner ? results.Team : enemy; // sort players if (results.GameType != E_MPGameType.DeathMatch) { players.Sort((x, y) => { int res = x.Team.CompareTo(y.Team); if (res == 0) { // descending by score res = y.Score.CompareTo(x.Score); } else { res = x.Team == winners ? -1 : +1; } return(res); }); } m_TeamColors[(int)E_Team.None] = m_NoTeamColor; m_TeamColors[(int)E_Team.Good] = m_TeamGoodColor; m_TeamColors[(int)E_Team.Bad] = m_TeamBadColor; ShowResultText(results, winners); ShowResultImage(results, winners); yield return(StartCoroutine(UpdateList(players, winners))); yield return(new WaitForSeconds(0.2f)); PreyNightmare prey = new PreyNightmare(Layout.GetWidget("Prey")); prey.CountDownSound = m_CountDownSound; prey.Update(players.Find(obj => obj.PrimaryKey == results.Prey.PrimaryKey), results.Prey); PreyNightmare nightmare = new PreyNightmare(Layout.GetWidget("Nightmare")); nightmare.CountDownSound = m_CountDownSound; nightmare.Update(players.Find(obj => obj.PrimaryKey == results.Nightmare.PrimaryKey), results.Nightmare); if (m_SkipAnimations == true) { MFGuiManager.FlushAnimations(); } #if !UNITY_STANDALONE int screenShotPlace = 3; #if FB_LOGIN_REVIEW screenShotPlace = 100; #endif if (results.Place < screenShotPlace) { GUIBase_Widget socNetsRoot = Layout.GetWidget("SocialNetworks", false); if (socNetsRoot != null) { socNetsRoot.Show(true, true); RegisterButtonDelegate("FB_Button", null, (inside) => { if (inside) { PostResults(true, results); } }); RegisterButtonDelegate("TW_Button", null, (inside) => { if (inside) { PostResults(false, results); } }); } } #endif }