public void OnDirectionChange(DirectionChange messageObject) { DirectionChange change = messageObject; switch (change.newDirection) { case MovementDirection.Left: SetAnimationTrigger("Walk Left"); break; case MovementDirection.Right: SetAnimationTrigger("Walk Right"); break; case MovementDirection.Up: SetAnimationTrigger("Walk Up"); break; case MovementDirection.Down: SetAnimationTrigger("Walk Down"); break; case MovementDirection.None: SetAnimationTrigger("Stop"); break; default: break; } }
//结尾 void PrepareOutro() { positionTo = tileFrom.transform.localPosition; directionChange = DirectionChange.None; directionAngleTo = direction.GetAngle(); model.localPosition = new Vector3(pathOffest, 0f); transform.localRotation = direction.GetRotation(); progressFactor = 2f * speed; }
// internal DirectionChange[] GetDirectionChanges() { int lc = list.Count - 1; DirectionChange[] dirChanges = new DirectionChange[lc]; for (int i = 0; i < lc; i++) { dirChanges[i] = new DirectionChange(Math.Sign(list[i + 1] - list[i]), i); } return(dirChanges); }
void PrepareIntro() { //起点坐标 positionFrom = tileFrom.transform.localPosition; //终点坐标 positionTo = tileFrom.ExitPoint; //起点方向 direction = tileFrom.PathDirection; //方向变化 directionChange = DirectionChange.None; //获取当前方向的角度及若变换到下一方向的角度 directionAngleFrom = directionAngleTo = direction.GetAngle(); model.localPosition = new Vector3(pathOffest, 0f); //获取当前的旋转欧拉角 transform.localRotation = direction.GetRotation(); progressFactor = 2f * speed; }
public void TryChangeDirection(DirectionChange _directionChanger) { if (canTurn) { canTurn = false; StartCoroutine(ChangeCanTurnValueCR()); Path nextPath = _directionChanger.GetConnectionFrom(entityReference.GetCurrentPath); // nextPathReference = nextPath; if (nextPath) { Vector3 currentDirection = entityReference.GetFollowPathComponent.GetCurrentDirection; Vector3 nextDirection = nextPath.GetDirectionAt(nextPath.GetTParameter(transform.position)); OnStartDirectionChangeArgs directionArgs = new OnStartDirectionChangeArgs { CurrentDirection = currentDirection, NextDirection = nextDirection, NextPath = nextPath }; onStartDirectionChange?.Invoke(directionArgs); } } }
void PrepareNextState() { tileFrom = tileTo; tileTo = tileTo.NextTileOnPath; //将上一个位置终点当做此次位置起点。依次往复,直到达到终点 positionFrom = positionTo; if (tileTo == null) { PrepareOutro(); return; } positionTo = tileFrom.ExitPoint; //将上一方向变换至下一方向,并缓存当前方向变换 directionChange = direction.GetDirectionChangeTo(tileFrom.PathDirection); //当前方向修改至以变换的方向 direction = tileFrom.PathDirection; //记录起点变换角度 directionAngleFrom = directionAngleTo; //根据变换的下一方向,来决定终点变换的角度 switch (directionChange) { case DirectionChange.None: PrepareForward(); break; case DirectionChange.TurnRight: PrepareTurnRight(); break; case DirectionChange.TurnLeft: PrepareTurnLeft(); break; default: PrepareTurnAround(); break; } }
protected virtual void OnDirectionChange() { DirectionChange?.Invoke(this, new StringEventArgs(direction)); }
protected int getDirection(DirectionChange dir_change) { return(dir_change == DirectionChange.Random ? (random.NextBoolean() ? -1 : 1) : dir_change == DirectionChange.TowardsJuni ? (Juni.ApparentPosition.x > Center.x ? 1 : -1) : (Juni.ApparentPosition.x > Center.x ? -1 : 1)); }
public void OnDirectionChange(DirectionChange messageObject) { DirectionChange change = messageObject; switch (change.newDirection) { case MovementDirection.Left: bodyAnimator.SetTrigger("Walk Left"); break; case MovementDirection.Right: bodyAnimator.SetTrigger("Walk Right"); break; case MovementDirection.Up: bodyAnimator.SetTrigger("Walk Up"); break; case MovementDirection.Down: bodyAnimator.SetTrigger("Walk Down"); break; case MovementDirection.None: bodyAnimator.SetTrigger("Stop"); break; default: break; } }