public async void Dodge() { if (CombatHandler.UnitAnimator.Params.IsInDodgingState == true) { return; } var animationDodgeData = CombatHandler.UnitAnimator.AnimStatus.GetAnimationDodgeData(); if (CombatHandler.UnitAnimator.Params.IsInDodgingState == false) { CombatHandler.UnitAnimator.OnDodgeAnimationStarted.Invoke(); } if (KeyboardController.IsWASDPressed(out bool[] output)) { if (output[(int)Direction.Right]) { transform.rotation = Quaternion.LookRotation(-transform.right, Vector3.up); } else if (output[(int)Direction.Left]) { transform.rotation = Quaternion.LookRotation(transform.right, Vector3.up); } } CombatHandler.UnitAnimator.Params.AnimDodge = animationDodgeData.paramValue; await AsyncManager.WaitForFrame(1); CombatHandler.UnitAnimator.Play(animationDodgeData.stateName); }
private async void ResetItemPreviewRotationToDefault() { await AsyncManager.WaitForFrame(1); ItemPreview.ResetRotation(); ResetCameraPositionAndRotation(); RenderCamera(); }
private async void UpdateAsync() { while (renderTexture != null) { await AsyncManager.WaitForFrame(1); UI_ItemRenderer.Render(); } }
public async void SetValue(string characterName, IReadOnlyCollection <Chat_Base> dialogues) { this.characterName.text = characterName; this.dialogues = dialogues; index = 0; dialogueText.text = (dialogues.ElementAt(index) as Chat_Dialogue).Dialogue; index++; await AsyncManager.WaitForFrame(1); InputEvent.Instance.Event_NextDialogue.AddListener(GoToNextDialogue); }
private async void UpdateAsync() { var instanceID = itemPreview.GetInstanceID(); while (itemPreview != null && instanceID == itemPreview.GetInstanceID()) { await AsyncManager.WaitForFrame(1); if (itemPreview != null) { UI_ItemRenderer.ResetCameraPositionAndRotation(itemPreview.ItemBase, itemPreview.transform); UI_ItemRenderer.SetTexture(renderTexture); UI_ItemRenderer.Render(); } } }
private async void RenderCameraForTheFirstTime() { await AsyncManager.WaitForFrame(2); foreach (var t in itemIconsList) { UI_ItemRenderer.SetPosition(t.ItemRenderer.ItemPreview.transform.position - new Vector3(0, 0, 1)); UI_ItemRenderer.SetTexture(t.ItemRenderer.RawImage.texture as RenderTexture); UI_ItemRenderer.ResetCameraPositionAndRotation(t.Item, t.ItemRenderer.ItemPreview.transform); t.ItemRenderer.ItemPreview.ResetRotation(); t.ItemRenderer.ItemPreview.UpdateMaterial(); UI_ItemRenderer.Render(); t.ItemRenderer.gameObject.SetActive(true); } }
public async void Activate(Unit_AI ai) { if (this.ai == ai) { return; } this.ai = ai; headTransform = ai.BodyTransform.Head; aiTransform = ai.transform; gameObject.SetActive(true); await AsyncManager.WaitForFrame(1); Image.enabled = true; InputEvent.Instance.Event_Chat.AddListener(StartChat); }
private async void InstantiateItem() { var products = Buy.Left.Shop.Products; var position = new Vector3(RectTransform.position.x, RectTransform.position.y + (RectTransform.sizeDelta.y * 0.5f)); var spacingPerItem = 10.0f; position.y -= itemPrefab.RectTransform.sizeDelta.y * 0.5f; items = new UI_Shop_Left_Buy_ItemChild[maxVisibleItem]; for (int i = startIndex; i < startIndex + maxVisibleItem; i++) { if (i > products.Count - 1) { break; } var product = Instantiate(itemPrefab, RectTransform); product.Initialize(products.ElementAt(i), this, position); items[i - startIndex] = product; position.y -= itemPrefab.RectTransform.sizeDelta.y + spacingPerItem; } await AsyncManager.WaitForFrame(1); int index = startIndex; foreach (var item in items) { if (index > products.Count - 1) { break; } UI_ItemRenderer.ResetCameraPositionAndRotation(products.ElementAt(index).Product, item.ItemPreview.transform); UI_ItemRenderer.SetTexture(item.ItemRenderer.texture as RenderTexture); UI_ItemRenderer.Render(); index++; } UI_ItemRenderer.SetTexture(null); }
private async void Awake() { await AsyncManager.WaitForFrame(1); var mid = RectTransform.position; icon = UI_Pool.Instance.GetImage(RectTransform, 64, 64, nameof(icon)); icon.sprite = GlobalAssetsReference.Money_Sprite; icon.rectTransform.position = mid + new Vector3(32, 0); var iconLeft = icon.rectTransform.position + new Vector3(32, 0); var leftLeft = mid + new Vector3(RectTransform.sizeDelta.x * 0.5f, 0); var amountSizeX = Mathf.Abs(iconLeft.x - leftLeft.x); amount = UI_Pool.Instance.GetText(RectTransform, amountSizeX, 48, PlayerData.MoneyString, nameof(amount)); amount.rectTransform.position = iconLeft + new Vector3(amountSizeX * 0.5f, 0); var amountPos = amount.rectTransform.position; amountPos.y = icon.rectTransform.position.y - 32 + 24; amount.rectTransform.position = amountPos; amount.alignment = TextAlignmentOptions.MidlineLeft; UI_Menu.OnBeforeOpen.AddListener(UpdateMoney); }