protected virtual PlaceObj UnBinding() { var old = target; target = null; return(old); }
public bool CanPlace(PlaceObj matchPos, PickUpAbleItem element, out string why) { var matchAble = true; if (matchPos == null) { why = "【配制错误】:零件未挂MatchObj脚本"; Debug.LogError("【配制错误】:零件未挂MatchObj脚本"); matchAble = false; } else if (!matchPos.Started) { matchAble = false; why = "操作顺序错误"; } else if (matchPos.AlreadyPlaced) { matchAble = false; why = "已经触发结束"; } else if (matchPos.Name != element.Name) { matchAble = false; why = "零件不匹配"; } else { why = null; matchAble = true; } return(matchAble); }
public bool CanPlace(PlaceObj placeObj, PickUpAbleItem element, out string why) { why = null; var canplace = true; if (placeObj == null) { Debug.LogError("【配制错误】:零件未挂InstallObj脚本"); } else if (!placeObj.Started) { canplace = false; why = "操作顺序错误"; } else if (placeObj.AlreadyPlaced) { canplace = false; why = "已经安装"; } else if (element.Name != placeObj.Name) { canplace = false; why = "零件不匹配"; } else { canplace = true; } return(canplace); }
public void CompleteElements(PlaceObj element, bool undo) { lockQueue.Remove(element); var active = lockQueue.Find(x => x.Name == element.Name); if (active == null) { var objs = GetElements(element.Name); if (objs == null) { return; } for (int i = 0; i < objs.Count; i++) { if (log) { Debug.Log("CompleteElements:" + element.Name + objs[i].Started); } if (objs[i].Started) { if (undo) { objs[i].StepUnDo(); } else { objs[i].StepComplete(); } } } } }
public void ActiveElements(PlaceObj element) { var actived = lockQueue.Find(x => x.Name == element.Name); if (actived == null) { var objs = GetElements(element.Name); if (objs == null) { return; } for (int i = 0; i < objs.Count; i++) { if (log) { Debug.Log("ActiveElements:" + element.Name + (!objs[i].Started && !objs[i].HaveBinding)); } if (!objs[i].Started && !objs[i].HaveBinding) { objs[i].StepActive(); } } } lockQueue.Add(element); }
public void UpdatePlaceState() { if (pickedUpObj == null) { return; } if (!pickedUpObj.Active) { resonwhy = "当前步骤无需该零件!"; installAble = false; } else { ray = viewCamera.ScreenPointToRay(Input.mousePosition); hits = Physics.RaycastAll(ray, hitDistence, PlacePoslayerMask); if (hits != null || hits.Length > 0) { var hitedObj = false; for (int i = 0; i < hits.Length; i++) { installPos = hits[i].collider.GetComponentInParent <PlaceObj>(); if (installPos) { SwitchState(installPos.CtrlType); hitedObj = true; installAble = CanPlace(installPos, pickCtrl.pickedUpObj, out resonwhy); if (installAble) { break; } } } if (!hitedObj) { installAble = false; resonwhy = "零件放置位置不正确"; } } } if (installAble) { //可安装显示绿色 if (activeNotice) { highLight.HighLightTarget(pickedUpObj.Render, Color.green); } } else { //不可安装红色 if (activeNotice) { highLight.HighLightTarget(pickedUpObj.Render, Color.red); } } }
/// <summary> /// 快速卸载 /// </summary> public virtual void QuickUnInstall() { Debug.Log("QuickUnInstall"); #if !NoFunction StopTween(); transform.eulerAngles = startRotation; transform.position = startPos; target = null; if (HaveBinding) { UnBinding(); } OnUnInstallComplete(); #endif }
/// <summary> /// 动画安装 /// </summary> /// <param name="target"></param> public virtual void NormalInstall(PlaceObj target, bool complete = true, bool binding = true) { StopTween(); if (!HaveBinding) { Binding(target); tweenCompleteAction = () => { OnInstallComplete(complete); }; DoPath(target.transform.position, target.transform.eulerAngles); if (!binding) { UnBinding(); } } }
/// <summary> /// 定位安装 /// </summary> /// <param name="target"></param> public virtual void QuickInstall(PlaceObj target, bool complete = true, bool binding = true) { StopTween(); if (!HaveBinding) { Binding(target); transform.position = target.transform.position; transform.rotation = target.transform.rotation; if (!binding) { UnBinding(); } OnInstallComplete(complete); } else { Debug.LogError(this + "HaveBinding:" + BindingObj); } }
public void PlaceObject(PlaceObj pos, PlaceElement pickup) { pos.Attach(placeCtrl.pickedUpObj); placeCtrl.pickedUpObj.QuickInstall(pos, false, false); }
public bool CanPlace(PlaceObj placeItem, PickUpAbleItem element, out string why) { return(current.CanPlace(placeItem, element, out why)); }
public void PlaceObject(PlaceObj pos, PickUpAbleElement pickup) { current.PlaceObject(pos, pickup); }
public void PlaceObject(PlaceObj pos, PlaceElement pickup) { pos.Attach(pickup); pickup.QuickInstall(pos); pickup.PickUpAble = false; }
protected virtual void Binding(PlaceObj target) { this.target = target; }