示例#1
0
 /// <summary>
 /// 尝试安装元素
 /// </summary>
 void TryInstallObject()
 {
     ray = Camera.main.ScreenPointToRay(Input.mousePosition);
     if (Physics.Raycast(ray, out hit, 100, elementInstallLayer))
     {
         installPos = hit.collider.GetComponent <InstallPos>();
         if (installPos != null)
         {
             //判断当前坐标可否安装
             if (endParent.CanPosInstall(installPos))
             {
                 if (startParent.CanInstallToPos(installPos))
                 {
                     startParent.InstallPickedUpObject(installPos);
                     pickedUp = false;
                 }
             }
         }
     }
     else
     {
         startParent.PickDownPickedUpObject();
         pickedUp = false;
     }
 }
 /// <summary>
 /// 是否可以安装到指定坐标(名称条件)
 /// </summary>
 /// <param name="pos"></param>
 /// <returns></returns>
 public bool CanInstallToPos(InstallPos pos)
 {
     if (pickedUpObj != null)
     {
         return(pickedUpObj.name == pos.name);
     }
     return(false);
 }
 /// <summary>
 /// 安装元素到指定坐标
 /// </summary>
 /// <param name="pos"></param>
 public void InstallPickedUpObject(InstallPos pos)
 {
     if (pickedUpObj != null && !pickedUpObj.Installed)
     {
         pickedUpObj.NormalInstall(pos);
         pos.Attach(pickedUpObj);
     }
 }
示例#4
0
 /// <summary>
 /// 判断是否可以安装
 /// </summary>
 /// <param name="installpos"></param>
 /// <returns></returns>
 public bool CanPosInstall(InstallPos installObj)
 {
     if (currInstallPoss.Contains(installObj) && !installObj.Installed)
     {
         return(true);
     }
     return(false);
 }
 /// <summary>
 /// 定位安装
 /// </summary>
 /// <param name="target"></param>
 public void QuickInstall(InstallPos target)
 {
     if (!Installed)
     {
         transform.position = target.transform.position;
         transform.rotation = target.transform.rotation;
         this.target        = target;
     }
 }
 /// <summary>
 /// 动画安装
 /// </summary>
 /// <param name="target"></param>
 public void NormalInstall(InstallPos target)
 {
     if (!Installed)
     {
         transform.rotation = target.transform.rotation;
         move.ChangeValues(transform.position, target.transform.position).Restart();
         this.target = target;
     }
 }
 public void NormalUnInstall()
 {
     if (Installed)
     {
         move.Pause();
         transform.rotation = startRotation;
         move.ChangeValues(transform.position, startPos).Restart();
         target = null;
     }
 }
 public void QuickUnInstall()
 {
     if (Installed)
     {
         move.Pause();
         transform.rotation = startRotation;
         transform.position = startPos;
         target.Detach();
         target = null;
     }
 }