Exemple #1
0
    void ScreenOnDrag(PointerEventData eventData)
    {
        Vector2 pos  = GetLocalPos(eventData);
        Vector2 move = (pos - lastDragCameraPosition);

        lastDragCameraPosition = pos;
        MessageSystem.Publish("ui_change_yaw_pitch", move.x * 0.3f, -move.y * 0.3f);
    }
Exemple #2
0
    // Update is called once per frame
    void Update()
    {
        m_count++;
        m_timeElapse = Time.realtimeSinceStartup - m_timeCountStart;
        if (m_timeElapse >= INTERVAL)
        {
            float newFps = 1.0f / m_timeElapse * m_count;
            m_timeCountStart = Time.realtimeSinceStartup;
            m_count          = 0;
            if (Mathf.Abs(newFps - fps) >= 3)
            {
                fps         = newFps;
                txtFps.text = ((int)fps).ToString();
            }
        }


        if (isMoving)
        {
            Vector3 camDir     = Camera.main.transform.TransformDirection(Vector3.forward);
            Vector3 leftDir    = Vector3.Cross(camDir, Vector3.up);
            Vector3 forwardDir = Vector3.Cross(leftDir, Vector3.down);
            float   worldAngle = Mathf.PI + get2DAngle(Vector2.right, new Vector2(forwardDir.x, forwardDir.z));
            worldAngle += movingAngle;

            MessageSystem.Publish("ui_move_angle", worldAngle * Mathf.Rad2Deg);
            MessageSystem.Publish("ui_move_speed", 1.0f);
        }
        else
        {
            MessageSystem.Publish("ui_move_speed", 0.0f);
        }


        if (!isDraging)
        {
            MoveDirection dir = getKeyboardDirection();
            if (dir != MoveDirection.Stand)
            {
                isMoving    = true;
                movingAngle = (((int)dir) / 8.0f) * Mathf.PI * 2 - Mathf.PI / 2;
            }
            else
            {
                isMoving = false;
            }
        }

        if (Input.GetAxis("Mouse ScrollWheel") != 0)
        {
            MessageSystem.Publish("ui_mouse_scroll", Input.GetAxis("Mouse ScrollWheel"));
        }
    }
Exemple #3
0
 void OnClickSkill(int id)
 {
     MessageSystem.Publish("ui_use_skill", id);
 }
Exemple #4
0
 public void SetBaseClass(Classifier @interface, MessageSystem messageSystem)
 {
     var oldBaseClass = BaseClass;
     BaseClass = @interface;
     if (oldBaseClass == null)
         messageSystem.Publish(this, new BaseClassSetEvent(@interface.Name));
     else
         messageSystem.Publish(this, new BaseClassChangedEvent(oldBaseClass.Name,@interface.Name));
 }