浏览代码

taking reverse merge from develop

/main
David Woodruff 4 年前
当前提交
13a7f3fb
共有 8 个文件被更改,包括 75 次插入63 次删除
  1. 34
      Assets/BossRoom/Prefabs/Player.prefab
  2. 11
      Assets/BossRoom/Scripts/Client/ClientCharacterVisualization.cs
  3. 7
      Assets/BossRoom/Scripts/Client/ClientInputSender.cs
  4. 47
      Assets/BossRoom/Scripts/Server/ServerCharacterMovement.cs
  5. 11
      Assets/BossRoom/Scripts/Shared/NetworkCharacterState.cs
  6. 7
      Packages/manifest.json
  7. 17
      Packages/packages-lock.json
  8. 4
      ProjectSettings/ProjectVersion.txt

34
Assets/BossRoom/Prefabs/Player.prefab


- component: {fileID: 4600110157238723777}
- component: {fileID: 4600110157238723776}
- component: {fileID: 4600110157238723779}
- component: {fileID: 4093145920273822261}
- component: {fileID: 4093145920273822261}
m_Layer: 0
m_Name: Player
m_TagString: Untagged

m_Script: {fileID: 11500000, guid: edb78c1621dad5149bb47b96120d3fbf, type: 3}
m_Name:
m_EditorClassIdentifier:
NetworkPosition:
InternalValue: {x: 0, y: 0, z: 0}
NetworkRotationY:
InternalValue: 0
--- !u!114 &4600110157238723776
MonoBehaviour:
m_ObjectHideFlags: 0

m_Script: {fileID: 11500000, guid: fdad0914904cc1e47933ecd7a58514ac, type: 3}
m_Name:
m_EditorClassIdentifier:
movementSpeed: 4
m_MovementSpeed: 3
--- !u!114 &4093145920273822261
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4600110157238723781}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9520a47fc61d5ab4ca99cdac2d574909, type: 3}
m_Name:
m_EditorClassIdentifier:
m_ClientVisuals: {fileID: 1935255767028652502}
--- !u!54 &4470766618279719912
Rigidbody:
m_ObjectHideFlags: 0

m_Height: 2
m_Direction: 1
m_Center: {x: 0, y: 1, z: 0}
--- !u!114 &4093145920273822261
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4600110157238723781}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9520a47fc61d5ab4ca99cdac2d574909, type: 3}
m_Name:
m_EditorClassIdentifier:
m_ClientVisuals: {fileID: 1935255767028652502}

11
Assets/BossRoom/Scripts/Client/ClientCharacterVisualization.cs


[RequireComponent(typeof(NetworkCharacterState))]
public class ClientCharacterVisualization : NetworkedBehaviour
{
private NetworkCharacterState networkCharacterState;
private NetworkCharacterState m_NetworkCharacterState;
/// <summary>
/// The GameObject which visually represents the character is a child object of the character GameObject. This needs to be the case to support host mode.

[SerializeField] private Transform m_ClientVisuals;
[SerializeField]
private Transform m_ClientVisuals;
/// <inheritdoc />
public override void NetworkStart()

void Awake()
{
networkCharacterState = GetComponent<NetworkCharacterState>();
m_NetworkCharacterState = GetComponent<NetworkCharacterState>();
m_ClientVisuals.position = networkCharacterState.NetworkPosition.Value;
m_ClientVisuals.position = m_NetworkCharacterState.NetworkPosition.Value;
m_ClientVisuals.rotation = Quaternion.Euler(0, networkCharacterState.NetworkRotationY.Value, 0);
m_ClientVisuals.rotation = Quaternion.Euler(0, m_NetworkCharacterState.NetworkRotationY.Value, 0);
}
}
}

7
Assets/BossRoom/Scripts/Client/ClientInputSender.cs


[RequireComponent(typeof(NetworkCharacterState))]
public class ClientInputSender : NetworkedBehaviour
{
private NetworkCharacterState networkCharacter;
private NetworkCharacterState m_NetworkCharacter;
public override void NetworkStart()
{

void Awake()
{
networkCharacter = GetComponent<NetworkCharacterState>();
m_NetworkCharacter = GetComponent<NetworkCharacterState>();
}
void FixedUpdate()

if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit))
{
// The MLAPI_INTERNAL channel is a reliable sequenced channel. Inputs should always arrive and be in order that's why this channel is used.
networkCharacter.InvokeServerRpc(networkCharacter.SendCharacterInputServerRpc, hit.point, "MLAPI_INTERNAL");
m_NetworkCharacter.InvokeServerRpc(m_NetworkCharacter.SendCharacterInputServerRpc, hit.point,
"MLAPI_INTERNAL");
}
}
}

47
Assets/BossRoom/Scripts/Server/ServerCharacterMovement.cs


