protected override void OnDropEvent() { if (UIDragDropHandler.CurrentData == null) { if (UIDragDropHandler.Active) { UIDragDropHandler.Return(); } return; } if (UIDragDropHandler.CurrentData.Get <InventoryItem>()?.Identified ?? false) { UIFloatingText.Spawn("Doesn't need to be identified", transform as RectTransform, Color.green, UIFloatingText.Orietation.Center); UIDragDropHandler.Return(); return; } var price = GameOptions.IdentifyEstimate(UIDragDropHandler.CurrentData); if (Player.Currency.Value < price) { UIFloatingText.Spawn(string.Format("Identify Cost: {0} Not enough {1}", price, GameLabels.Currency), transform as RectTransform, Color.green, UIFloatingText.Orietation.Center); UIDragDropHandler.Return(); return; } UIModalQuestion.Set(ConfirmIdentify, string.Format("Identify for {0} {1}?", price, GameLabels.Currency)); }
void Update() { if (!Game.GameActive || PlayerInput.IsCursorOverUI) { return; } bool leftClick = CheckLeftClick(); bool rightClick = CheckRightClick(); if (!leftClick && !rightClick) { _cam.UpdateInput(); return; } _mouseRay = WorldControlMonitor.Cam.ScreenPointToRay(Input.mousePosition); var cnt = Physics.RaycastNonAlloc(_mouseRay, _hits, _rayDistance, _mask); _hits.SortByDistanceAsc(cnt); for (int i = 0; i < cnt; i++) { var hit = _hits[i]; Actor actor = Actor.Get(hit.collider); if (actor != null) { if (leftClick) { if (actor.Faction == Factions.Enemy && Player.SelectedActor != null) { var attack = Player.SelectedActor.GetAttack(Player.SelectedActor.ActionDistance(UICenterTarget.CurrentActor)); if (!attack.TryStart(UICenterTarget.CurrentActor)) { UIFloatingText.Spawn(attack.LastStatusUpdate, 2f, Player.SelectedActor.PartySlot.RectTr, Color.yellow); } } //else { // var playActor = actor as PlayerActor; // if (playActor != null) { // Player.SelectedActor = playActor; // } //} } if (rightClick) { UIActionController.main.OpenRadial(actor); } continue; } if (LayerMasks.Environment.ContainsLayer(hit.transform.gameObject.layer)) { if (Player.SelectedActor != null) { var info = CellGridGraph.Current.GetNearest(hit.point, _constraint); if (info.node != null) { Player.SelectedActor.StateController.MoveTo((Vector3)info.node.position); } } } } }
public void Handle(HealingEvent arg) { if (!arg.Target.Entity.HasComponent <FloatingText>()) { return; } UIFloatingText.WorldSpawn(arg.Amount.ToString("F0"), arg.Target.Entity.GetPosition(), Color.green); }
public void Handle(TakeDamageEvent arg) { if (!arg.Target.Entity.HasComponent <FloatingText>()) { return; } UIFloatingText.WorldSpawn(arg.Amount.ToString("F0"), arg.Target.Tr.position, Color.red); }
protected void StatusMessages(string message, Color color) { if (_statusTimer.IsActive) { return; } _statusTimer.StartTimer(); UIFloatingText.Spawn(message, transform as RectTransform, color, UIFloatingText.Orietation.Center); }
private void StatusMessages(Entity item, string message) { if (_statusTimer.IsActive) { return; } _statusTimer.StartTimer(); UIFloatingText.Spawn(message, transform as RectTransform, Color.yellow, _textOrientation); }
public void UseSlot() { if (Data == null) { return; } if (!Data.Get <UsableComponent>().TryUse(this)) { UIFloatingText.InventoryMessage(Data.Get <StatusUpdateComponent>(), RectTransform); } }
public void UseSlotTarget() { if (Data == null) { return; } if (!Data.Get <Command>()?.TryStart(UICenterTarget.CurrentCharacter?.Entity ?? null) ?? false) { UIFloatingText.InventoryMessage(Data.Get <StatusUpdateComponent>(), RectTransform); } }
public override void OnComplete() { _floating = NewPrefab.GetComponent <UIFloatingText>(); if (_icon != null) { _floating._icon.overrideSprite = _icon; } _floating.RectTransform.SetParent(_parent); _floating.RectTransform.SetAsLastSibling(); TimeManager.StartTask(SetTargetText()); }
protected override void TryDrop() { var newItem = UIDragDropHandler.CurrentData; if (World.Get<EquipmentSystem>().TryEquip(_slot, newItem)) { UIDragDropHandler.Take(); } else { if (PlayAudio) { AudioPool.PlayClip(StringConst.AudioDefaultItemReturn, transform.position, 0, AudioVolume); } UIFloatingText.InventoryMessage(_slot.LastEquipStatus, RectTransform); UIDragDropHandler.Return(); } }
public void ShowCenter(params System.Object[] param) { string message; try { message = string.Format(_message, param); } catch (FormatException e) { Debug.LogFormat("Received {0} and {1} but threw {2}", _message, param.Length, e); return; } UIFloatingText.SpawnCentered(message, _messageColor); }
public static void WorldSpawn(string text, Vector3 start, Color color) { if (string.IsNullOrEmpty(text)) { return; } _msgChecker.Add(text, UIRoot.Misc.Get().transform); UIFloatingText spawn = ItemPool.SpawnUIPrefab <UIFloatingText>("UI/UIFloatingTextStandard", UIRoot.Misc.Get().transform); spawn.transform.position = RectTransformUtility.WorldToScreenPoint(Player.Cam, start); var end = RectTransformUtility.WorldToScreenPoint(Player.Cam, start + new Vector3(0, 1, 0)); spawn.RectTransform.SetAsLastSibling(); TimeManager.StartUnscaled(spawn.SetTargetText(text, 2f, end, color)); }
public void Handle(TakeDamageEvent arg) { if (!arg.Target.Entity.HasComponent <FloatingText>()) { return; } if (arg.Impact.Hit == CollisionResult.CriticalHit) { UIFloatingText.WorldSpawn(arg.Amount.ToString("F0") + "!", arg.Target.Tr.position, new Color(1f, 0.6f, 0.14f)); } else { UIFloatingText.WorldSpawn(arg.Amount.ToString("F0"), arg.Target.Tr.position, Color.red); } }
private void ChangeText() { var difference = Player.DefaultCurrencyHolder.Value - _lastValue; if (difference > 0) { UIFloatingText.Spawn(string.Format("+{0}", difference.ToString("F0")), 2.5f, transform as RectTransform, Color.green); } else if (difference < 0) { UIFloatingText.Spawn(string.Format("-{0}", difference.ToString("F0")), 2.5f, transform as RectTransform, Color.red); } _lastValue = Player.DefaultCurrencyHolder.Value; _currency.text = _lastValue.ToString("F0"); }
private void ConfirmRepair(int id) { if (id > 0 || UIDragDropHandler.CurrentData == null) { if (UIDragDropHandler.Active) { UIDragDropHandler.Return(); } return; } var price = GameOptions.RepairEstimate(UIDragDropHandler.CurrentData); UIFloatingText.Spawn(string.Format("Repaired for {0} {1}", price, GameText.DefaultCurrencyLabel), transform as RectTransform, Color.green, UIFloatingText.Orietation.Center); Player.DefaultCurrencyHolder.AddToValue(-price); //UIDragDropHandler.CurrentData.Durability.SetMax(); UIDragDropHandler.Return(); }
private void ConfirmIdentify(int id) { if (id > 0 || UIDragDropHandler.CurrentData == null) { if (UIDragDropHandler.Active) { UIDragDropHandler.Return(); } return; } var price = GameOptions.IdentifyEstimate(UIDragDropHandler.CurrentData); UIFloatingText.Spawn(string.Format("Identified for {0} {1}", price, GameLabels.Currency), transform as RectTransform, Color.green, UIFloatingText.Orietation.Center); Player.Currency.AddToValue(-price); UIDragDropHandler.CurrentData.Get <InventoryItem>(i => i.Identified = true); UIDragDropHandler.Return(); }
public static void SpawnIcon(Sprite icon, string text, RectTransform start, Color color) { var startPosition = start.position; UIFloatingText spawn = ItemPool.SpawnUIPrefab <UIFloatingText>("UI/UIFloatingTextIcon", start); spawn.RectTransform.SetParent(UIRoot.Misc.Get().transform); spawn.RectTransform.SetAsLastSibling(); if (_iconTimer.IsActive) { startPosition = start.position + new Vector3(_negative ? -Offset : Offset, 0, 0); spawn.RectTransform.position = startPosition; _negative = !_negative; } _iconTimer.StartTimer(); spawn._icon.sprite = icon; TimeManager.StartUnscaled(spawn.SetTargetText(text, 2f, startPosition + new Vector3(0, 150, 0), color)); }
private IEnumerator SetTargetText() { var tr = _floating.transform; tr.position = _start; _floating._text.text = _text; _floating._moveTween.Restart(tr.position, _end, _duration); _floating._colorTween.Restart(0, 1, _duration); _timeoutTimer.RestartTimer(); while (_floating._moveTween.Active) { _floating._text.color = Color.Lerp(_startColor, _floating._endColor, _floating._colorTween.Get()); tr.position = _floating._moveTween.Get(); yield return(null); } ItemPool.Despawn(_floating.gameObject); _floating = null; _parent = null; _icon = null; SourcePrefab = null; NewPrefab = null; _pool.Store(this); }
private void FloatingText(RectTransform rectTr, string text) { UIFloatingText.Spawn(text, rectTr, Color.red, UIFloatingText.Orietation.Center); }
public void Handle(HealEvent arg) { UIFloatingText.WorldSpawn(arg.Amount.ToString("F0"), this.GetEntity().GetPosition(), Color.green); }