// Update is called once per frame
    void Update()
    {
        Ray        ray             = Camera.main.ScreenPointToRay(Input.mousePosition);
        int        groundLayerMask = LayerMask.GetMask("Ground");
        RaycastHit hitInfo;

        if (Physics.Raycast(ray, out hitInfo, 10000f, groundLayerMask))
        {
            Vector3 worldPos = hitInfo.point;
            float   angle    = Mathf.Atan2(worldPos.z - transform.position.z, worldPos.x - transform.position.x);

            if ((worldPos - transform.position).magnitude > distance)
            {
                Vector3 center = transform.position + (worldPos - transform.position) / (worldPos - transform.position).magnitude * distance + new Vector3(0, 0.01f, 0);
                circleRoot.position = center;
            }
            else
            {
                circleRoot.position = worldPos + new Vector3(0, 0.01f, 0);
            }
        }

        if (Input.GetMouseButtonDown(0))
        {
            CastObj castObj = new CastObj()
            {
                SkillSlotNum = (byte)skillSlotNum,
                IntArgs      = new int[0],
                FloatArgs    = new float[] { circleRoot.position.x, circleRoot.position.z }
            };
            network.Send(MessageType.Cast, MessagePackSerializer.Serialize(castObj), ENet.PacketFlags.Reliable);
            playerController.ResetFromInstance();
        }
    }
    // Update is called once per frame
    void Update()
    {
        Ray        ray             = Camera.main.ScreenPointToRay(Input.mousePosition);
        int        groundLayerMask = LayerMask.GetMask("Ground");
        RaycastHit hitInfo;

        if (Physics.Raycast(ray, out hitInfo, 10000f, groundLayerMask))
        {
            Vector3 worldPos = hitInfo.point;
            float   angle    = Mathf.Atan2(worldPos.z - transform.position.z, worldPos.x - transform.position.x);
            arrowRoot.eulerAngles = new Vector3(0, -angle * Mathf.Rad2Deg, 0);
        }

        if (Input.GetMouseButtonDown(0))
        {
            CastObj castObj = new CastObj()
            {
                SkillSlotNum = (byte)skillSlotNum,
                IntArgs      = new int[0],
                FloatArgs    = new float[] { 360 - arrowRoot.transform.eulerAngles.y }
            };
            network.Send(MessageType.Cast, MessagePackSerializer.Serialize(castObj), ENet.PacketFlags.Reliable);
            playerController.ResetFromInstance();
        }
    }
예제 #3
0
        void CastHandler(Peer peer, byte[] data)
        {
            CastObj castObj = MessagePackSerializer.Deserialize <CastObj>(data);
            Unit    unit    = Root.GetChild <WorldEntity>().GetUnit(peers[peer.ID].UnitID);

            if (unit != null)
            {
                if (castObj.SkillSlotNum == 0)
                {
                    unit.Execute(CombatAttribute.QSkill, castObj);
                }
                else if (castObj.SkillSlotNum == 1)
                {
                    unit.Execute(CombatAttribute.WSkill, castObj);
                }
                else if (castObj.SkillSlotNum == 2)
                {
                    unit.Execute(CombatAttribute.ESkill, castObj);
                }
                else
                {
                    unit.Execute(CombatAttribute.RSkill, castObj);
                }
            }
        }