Transform DisplayUP(Transform Target, HUDType type, string key, string text, bool isFollow, Vector2 offset) { //获取HUD对象 GameObject UDObj = GetHUDObj(key); //初始化UD组件 Transform UITran = UIPool.GetObject(key, UDObj).transform; Transform ContextTran = UITran.GetChild(0); UIWidget UIComponet = ContextTran.GetComponent<UIWidget>(); //设置对应关联 UITran.parent = mTran; UITran.localScale = Vector3.one; ContextTran.localPosition = Vector3.zero; UITran.gameObject.SetActive(true); //初始化位置 if (offset == Vector2.zero) Follow(UITran, Target); else Follow(UITran, Target, offset); //开启HUD特效 switch (type) { case HUDType.Rise: StartCoroutine(Rise(Target, UITran, ContextTran, UIComponet, text, isFollow, offset)); break; case HUDType.Jump: StartCoroutine(Jump(Target, UITran, ContextTran, UIComponet, text, isFollow)); break; case HUDType.Scale: StartCoroutine(Scale(Target, UITran, ContextTran, UIComponet, text, isFollow, offset)); break; case HUDType.Erasure: StartCoroutine(Erasure(Target, UITran, ContextTran, UIComponet, text, isFollow)); break; } return UITran; }
private GHUD GenHUD(HUDType a_HUDType) { HUDInfo hudInfo = DbMgr.s_Instance.GetHUDInfo(a_HUDType); if (hudInfo == null) { return(null); } GameObject hudPref = Resources.Load <GameObject>(hudInfo.m_PrefPath); if (hudPref == null) { return(null); } // instantiate & init new HUD GameObject hudObj = Instantiate(hudPref, transform); GHUD gHUD = hudObj.GetComponent <GHUD>(); gHUD.OnCreateObj(); gHUD.Init(hudInfo); m_lHUD.Add(gHUD); return(gHUD); }
/// <summary> /// send a new event, to create a new floating text /// </summary> public GameObject NewText(string text, HUDType hudType, Transform trans, Color color, int size, float speed, float yAcceleration, float yAccelerationScaleFactor, bl_Guidance movement) { GameObject t = Instantiate(TextPrefab) as GameObject; //Create new text info to instatiate bl_Text item = t.GetComponent <bl_Text>(); item.m_Speed = speed; item.m_Color = color; item.m_Transform = trans; // text = ""; item.m_text = ""; item.m_Size = size; item.movement = movement; item.Yquickness = yAcceleration; item.YquicknessScaleFactor = yAccelerationScaleFactor; t.transform.SetParent(CanvasParent, false); // t.GetComponent<RectTransform>().anchoredPosition = Vector2.zero; texts.Add(item); HUDImage hudImage = t.GetComponent <HUDImage>(); hudImage.Show(text, hudType); return(item.gameObject); }
public override void Excute(CharacterState cs, float mCurValue) { base.Excute(cs, mCurValue); int hpResult = GameLibrary.Instance().CalcSkillDamage(mCurValue, node.damageType, lvl, target, attacker); HUDType mCurType = attacker.state == Modestatus.Player ? HUDType.DamagePlayer : HUDType.DamageEnemy; cs.Hp(hpResult < 1 ? 1 : hpResult, mCurType, true, attacker); }
public void DisableGHUD(HUDType a_HUDType) { GHUD ghud = GetHUD(a_HUDType); if (ghud != null) { ghud.SetActive(false); } }
void ToggleHUD(HUDType type) { switch (type) { case HUDType.Inventory: UpdateHUD(type, hudInventory.interactable); break; } }
void OnGUI() { GUILayout.Label(" WSAD 上下左右"); GUILayout.Label(" H 文本"); GUILayout.Label(" J 文本2"); GUILayout.Label(" K 图片"); GUILayout.Label(" L 图片2"); follow = GUILayout.Toggle(follow, "跟随"); Select = GUILayout.SelectionGrid(Select, Selections, 1); Type = Types[Select]; }
// ================================== PRIVATE FUNCS ================================== #region Private Funcs private GHUD GetHUD(HUDType a_HUDType) { for (int i = 0; i < m_lHUD.Count; i++) { GHUD ghud = m_lHUD[i]; if (ghud.GetHUDInfo().m_HUDType == a_HUDType) { return(ghud); } } return(null); }
// ================================== PUBLIC FUNCS ================================== #region Public Funcs public GHUD GenHUD(HUDType a_HUDType, bool a_IsClearOldHUD = false) { if (a_IsClearOldHUD) { for (int i = 0; i < m_lHUD.Count; i++) { DestroyHUD(i); i--; } } return(GenHUD(a_HUDType)); }
///<summary>Updates a specific HUD</summary> ///<param name="hide">Should the HUD be hidden or shown?</param> public void UpdateHUD(HUDType type, bool hide) { switch (type) { case HUDType.Inventory: hudInventory.interactable = !hide; hudInventory.blocksRaycasts = !hide; hudInventory.alpha = hide ? 0 : 1; player.receiveInput = hide; if (!hide) { Inventory.RefreshBackpack(); } if (hide) { Inventory.ShowSelectedItem(null, -1); } break; case HUDType.Shop: hudShop.interactable = !hide; hudShop.blocksRaycasts = !hide; hudShop.alpha = hide ? 0 : 1; player.receiveInput = hide; break; case HUDType.Health: hudHealth.alpha = hide ? 0 : 1; break; case HUDType.Items: hudItems.alpha = hide ? 0 : 1; break; case HUDType.GameOver: hudGameOver.interactable = !hide; if (!hide) { hudGameOver.GetComponent <Animator>().SetTrigger("Fade"); } break; } }
// Use this for initialization public void InitHUD(HUDType type, Transform target) { this.currType = type; this.target = target; switch (currType) { case HUDType.NameHint: offsetY = 1.5f; break; case HUDType.HealthBar: offsetY = 1f; break; } }
public void Show(HUDType type, string msg, int duaration) { switch (type) { case HUDType.Loading: BTProgressHUD.Show(msg, maskType: MaskType.Black); break; case HUDType.Success: BTProgressHUD.ShowImage(UIImage.FromBundle("IconSuccess"), msg, duaration); break; case HUDType.Fail: BTProgressHUD.ShowImage(UIImage.FromBundle("IconFail"), msg, duaration); break; } }
public void HUD(GameObject target, int count, HUDType hType = HUDType.DamageEnemy, float time = 0f) { string str = (count != 0) ? "" + Mathf.Abs(count) : ""; if (hudDic.ContainsKey(target)) { hudDic[target].Add(str, time, hType); } else { HUDText hudTxt = NGUITools.AddChild(mHudPanel, HUDTextPrefab).GetComponent <HUDText>(); GameObject go = Instantiate(Resources.Load("HUD/HUD Point"), Vector3.zero, Quaternion.identity) as GameObject; go.transform.parent = target.transform; Transform mHitPoint = target.GetComponent <CharacterState>().mHitPoint; go.transform.localPosition = mHitPoint == null ? Vector3.up * 0.5f : mHitPoint.localPosition; hudTxt.GetComponent <UIFollowTarget>().target = go.transform; hudTxt.Add(str, time, hType); hudDic.Add(target, hudTxt); } }
public void Show(HUDType type = HUDType.Loading, string msg = "", int duaration = 640) { if (!hasInit) { Logger($"{type} : {msg}"); return; } RunInUI(() => { msgBar.Text = msg; if (type == HUDType.Loading) { msgBox.Background = DefaultBrush; msgBar.Foreground = BlackBrush; } else { new Timer((o) => Dismiss(), null, duaration, Timeout.Infinite); msgBox.Background = type == HUDType.Fail ? RedBrush : GreenBrush; msgBar.Foreground = WhiteBrush; } }); }
public void Show(string _value, HUDType hudType) { int value = int.Parse(_value); List <int> numberList = new List <int>(); if (value > 0) { while (value / 10 > 0) { numberList.Add(value % 10); value = value / 10; } numberList.Add(value); } else { value = -value; while (value / 10 > 0) { numberList.Add(value % 10); value = value / 10; } numberList.Add(value); } switch (hudType) { case HUDType.HPReduce: numImageList[0].gameObject.SetActive(true); AtlasManager.Instance.SetSprite(numImageList[0], "atlas_number", "Damage_jian"); for (int i = 1; i < numImageList.Count; i++) { if (i < numberList.Count + 1) { numImageList[i].gameObject.SetActive(true); string name = "Damage_" + numberList[numberList.Count - i]; AtlasManager.Instance.SetSprite(numImageList[i], "atlas_number", name); } else { numImageList[i].gameObject.SetActive(false); } } break; case HUDType.CritHPReduce: numImageList[0].gameObject.SetActive(true); AtlasManager.Instance.SetSprite(numImageList[0], "atlas_number", "CritDamage_jian"); numImageList[0].transform.localScale = new Vector3(1.5f, 1.5f, 1.5f); // numImageList[0].color = Color.red; for (int i = 1; i < numImageList.Count; i++) { if (i < numberList.Count + 1) { numImageList[i].gameObject.SetActive(true); string name = "CritDamage_" + numberList[numberList.Count - i]; AtlasManager.Instance.SetSprite(numImageList[i], "atlas_number", name); numImageList[i].transform.localScale = new Vector3(1.5f, 1.5f, 1.5f); // numImageList[i].color = Color.red; } else { numImageList[i].gameObject.SetActive(false); } } break; case HUDType.HPRecover: numImageList[0].gameObject.SetActive(true); AtlasManager.Instance.SetSprite(numImageList[0], "atlas_number", "RecoverHP_jia"); // numImageList[0].color = Color.green; for (int i = 1; i < numImageList.Count; i++) { if (i < numberList.Count + 1) { numImageList[i].gameObject.SetActive(true); string name = "RecoverHP_" + numberList[numberList.Count - i]; AtlasManager.Instance.SetSprite(numImageList[i], "atlas_number", name); // numImageList[i].color = Color.green; } else { numImageList[i].gameObject.SetActive(false); } } break; case HUDType.MPRecover: numImageList[0].gameObject.SetActive(true); AtlasManager.Instance.SetSprite(numImageList[0], "atlas_number", "RecoverMP_jia"); // numImageList[0].color = Color.blue; for (int i = 1; i < numImageList.Count; i++) { if (i < numberList.Count + 1) { numImageList[i].gameObject.SetActive(true); string name = "RecoverMP_" + numberList[numberList.Count - i]; AtlasManager.Instance.SetSprite(numImageList[i], "atlas_number", name); // numImageList[i].color = Color.blue; } else { numImageList[i].gameObject.SetActive(false); } } break; } }
public Transform Display(Transform Target, HUDType hudType, string key, string text, Vector2 offset, bool isFollow = false) { return DisplayUP(Target, hudType, key, text, isFollow, offset); }
public Transform Display(Transform Target, HUDType hudType, string key, bool isFollow = false) { return DisplayUP(Target, hudType, key, null, isFollow, Vector2.zero); }
/// <summary> /// Add a new scrolling text entry. /// </summary> public void Add(string str, float stayDuration, HUDType hType) { if (!enabled) { return; } // Create a new entry Entry ne = Create(); ne.stay = stayDuration; ne.label.applyGradient = false; ne.label.alpha = 0f; ne.label.effectStyle = UILabel.Effect.Outline; ne.label.effectDistance = new Vector2(1, 1); ne.label.color = Color.white; ne.label.fontSize = GameLibrary.isMoba ? 20 : 30; ne.label.depth = 999; ne.time = Time.realtimeSinceStartup; ne.isLeft = Random.Range(0, 2) > 0; ne.hudType = hType; switch (hType) { case HUDType.DamagePlayer: ne.label.text = str; ne.label.effectColor = new Color((float)229 / 255, 0, 0); break; case HUDType.DamageEnemy: ne.label.text = str; ne.label.color = new Color((float)255 / 255, (float)59 / 255, (float)44 / 255); ne.label.effectColor = new Color((float)101 / 255, 0, 0); break; case HUDType.Crit: mBuilder = new StringBuilder(Localization.Get("HUDCrit")); ne.label.text = mBuilder.Append(str).ToString(); ne.label.applyGradient = true; ne.label.gradientTop = new Color((float)255 / 255, (float)250 / 255, (float)126 / 255); ne.label.gradientBottom = new Color((float)255 / 255, (float)235 / 255, (float)101 / 255); ne.label.effectColor = new Color((float)33 / 255, (float)12 / 255, 0); ne.label.effectDistance = new Vector2(1, 1); ne.label.fontSize = GameLibrary.isMoba ? 30 : 40; break; case HUDType.Cure: mBuilder = new StringBuilder(Localization.Get("HUDCure")); ne.label.text = mBuilder.Append("+").Append(str).ToString(); ne.label.effectColor = new Color(0, (float)40 / 255, (float)0 / 255); ne.label.color = new Color((float)142 / 255, (float)245 / 255, (float)106 / 255); break; case HUDType.Bleeding: mBuilder = new StringBuilder(Localization.Get("HUDBleeding")); ne.label.text = mBuilder.Append(str).ToString(); ne.label.color = new Color((float)255 / 255, (float)59 / 255, (float)44 / 255); ne.label.effectColor = new Color((float)101 / 255, 0, 0); break; case HUDType.SuckBlood: mBuilder = new StringBuilder(Localization.Get("HUDSuckBlood")); ne.label.text = mBuilder.Append(str).ToString(); ne.label.effectColor = new Color(0, (float)195 / 255, (float)4 / 255); break; case HUDType.Miss: mBuilder = new StringBuilder(Localization.Get("HUDMiss")); ne.label.text = mBuilder.ToString(); //ne.label.color = new Color((float)255 / 255, (float)59 / 255, (float)44 / 255); ne.label.effectColor = new Color((float)101 / 255, 0, 0); break; case HUDType.Immune: mBuilder = new StringBuilder(Localization.Get("HUDImmune")); ne.label.text = mBuilder.ToString(); //ne.label.color = new Color((float)255 / 255, (float)59 / 255, (float)44 / 255); ne.label.effectColor = new Color((float)101 / 255, 0, 0); break; case HUDType.Absorb: mBuilder = new StringBuilder(Localization.Get("HUDAbsorb")); //ne.label.text = mBuilder.Append("(").Append(str).Append(")").ToString(); ne.label.text = mBuilder.ToString(); ne.label.effectColor = new Color(0, (float)40 / 255, (float)0 / 255); break; default: break; } YOffsetCurveUsed = offsetCurve; XOffsetCurveUsed = xOffsetCurve; AlphaCurveUsed = alphaCurve; ScaleCurveUsed = scaleCurve; if (isAddType(ne)) { YOffsetCurveUsed = addOffsetCurve; XOffsetCurveUsed = addxOffsetCurve; } if (isBuffType(ne)) { YOffsetCurveUsed = buffOffsetCurve; XOffsetCurveUsed = buffXOffsetCurve; AlphaCurveUsed = buffAlphaCurve; ScaleCurveUsed = buffScaleCurve; } float offsetEnd = YOffsetCurveUsed.keys[YOffsetCurveUsed.keys.Length - 1].time; float xOffsetEnd = XOffsetCurveUsed.keys[XOffsetCurveUsed.keys.Length - 1].time; float alphaEnd = AlphaCurveUsed.keys[AlphaCurveUsed.keys.Length - 1].time; float scalesEnd = ScaleCurveUsed.keys[ScaleCurveUsed.keys.Length - 1].time; totalEnd = Mathf.Max(scalesEnd, Mathf.Max(Mathf.Max(offsetEnd, xOffsetEnd), alphaEnd)); // Sort the list mList.Sort(Comparison); }
public bool IsGHUDAvailable(HUDType a_HUDType) { GHUD ghud = GetHUD(a_HUDType); return(ghud != null ? true : false); }
/// <summary> /// /// </summary> /// <param name="text"></param> /// <param name="trans"></param> /// <param name="place"></param> public void NewText(string text, HUDType hudType, Transform trans, bl_Guidance place) { NewText(text, hudType, trans, Color.white, 8, 20f, 0, 2.2f, place); }
/// <summary> /// /// </summary> /// <param name="text"></param> /// <param name="trans"></param> public void NewText(string text, HUDType hudType, Transform trans, Color color) { NewText(text, hudType, trans, color, 8, 20f, 1, 2.2f, bl_Guidance.Up); }
/// <summary> /// Simple way /// </summary> /// <param name="text"></param> /// <param name="trans"></param> public void NewText(string text, HUDType hudType, Transform trans) { NewText(text, hudType, trans, bl_Guidance.Up); }