void Update() { if (Input.GetKeyDown(KeyCode.Escape)) { SetTarget(null); } if (Input.GetMouseButtonDown(0)) { var ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out RaycastHit hit, 150)) { var ch = hit.collider.GetComponent <Character>(); if (ch) { SetTarget(ch); } } } if (Input.GetMouseButtonDown(1)) { var ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out RaycastHit hit, 150)) { var ch = hit.collider.GetComponent <Character>(); if (ch) { SetTarget(ch); OutcomingPackets.SendPacket(ServerPacketType.ClickNpcRequest, ch.id, (byte)1); } } } }
private void Awake() { var bts = transform.GetComponentsInChildren <DraggableButton>(); for (int i = 0; i < bts.Length; i++) { button.Add(i, bts[i]); int slot = i; bts[i].Slot = slot; bts[i].OnDrop.AddListener((e) => { Debug.Log(e.pointerDrag); var skillHandler = e.pointerDrag.GetComponentInParent <SkillButton>(); if (skillHandler != null) { Debug.Log("Set skill bar slot: " + slot + " to " + skillHandler.skillData.name); //var dragged = e.pointerDrag.GetComponent<DraggableButton>(); OutcomingPackets.SendPacket(ServerPacketType.MoveEntitySlot, MoveEntityType.SKILLBAR, slot); } else { Debug.Log("There is no skill button component in parent."); } }); } }
private void SendChatMessage() { if (messageField.text == "") { return; } OutcomingPackets.SendPacket(ServerPacketType.ChatMessageRequest, messageField.text); messageField.text = ""; EventSystem.current.SetSelectedGameObject(null); }
private IEnumerator SendInfo() { while (true) { yield return(new WaitForSeconds(1f / 30f)); if (Character != null) { OutcomingPackets.SendPacket(ServerPacketType.MoveRequest, (byte)Character.transform.eulerAngles.y, Character.transform.position.x, Character.transform.position.y, Character.transform.position.z); } } }
private void SetTarget(Character ch) { target = ch; if (target == null) { targetDecal.gameObject.SetActive(false); OutcomingPackets.SendPacket(ServerPacketType.ClickNpcRequest, (uint)0, (byte)0); } else { targetDecal.gameObject.SetActive(true); } UpdateDecalPosition(); OnTargetChanged(ch); }
private void Awake() { var bts = GetComponentsInChildren <ItemButton>(); for (int i = 0; i < bts.Length; i++) { var slot = i; bts[i].SetContainerId(containerId); buttons.Add(i, bts[i]); var draggable = bts[i].GetComponentInChildren <DraggableButton>(); draggable.Slot = slot; draggable.OnDrag.AddListener((e) => { draggable.transform.position = Input.mousePosition; }); draggable.OnPickup.AddListener((e) => { draggable.SetInteractable(false); }); draggable.OnRelease.AddListener((e) => { draggable.SetInteractable(true); draggable.ReturnToPickupPosition(); }); draggable.OnClick.AddListener((e) => { if (e.button == PointerEventData.InputButton.Right) { OutcomingPackets.SendPacket(ServerPacketType.UseItem, containerId, (byte)1, slot); } }); draggable.OnDrop.AddListener((e) => { var dragged = e.pointerDrag.GetComponent <DraggableButton>(); OutcomingPackets.SendPacket(ServerPacketType.MoveEntitySlot, MoveEntityType.ITEM, slot, containerId, draggable.GetComponentInParent <ItemsContainerButtons>().containerId, dragged.Slot); }); } }