private void DragObject() { if (!Grid_ || !GridCollider_) { return; } #if !UNITY_EDITOR && !UNITY_STANDALONE && !UNITY_WEBPLAYER if (Input.touchCount > 1) { Debugger.Log("<color=red>more than one finger touched, do nothing! count: </color>" + Input.touchCount); return; } #endif Vector3 cursorWorldPoint = ShootRay(); CachedTransform_.position = cursorWorldPoint; Grid_.AlignTransform(CachedTransform_); CachedTransform_.position = DeployUnitPositionCorrector.CalculateOffsetY(Grid_, CachedTransform_); //DeployUnitPositionCorrector.CorrectOffsetXZ(Grid_, CachedTransform_, ShipWrapRadius); DeployUnitMenu.Instance.SetFollowTarget(transform); if (!FollowIconShow_) //仅在第一次显示跟随图标 { FollowIcon.Follow(); } }
void Awake() { CachedTransform_ = transform; if (Grid_) { GridCollider_ = Grid_.gameObject.GetComponent <Collider>(); if (GridCollider_) { //perform an initial align and snap the objects to the bottom Grid_.AlignTransform(CachedTransform_); CachedTransform_.position = DeployUnitPositionCorrector.CalculateOffsetY(Grid_, CachedTransform_); } } SetupRigidbody(); ConstructTrigger(); Renderers_ = GetComponentsInChildren <Renderer>(); DefaultMaterial_ = Renderers_[0].material; }
private IEnumerator SyncClickFromUI(Vector3 pickedPos, System.Action InvalidCallback) { CachedTransform_.position = pickedPos; //更正位置 CachedTransform_.position = DeployUnitPositionCorrector.CalculateOffsetY(Grid_, CachedTransform_); //DeployUnitPositionCorrector.CorrectOffsetXZ(Grid_, CachedTransform_, ShipWrapRadius); yield return(new WaitForSeconds(0.05f)); if (InvalidClickDeploy) { //点选布阵时有交叉 InvalidClickDeploy = false; //Debugger.Log("<color=yellow>Click Deploy Exist Intersection!Cancel Deploy!</color>"); CancelThisDeploy(); } else { //更新布阵状态为:完成布阵 State = DeployState.OnPlaced; InvalidCallback(); } }