/// <summary>
/// Component responsible for moving a character on the server side based on inputs.
/// </summary>
[RequireComponent(typeof(NavMeshAgent))]
[RequireComponent(typeof(NetworkCharacterState))]
[RequireComponent(typeof(NetworkCharacterState), typeof(NavMeshAgent))]
private NavMeshAgent navMeshAgent;
private NetworkCharacterState networkCharacterState;
private NavMeshAgent m_NavMeshAgent;
private NetworkCharacterState m_NetworkCharacterState;
private NavMeshPath path;
private MovementState movementState;
private NavMeshPath m_DesiredMovementPath;
private MovementState m_MovementState;
private float movementSpeed; // TODO this should be assigned based on character definition
private float m_MovementSpeed; // TODO [GOMPS-86] this should be assigned based on character definition
public override void NetworkStart()
{

}
// On the server enable navMeshAgent and initialize
navMeshAgent.enabled = true;
networkCharacterState.OnReceivedClientInput += SetMovementTarget;
path = new NavMeshPath();
m_NavMeshAgent.enabled = true;
m_NetworkCharacterState.OnReceivedClientInput += SetMovementTarget;
m_DesiredMovementPath = new NavMeshPath();
movementState = MovementState.PathFollowing;
m_MovementState = MovementState.PathFollowing;
navMeshAgent.CalculatePath(position, path);
m_NavMeshAgent.CalculatePath(position, m_DesiredMovementPath);
navMeshAgent = GetComponent<NavMeshAgent>();
networkCharacterState = GetComponent<NetworkCharacterState>();
m_NavMeshAgent = GetComponent<NavMeshAgent>();
m_NetworkCharacterState = GetComponent<NetworkCharacterState>();
if (movementState == MovementState.PathFollowing)
if (m_MovementState == MovementState.PathFollowing)
networkCharacterState.NetworkPosition.Value = transform.position;
networkCharacterState.NetworkRotationY.Value = transform.rotation.eulerAngles.y;
m_NetworkCharacterState.NetworkPosition.Value = transform.position;
m_NetworkCharacterState.NetworkRotationY.Value = transform.rotation.eulerAngles.y;
var corners = path.corners;
var corners = m_DesiredMovementPath.corners;
if (!corners.Any())
if (corners.Length == 0)
movementState = MovementState.Idle;
m_MovementState = MovementState.Idle;
var desiredMovementAmount = movementSpeed * Time.fixedDeltaTime;
var desiredMovementAmount = m_MovementSpeed * Time.fixedDeltaTime;
// If there is less distance to move left in the path than our desired amount
if (Vector3.SqrMagnitude(corners[corners.Length - 1] - transform.position) < (desiredMovementAmount * desiredMovementAmount))

movementState = MovementState.Idle;
m_MovementState = MovementState.Idle;
return;
}

var movementVector = direction * desiredMovementAmount;
navMeshAgent.Move(movementVector);
m_NavMeshAgent.Move(movementVector);
navMeshAgent.CalculatePath(corners[corners.Length - 1], path);
m_NavMeshAgent.CalculatePath(corners[corners.Length - 1], m_DesiredMovementPath);
}
}
}

11
Assets/BossRoom/Scripts/Shared/NetworkCharacterState.cs


/// </summary>
public class NetworkCharacterState : NetworkedBehaviour
{
public NetworkedVarVector3 NetworkPosition;
public NetworkedVarFloat NetworkRotationY;
/// <summary>
/// The networked position of this Character. This reflects the authorative position on the server.
/// </summary>
public NetworkedVarVector3 NetworkPosition { get;} = new NetworkedVarVector3();
/// <summary>
/// The networked rotation of this Character. This reflects the authorative rotation on the server.
/// </summary>
public NetworkedVarFloat NetworkRotationY { get; } = new NetworkedVarFloat();
/// <summary>
/// Gets invoked when inputs are received from the client which own this networked character.

7
Packages/manifest.json


"com.unity.cinemachine": "2.6.3",
"com.unity.collab-proxy": "1.3.9",
"com.unity.ide.rider": "2.0.7",
"com.unity.ide.visualstudio": "2.0.2",
"com.unity.ide.vscode": "1.2.1",
"com.unity.ide.visualstudio": "2.0.5",
"com.unity.ide.vscode": "1.2.3",
"com.unity.test-framework": "1.1.16",
"com.unity.multiplayer.multipie": "https://github.com/Unity-Technologies/com.unity.multiplayer.multipie.git",
"com.unity.test-framework": "1.1.19",
"com.unity.textmeshpro": "3.0.1",
"com.unity.timeline": "1.4.3",
"com.unity.ugui": "1.0.0",

17
Packages/packages-lock.json


"url": "https://packages.unity.com"
},
"com.unity.ext.nunit": {
"version": "1.0.0",
"version": "1.0.5",
"depth": 1,
"source": "registry",
"dependencies": {},

"url": "https://packages.unity.com"
},
"com.unity.ide.visualstudio": {
"version": "2.0.2",
"version": "2.0.5",
"depth": 0,
"source": "registry",
"dependencies": {},

"version": "1.2.1",
"version": "1.2.3",
"depth": 0,
"source": "registry",
"dependencies": {},

},
"hash": "726b77f90f2bb2879303cf72a22048ac0abf4084"
},
"com.unity.multiplayer.multipie": {
"version": "https://github.com/Unity-Technologies/com.unity.multiplayer.multipie.git",
"depth": 0,
"source": "git",
"dependencies": {},
"hash": "bb86715f2a0144fdced1386eb40edaa6839ff4cd"
},
"com.unity.multiplayer.transport.litenet": {
"version": "file:com.unity.multiplayer.transport.litenet",
"depth": 0,

"url": "https://packages.unity.com"
},
"com.unity.test-framework": {
"version": "1.1.16",
"version": "1.1.19",
"com.unity.ext.nunit": "1.0.0",
"com.unity.ext.nunit": "1.0.5",
"com.unity.modules.imgui": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0"
},

4
ProjectSettings/ProjectVersion.txt


m_EditorVersion: 2020.2.0b5
m_EditorVersionWithRevision: 2020.2.0b5 (e2067236bd5c)
m_EditorVersion: 2020.2.0f1
m_EditorVersionWithRevision: 2020.2.0f1 (3721df5a8b28)
正在加载...
取消
保存