예제 #1
0
    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;
        }
    }
예제 #2
0
 //结尾
 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;
 }
예제 #3
0
        //
        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);
        }
예제 #4
0
 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;
 }
예제 #5
0
 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);
         }
     }
 }
예제 #6
0
    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;
        }
    }
예제 #7
0
 protected virtual void OnDirectionChange()
 {
     DirectionChange?.Invoke(this, new StringEventArgs(direction));
 }
예제 #8
0
 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));
 }
예제 #9
0
	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;
		}
	}