void ShowBloodChange() { if (m_FrameBloodChange != 0) { Vector3 new_pos = GetBloodPointPos(); GameObject label = null; if (m_FrameBloodChange > 0) { label = UIManager.Instance.AddUI("UI/HealLabel"); HealLabel hl = label.GetComponent <HealLabel> (); hl.DamageShow = m_FrameBloodChange; hl.Reposition(new_pos); } else { label = UIManager.Instance.AddUI("UI/DamageLabel"); //CommonLogger.Log ("Pos before " + label.gameObject.transform.position.ToString ()); DamageLabel dl = label.GetComponent <DamageLabel> (); dl.DamageShow = m_FrameBloodChange; dl.Reposition(new_pos); //CommonLogger.LogError ("Pos after " + label.gameObject.transform.position.ToString ()); } m_FrameBloodChange = 0; } }
/// <summary> /// Show a damage label at the given position. /// </summary> /// <param name="position">The position where the damage label is spawned.</param> /// <param name="damage">The damage displayed on the label.</param> /// <param name="textColor">The color of the damage text when first spawned.</param> /// <param name="textColor">The final color of the damage text. The color is tweened from the starting color to this one.</param> /// <param name="backgroundStartColor">The color of the background when first spawned.</param> /// <param name="backgroundEndColor">The color of the background at the end of the damage label animation.</param> /// <param name="flyingDirection">The direction in which the label will fly (either left or right).</param> public void ShowDamageLabel(Vector3 position, float damage, Color textStartColor, Color textColor, Color backgroundStartColor, Color backgroundEndColor, Direction flyingDirection) { // Retrieve a damage label from a pool DamageLabel damageLabel = damageLabelPool.Obtain().GetComponent <DamageLabel>(); // Tell the damageLabel which canvas rect it is being displayed on. Allows the label to convert its world position into canvas coordinates. damageLabel.CanvasRect = canvasRect; // Activates the damage label and makes it fly in the given direction damageLabel.Activate(position, damage, textStartColor, textColor, backgroundStartColor, backgroundEndColor, flyingDirection); // Free the damage label back into a pool once it fades out, in 'damageLabel.displayTime' seconds StartCoroutine(FreeIntoPool(damageLabel.gameObject, damageLabelPool, damageLabel.displayTime)); }
public static void AddDamageLabel(DamageList damageList, Vector3 hitPosition, Character target) { if (damageList.TotalDamage < (float)CombatHUD.config.GetValue(Settings.MinimumDamage)) { return; } if (target.IsAI && !(bool)CombatHUD.config.GetValue(Settings.PlayerDamageLabels)) { return; } if (!target.IsAI && !(bool)CombatHUD.config.GetValue(Settings.EnemyDamageLabels)) { return; } Color damagecolor = Color.white; if (!(bool)CombatHUD.config.GetValue(Settings.DisableColors)) { float highest = 0f; foreach (DamageType type in damageList.List) { if (type.Damage > highest) { highest = type.Damage; damagecolor = GetDmgColor(type.Type); } } } var x = CombatHUD.Rel(30f); var y = CombatHUD.Rel(15f, true); DamageLabel label = new DamageLabel { CreationTime = Time.time, TextColor = damagecolor, Damage = damageList.TotalDamage, HitWorldPos = hitPosition, Target = target, ranXpos = UnityEngine.Random.Range(-x, x), ranYpos = UnityEngine.Random.Range(-y, y) }; ActiveLabels.Add(label); }
public static int restoreHealth(BoardCharacter target, int amount) { int healed = amount; if (target.cHealth == target.bHealth) { healed = 0; } else { target.restoreHealth(amount); healed = amount; } DamageLabel label = GameObject.Instantiate(lb) as DamageLabel; label.transform.position = target.transform.position; label.GetComponent <TextMesh>().text = "+" + healed; label.attached = target; return(healed); }
public static int dealDamage(BoardCharacter target, int amount) { int dealt = amount; if (target.cstatts.Contains("divineshield")) { target.cstatts.Remove("divineshield"); target.ostatts.Remove("divineshield"); dealt = 0; } else { target.takeDamage(amount); dealt = amount; } DamageLabel label = GameObject.Instantiate(lb) as DamageLabel; label.transform.position = target.transform.position; label.GetComponent <TextMesh>().text = "-" + dealt; label.attached = target; if (dealt > 0) { if (target.type == "minion") { Minion t = (Minion)target; t.effect.onSelfDamaged(); sendTriggerTo(t.Player.board, "onFriendlyMinionDamaged"); sendTriggerTo(CardController.getController().getOtherPlayer(t.Player).board, "onEnemyMinionDamaged"); sendTriggerTo(getAllMinions(), "onMinionDamaged"); } } return(dealt); }
private void Instance_OnDamageReceived(DamageInfo info) { var character = MobsManager.Instance.GetCharacter(info.targetId); if (character == null) { return; } DamageLabel dl = new DamageLabel(); Text inst = Text.Instantiate(damageLabelPrefab, transform); inst.text = info.damage.ToString(); dl.target = character; dl.label = inst; dl.UpdateTarget(); Destroy(inst, 1); labels.Add(dl); }
private void Awake() { instance = this; }