Repository navigation
Visual Sheets
DaanDuits edited this page May 23, 2025
·
2 revisions
[Rpc(SendTo.Server)]
private void LoadNetworkedSceneRpc(string _sceneName)
{
NetworkManager.SceneManager.LoadScene(_sceneName, LoadSceneMode.Single);
}
private IEnumerator LoadLocalScene(string _sceneName)
{
yield return new WaitForSeconds(loadDelay);
AsyncOperation _asyncLoad = SceneManager.LoadSceneAsync(_sceneName);
while(!_asyncLoad.isDone)
yield return null;
}MultiplayerVisualSheet.mp4
private void DismantleOrExplode()
{
AttackPosition = data.GridPosition;
if (Ship != null && Ship.dismantleMines && !_dismantled)
{
_dismantled = true;
Destroy(gameObject);
return;
}
for (byte i = 0; i < CompassDirections.Directions; i++)
{
AttackPosition = data.GridPosition + CompassDirections.DirectionToVector(startDirection);
if (Ship != null && Ship.dismantleMines && !_dismantled)
{
_dismantled = true;
AttackPosition = data.GridPosition;
if (Ship != null)
Destroy(gameObject);
return;
}
startDirection = CompassDirections.RotateClockwise(startDirection);
}
AttackPosition = data.GridPosition;
if (Attack())
return;
for (byte i = 0; i < CompassDirections.Directions; i++)
{
AttackPosition = data.GridPosition + CompassDirections.DirectionToVector(startDirection);
if (Attack())
return;
startDirection = CompassDirections.RotateClockwise(startDirection);
}
}VisualSheet.mp4
private void Calculate2DSpace()
{
_normal = (data.EndPosition - data.StartPosition).normalized;
_length = Mathf.Sqrt(Mathf.Pow(data.EndPosition.x - data.StartPosition.x, 2) + Mathf.Pow(data.EndPosition.z - data.StartPosition.z, 2));
}
private void Move()
{
float x = Mathf.Lerp(0, _length, _time);
float y = heightCurve.Evaluate(_time);
Vector3 rotated = new Vector3(x * _normal.x, y * heightMultiplier, x * _normal.z);
transform.position = rotated + data.StartPosition;
_time += Time.deltaTime * speed;
_time = Mathf.Clamp01(_time);
}
private void Rotate()
{
float x1 = Mathf.Lerp(0, _length, _time);
float y1 = heightCurve.Evaluate(_time);
Vector3 rotated1 = new Vector3(x1 * _normal.x, y1 * heightMultiplier, x1 * _normal.z);
Vector3 toTarget = (rotated1 + data.StartPosition - transform.position).normalized;
Vector3 forward = Vector3.Cross(toTarget, transform.right);
if (forward == Vector3.zero)
{
forward = Vector3.Cross(toTarget, transform.forward);
}
Quaternion targetRotation = Quaternion.LookRotation(forward, toTarget);
transform.rotation = targetRotation;
}