Ejemplo n.º 1
0
        /// <summary>
        /// 尝试放置绳子
        /// </summary>
        /// <param name="ropeSelected"></param>
        public void TryPlaceRope(RopeElement ropeSelected)
        {
            if (ropeSelected == null)
            {
                return;
            }
            //if (ropeElement != null) return;
            if (!ropeSelected.OperateAble)
            {
                return;
            }

            var distence = Vector3.Distance(ropeSelected.transform.position, transform.position);

            if (distence < triggerDistence)
            {
                ropeSelected.RecordPlayer(this);
                contentFeature.Element = ropeSelected;

                ropeSelected.transform.position = bestRopePos.transform.position;
                ropeSelected.transform.rotation = bestRopePos.transform.rotation;
                ropeSelected.OnPlaceRopeElement();
                NoticePickupAbleNode();
            }
        }
Ejemplo n.º 2
0
        private void OnPickUp(PickUpAbleComponent arg0)
        {
            var ropeElement = arg0.GetComponentInParent <RopeElement>();

            if (ropeElement)
            {
                ropeSelected = ropeElement;
            }
        }
Ejemplo n.º 3
0
 private void TrySelectNode()
 {
     ray = viewCamera.ScreenPointToRay(Input.mousePosition);
     if (Physics.Raycast(ray, out hit, hitDistence, ropeNodeLayerMask))
     {
         var obj = hit.collider.GetComponentInParent <RopeElement>();
         if (obj != null && obj.Actived)//正在进行操作
         {
             obj.BindingTarget.PickupCollider(hit.collider);
             ropeSelected     = obj;
             pickUpedRopeNode = hit.collider;
             Debug.Log("Select: " + pickUpedRopeNode);
             elementDistence = Vector3.Distance(viewCamera.transform.position, pickUpedRopeNode.transform.position);
         }
     }
 }
Ejemplo n.º 4
0
 private static bool CanPlaceNode(RopeItem ropeTarget, RopeElement ropeSelected, Collider collider, out string resonwhy)
 {
     resonwhy = null;
     //if (ropeSelected.BindingTarget != ropeTarget)
     //{
     //    resonwhy = "对象不匹配";
     //}
     //else
     if (ropeTarget == null)
     {
         resonwhy = "目标点父级没有挂RopeObj脚本";
     }
     else if (ropeTarget.Connected)
     {
         resonwhy = "目标点已经完成连接";
     }
     else if (!ropeTarget.CanInstallCollider(collider))
     {
         resonwhy = "坐标点已经占用";
     }
     return(resonwhy == null);
 }