예제 #1
0
    private void Stop(bool notify)
    {
        Logger.LogTraceFormat(STOPPED_FLOATING, Category.Movement, gameObject.name);
        if (IsTileSnap)
        {
            serverState.LocalPosition = Vector3Int.RoundToInt(serverState.LocalPosition);
        }
        else
        {
            serverState.Speed = 0;
        }
        serverState.WorldImpulse = Vector2.zero;
        serverState.SpinRotation = transform.localRotation.eulerAngles.z;
        serverState.SpinFactor   = 0;

        if (IsBeingThrownServer)
        {
            OnThrowEnd.Invoke(serverState.ActiveThrow);
        }

        serverState.ActiveThrow = ThrowInfo.NoThrow;
        if (notify)
        {
            NotifyPlayers();
        }
        registerTile.UpdatePositionServer();
    }
	private void AdvanceMovement(Vector3 tempOrigin, Vector3 tempGoal)
	{
		//Natural throw ending
		if (IsBeingThrown && ShouldStopThrow)
		{
			//			Logger.Log( $"{gameObject.name}: Throw ended at {serverState.WorldPosition}" );
			OnThrowEnd.Invoke(serverState.ActiveThrow);
			serverState.ActiveThrow = ThrowInfo.NoThrow;
			//Change spin when we hit the ground. Zero was kinda dull
			serverState.SpinFactor = (sbyte)(-serverState.SpinFactor * 0.2f);
			//todo: ground hit sound
		}

		serverState.WorldPosition = tempGoal;
		//Spess drifting is perpetual, but speed decreases each tile if object has landed (no throw) on the floor
		if (!IsBeingThrown && !MatrixManager.IsSlipperyOrNoGravityAt(Vector3Int.RoundToInt(tempOrigin)))
		{
			//no slide inertia for tile snapped objects like closets
			if (IsTileSnap)
			{
				Stop();
				return;
			}
			//on-ground resistance
			serverState.Speed = serverState.Speed - (serverState.Speed * (Time.deltaTime * 10));
			if (serverState.Speed <= 0.05f)
			{
				Stop();
			}
			else
			{
				NotifyPlayers();
			}
		}
	}
예제 #3
0
 private void ProcessLandingOnGround()
 {
     OnThrowEnd.Invoke(serverState.ActiveThrow);
     serverState.ActiveThrow = ThrowInfo.NoThrow;
     //Change spin when we hit the ground. Zero was kinda dull
     serverState.SpinFactor = (sbyte)(-serverState.SpinFactor * 0.2f);
     //todo: ground hit sound
 }