public void PassBarrier(Barrier barrier, Action reachEnd) { float goStartTime = Mathf.Clamp(Vector3.Distance(_mem.transform.position, barrier.passStartPosition), 0.5f, 1f); float goEndTime = (barrier.neededManCount + 1) / 5f; Vector3 endPosition; TweenData[] passTweens = InteractBarrierBaseTweens(barrier, barrier.neededManCount - 1, out endPosition, goStartTime, goEndTime, (() => barrier.UnlockBarrier())); //add an extra tween when passing barrier //Debug.Log($"current end position {endPosition} "); endPosition += -barrier.transform.forward * 2f;// * Mathf.Abs(_myGang.Head.position.z - endPosition.z) / 2f; endPosition.y = barrier.passEndPosition.y; TweenData goTowardGangHead = MemberSequenceUtils.GoToDestination(_mem.transform, endPosition, 0.1f); //Debug.Log($"after end position {endPosition} "); passTweens = passTweens.Append(goTowardGangHead).ToArray(); AnimData walkAnim = new AnimData(MemberAnimType.Locomotion, goStartTime); AnimData passAnim = new AnimData(MemberAnimType.Climb, goEndTime); MemberSequenceUtils.BuildTweenSequence(passTweens, (() => reachEnd())); _mem.StartCoroutine(DoAnimSequence(walkAnim, passAnim)); }
public void BeBarrierPass(Barrier barrier, Action reachEnd)//, AnimData[] animDatas, TweenData[] tweens) { float goStartTime = Mathf.Clamp(Vector3.Distance(_mem.transform.position, barrier.passStartPosition), 0.5f, 0.7f); float goEndTime = (barrier.currentStepCount + 1) / 5f; Vector3 endPosition; TweenData[] passTweens = InteractBarrierBaseTweens(barrier, barrier.currentStepCount - 1, out endPosition, goStartTime, goEndTime); AnimData walkAnim = new AnimData(MemberAnimType.Locomotion, goStartTime); AnimData passAnim = new AnimData(MemberAnimType.Climb, goEndTime); MemberSequenceUtils.BuildTweenSequence(passTweens, (() => reachEnd())); _mem.StartCoroutine(DoAnimSequence(walkAnim, passAnim)); }
public void MemberJump(Vector3 fellStarPos, Action reachedJumpFrom) { fellStarPos.y = _mem.transform.position.y; float goStartTime = Mathf.Clamp(Vector3.Distance(_anim.transform.position, fellStarPos), 0.5f, 0.7f); TweenData goTowardJumpPos = MemberSequenceUtils.GoToDestination(_anim.transform, fellStarPos, goStartTime); //goTowardJumpPos.SetOnComplete(reachedJumpFrom); goTowardJumpPos.join = true; //_mem.transform.LookAt(fellStarPos); Quaternion targetRot = Quaternion.LookRotation(fellStarPos); TweenData rotateToJumpPos = MemberSequenceUtils.RotateTowardsDestination(_mem.transform, targetRot.eulerAngles, goStartTime / 2f); rotateToJumpPos.join = true; MemberSequenceUtils.BuildTweenSequence(new [] { goTowardJumpPos, rotateToJumpPos }, (() => reachedJumpFrom())); AnimData walkAnim = new AnimData(MemberAnimType.Locomotion, goStartTime); AnimData jumpAnim = new AnimData(MemberAnimType.Jump, 0f); _mem.StartCoroutine(DoAnimSequence(walkAnim, jumpAnim)); }