예제 #1
0
 private void OnPickUp(PickUpAbleItem arg0)
 {
     if (arg0 is RopeItem)
     {
         ropeSelected = arg0 as RopeItem;
     }
 }
예제 #2
0
 /// <summary>
 /// 试图绑定绳子
 /// </summary>
 /// <param name="arg0"></param>
 protected override void OnRegistElement(ISupportElement arg0)
 {
     if (ropeItem == null && arg0 is RopeItem)
     {
         ropeItem = arg0 as RopeItem;
         if (Started && ropeItem.BindingTarget == null)
         {
             ropeItem.StepActive();
             ropeItem.BindingTarget = this;
         }
     }
 }
예제 #3
0
        /// <summary>
        /// 找到或创建绳索
        /// </summary>
        private void TryFindAnRopeItem()
        {
            var ropes = elementCtrl.GetElements <RopeItem>(Name);

            if (ropes != null)
            {
                ropeItem = ropes.Find(x => x.BindingTarget == this || x.BindingTarget == null);
            }

            if (ropeItem != null)
            {
                ropeItem.BindingTarget = this;
                ropeItem.StepActive();
            }
        }
예제 #4
0
        /// <summary>
        /// 尝试放置绳子
        /// </summary>
        /// <param name="ropeSelected"></param>
        public void TryPlaceRope(RopeItem ropeSelected)
        {
            if (ropeSelected != ropeItem)
            {
                return;
            }
            var distence = Vector3.Distance(ropeSelected.transform.position, transform.position);

            if (distence < triggerDistence)
            {
                ropeSelected.transform.position = bestRopePos.transform.position;
                ropeSelected.transform.rotation = bestRopePos.transform.rotation;
                ropeSelected.OnPlace();
            }
        }
예제 #5
0
 private void TrySelectNode()
 {
     ray = viewCamera.ScreenPointToRay(Input.mousePosition);
     if (Physics.Raycast(ray, out hit, hitDistence, ropeNodeLayerMask))
     {
         var obj = hit.collider.GetComponentInParent <RopeItem>();
         if (obj != null && obj.Active && obj.BindingTarget != null)//正在进行操作
         {
             obj.BindingTarget.PickupCollider(hit.collider);
             ropeSelected     = obj;
             pickUpedRopeNode = hit.collider;
             Debug.Log("Select: " + pickUpedRopeNode);
             elementDistence = Vector3.Distance(viewCamera.transform.position, pickUpedRopeNode.transform.position);
         }
     }
 }
예제 #6
0
 private static bool CanPlaceNode(RopeObj ropeTarget, RopeItem 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);
 }
예제 #7
0
 /// <summary>
 /// 试图解除绑定
 /// </summary>
 /// <param name="arg0"></param>
 protected override void OnRemoveElement(ISupportElement arg0)
 {
     ropeItem.BindingTarget = null;
     ropeItem = null;
 }