예제 #1
0
 private void InitEvent()
 {
     m_interactiveObject.LeftButtonPressed += (sender, e) =>
     {
         m_dragCoroutine = StartCoroutine(DragEnumerator());
         var args = new PlacedOnPlatformEventArgs();
         args.m_platform = m_lastPlacedPlatform;
         OnUnplaced(args);
     };
     m_interactiveObject.LeftButtonReleased += (sender, e) =>
     {
         if (m_dragCoroutine != null)
         {
             StopCoroutine(m_dragCoroutine);
         }
         if (m_lastPlatform)
         {
             m_lastPlatform.OnUnselected();
             var args = new PlacedOnPlatformEventArgs();
             args.m_platform = m_lastPlatform;
             OnPlaced(args);
             m_lastPlatform = null;
             DestroyBottomMark();
         }
     };
 }
예제 #2
0
 private void OnPlaced(PlacedOnPlatformEventArgs e)
 {
     if (m_placedEventHandle != null)
     {
         m_placedEventHandle(this, e);
     }
     m_lastPlacedPlatform = e.m_platform;
 }
예제 #3
0
        private bool GetHitGridPoint(out Vector3 gridPoint, out KaiTool_BasicPlatform platform)
        {
            var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            //var ray = new Ray(transform.position + transform.up * 100f, -transform.up);
            var hit = new RaycastHit();

            if (Physics.Raycast(ray, out hit, Mathf.Infinity, m_platformLayer))
            {
                platform = hit.transform.GetComponent <KaiTool_BasicPlatform>();

                if (platform)
                {
                    if (m_lastPlatform != platform && m_lastPlatform)
                    {
                        m_lastPlatform.OnUnselected();
                        DestroyBottomMark();
                    }
                    platform.OnSelected();
                    gridPoint      = platform.GetFloorGridPoint(hit.point);
                    m_lastPlatform = platform;
                    return(true);
                }
                else
                {
                    if (m_lastPlatform)
                    {
                        m_lastPlatform.OnUnselected();
                        m_lastPlatform = null;
                        DestroyBottomMark();
                    }
                    gridPoint = Vector3.one;
                    return(false);
                }
            }
            else
            {
                if (m_lastPlatform)
                {
                    m_lastPlatform.OnUnselected();
                    m_lastPlatform = null;
                    DestroyBottomMark();
                }
                gridPoint = Vector3.one;
                platform  = null;
                return(false);
            }
        }