Skip to content

Commit

Permalink
Consertando rotação
Browse files Browse the repository at this point in the history
  • Loading branch information
lucas-khaled committed Sep 13, 2021
1 parent b6501b1 commit 68f9404
Show file tree
Hide file tree
Showing 9 changed files with 150 additions and 62 deletions.
28 changes: 12 additions & 16 deletions .idea/.idea.Extreme-Snowboarding/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

81 changes: 62 additions & 19 deletions Assets/Resources/Player.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -65,26 +65,9 @@ MonoBehaviour:
OwnershipTransfer: 0
ObservedComponents:
- {fileID: 5047158400277881475}
- {fileID: 8686251071526131219}
viewIdField: 0
InstantiationId: 0
isRuntimeInstantiated: 0
--- !u!114 &8686251071526131219
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1384769323432956389}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 627855c7f81362d41938ffe0b1475957, type: 3}
m_Name:
m_EditorClassIdentifier:
m_SynchronizePosition: 1
m_SynchronizeRotation: 1
m_SynchronizeScale: 0
m_UseLocal: 1
--- !u!1 &5797606892110252708
GameObject:
m_ObjectHideFlags: 0
Expand All @@ -100,7 +83,7 @@ GameObject:
- component: {fileID: -2960936140915857356}
- component: {fileID: 7695480993240459834}
- component: {fileID: 5471711173143376703}
m_Layer: 0
m_Layer: 3
m_Name: Player
m_TagString: Player
m_Icon: {fileID: 0}
Expand All @@ -115,7 +98,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5797606892110252708}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0.0050461665, y: 0.012710025, z: 0}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1764391739971603295}
Expand Down Expand Up @@ -303,14 +286,74 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: -7865630966810642468, guid: 3aabecf32c53147838d0a63a9d07438a, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: -7865630966810642468, guid: 3aabecf32c53147838d0a63a9d07438a, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: -7865630966810642468, guid: 3aabecf32c53147838d0a63a9d07438a, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: -7865630966810642468, guid: 3aabecf32c53147838d0a63a9d07438a, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: -7865630966810642468, guid: 3aabecf32c53147838d0a63a9d07438a, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 919132149155446097, guid: 3aabecf32c53147838d0a63a9d07438a, type: 3}
propertyPath: m_Name
value: RenatoTCC
objectReference: {fileID: 0}
- target: {fileID: 5184177756290302002, guid: 3aabecf32c53147838d0a63a9d07438a, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5184177756290302002, guid: 3aabecf32c53147838d0a63a9d07438a, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5184177756290302002, guid: 3aabecf32c53147838d0a63a9d07438a, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5184177756290302002, guid: 3aabecf32c53147838d0a63a9d07438a, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5184177756290302002, guid: 3aabecf32c53147838d0a63a9d07438a, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5866666021909216657, guid: 3aabecf32c53147838d0a63a9d07438a, type: 3}
propertyPath: m_Controller
value:
objectReference: {fileID: 9100000, guid: c6c2530e171949e409633f713e47b9a1, type: 2}
- target: {fileID: 7022108065205083589, guid: 3aabecf32c53147838d0a63a9d07438a, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7022108065205083589, guid: 3aabecf32c53147838d0a63a9d07438a, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7022108065205083589, guid: 3aabecf32c53147838d0a63a9d07438a, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7022108065205083589, guid: 3aabecf32c53147838d0a63a9d07438a, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7022108065205083589, guid: 3aabecf32c53147838d0a63a9d07438a, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 3aabecf32c53147838d0a63a9d07438a, type: 3}
--- !u!1 &1384769323432956389 stripped
Expand Down
50 changes: 30 additions & 20 deletions Assets/Script/Controllers/CorridaController.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using ExitGames.Client.Photon;
Expand Down Expand Up @@ -188,12 +189,7 @@ private void Start()
}
InvokeRepeating("CheckPlayerClassification",0,0.1f);
}

private void InstantiatePlayers()
{
InstancePlayer(transform.position, _playerData);
}


public void InstancePlayer(Vector3 position, PlayerData playerData)
{
Player.Player player = Instantiate(playerPrefab, position, playerPrefab.transform.rotation);
Expand All @@ -204,7 +200,7 @@ public void InstancePlayer(Vector3 position, PlayerData playerData)
Debug.Log("Allocated");
object[] data =
{
player.transform.position, player.transform.rotation, photonView.ViewID, PlayerData.Serialize(playerData)
player.transform.position, photonView.ViewID, PlayerData.Serialize(playerData)
};

RaiseEventOptions raiseEventOptions = new RaiseEventOptions
Expand All @@ -223,12 +219,12 @@ public void InstancePlayer(Vector3 position, PlayerData playerData)
else
{
Debug.LogError("Failed to allocate a ViewId.");

Destroy(player);
return;
}

player.SetMaterials(playerData.color1, playerData.color2, playerData.playerMeshes, instantiationSettings);
_playersInGame.Add(player);
player.SetMaterialsAndMeshes(playerData.color1, playerData.color2, playerData.playerMeshes, instantiationSettings);
StartCoroutine(AddAPlayer(player));

camera.SetInitialPlayer(player);
player.name = "My player";
Expand All @@ -239,30 +235,44 @@ public void InstancePlayer(Vector3 position, PlayerData playerData)

public void OnEvent(EventData photonEvent)
{
Debug.Log("On event");
if (photonEvent.Code == CustomManualInstantiationEventCode)
{
Debug.Log("Custom instantiation");
object[] data = (object[]) photonEvent.CustomData;

Player.Player player = Instantiate(playerPrefab, (Vector3) data[0], (Quaternion) data[1]);
Player.Player player = Instantiate(playerPrefab, (Vector3) data[0], playerPrefab.transform.rotation);
PhotonView photonView = player.GetComponent<PhotonView>();
photonView.ViewID = (int) data[2];
PlayerData playerData = (PlayerData) PlayerData.Deserialize((byte[]) data[3]);
photonView.ViewID = (int) data[1];
PlayerData playerData = (PlayerData) PlayerData.Deserialize((byte[]) data[2]);

player.SetMaterials(playerData.color1, playerData.color2, playerData.playerMeshes, instantiationSettings);
_playersInGame.Add(player);
player.SetMaterialsAndMeshes(playerData.color1, playerData.color2, playerData.playerMeshes, instantiationSettings);
StartCoroutine(AddAPlayer(player));

if(PlayerGeneralEvents.onPlayerInstantiate != null)
PlayerGeneralEvents.onPlayerInstantiate.Invoke(player);
}
}

private IEnumerator AddAPlayer(Player.Player player)
{
if(!PhotonNetwork.IsMasterClient)
player.transform.GetChild(0).LookAt(player.transform.position+Vector3.right);

_playersInGame.Add(player);

if (_playersInGame.Count >= PhotonNetwork.CurrentRoom.PlayerCount)
{
Time.timeScale = 1;
yield return new WaitForSeconds(3);
_alivePlayers = _playersInGame.Count;
foreach (var playerInGame in _playersInGame)
playerInGame.ChangeState(new Grounded());
}
}

private void LoadPlayers()
{
_playerData = GameController.gameController.playerData[0];
/*alivePlayers = playersDatas.Length;*/
InstantiatePlayers();
InstancePlayer(transform.position, _playerData);
}

private void CheckPlayerClassification()
Expand Down
1 change: 1 addition & 0 deletions Assets/Script/EstadosPlayer/Grounded.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ void UnsubscribeOnInputEvents()
if (playerInput == null)
playerInput = player.playerInput;


playerInput.currentActionMap.FindAction("Jump").started -= Jump;
playerInput.currentActionMap.Disable();
}
Expand Down
25 changes: 25 additions & 0 deletions Assets/Script/EstadosPlayer/Stopped.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using UnityEngine;

namespace ExtremeSnowboarding.Script.EstadosPlayer
{
public class Stopped : PlayerState
{
private Rigidbody _rb;
public override void StateStart(Player.Player player)
{
base.StateStart(player);
_rb = player.GetComponent<Rigidbody>();
_rb.useGravity = true;
}

public override void StateEnd()
{

}

public override void StateUpdate()
{

}
}
}
3 changes: 3 additions & 0 deletions Assets/Script/EstadosPlayer/Stopped.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions Assets/Script/Player/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private set

public Vector3 groundedVelocity { get; set; }

PlayerState playerState = new Grounded();
PlayerState playerState = new Stopped();

private Player[] playerSpectating = new Player[4];
private Vector3 startPoint;
Expand Down Expand Up @@ -152,9 +152,15 @@ public PlayerFeedbacksGroup GetPlayerFeedbackList()
{
return playerFeedbacksList;
}


public void SetMaterials(Color firstColor, Color secondColor, string[] playerMeshes, MultiplayerInstantiationSettings settings)

/// <summary>
/// Set the player Material and Meshes
/// </summary>
/// <param name="firstColor">The primary color</param>
/// <param name="secondColor">The secondary color</param>
/// <param name="playerMeshes">The choosed meshes names</param>
/// <param name="settings">The Instantiation settings</param>
public void SetMaterialsAndMeshes(Color firstColor, Color secondColor, string[] playerMeshes, MultiplayerInstantiationSettings settings)
{
Debug.Log("Player meshes names: "+playerMeshes[0]+" - "+playerMeshes[1]+" - "+playerMeshes[2]);
Material material = new Material(settings.playerShader);
Expand Down
9 changes: 6 additions & 3 deletions ProjectSettings/DynamicsManager.asset
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
--- !u!55 &1
PhysicsManager:
m_ObjectHideFlags: 0
serializedVersion: 11
serializedVersion: 13
m_Gravity: {x: 0, y: -9.81, z: 0}
m_DefaultMaterial: {fileID: 0}
m_BounceThreshold: 2
m_DefaultMaxDepenetrationVelocity: 10
m_SleepThreshold: 0.005
m_DefaultContactOffset: 0.01
m_DefaultSolverIterations: 6
Expand All @@ -17,11 +18,12 @@ PhysicsManager:
m_ClothInterCollisionDistance: 0
m_ClothInterCollisionStiffness: 0
m_ContactsGeneration: 1
m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
m_LayerCollisionMatrix: 59f8ffff50f8ffff50f8ffff51f8ffff5ff8ffff40f8ffff7ff8ffff00f8ffff00f8ffff00f8ffff00f8ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
m_AutoSimulation: 1
m_AutoSyncTransforms: 0
m_ReuseCollisionCallbacks: 1
m_ClothInterCollisionSettingsToggle: 0
m_ClothGravity: {x: 0, y: -9.81, z: 0}
m_ContactPairsMode: 0
m_BroadphaseType: 0
m_WorldBounds:
Expand All @@ -31,4 +33,5 @@ PhysicsManager:
m_FrictionType: 0
m_EnableEnhancedDeterminism: 0
m_EnableUnifiedHeightmaps: 1
m_DefaultMaxAngluarSpeed: 7
m_SolverType: 0
m_DefaultMaxAngularSpeed: 7
1 change: 1 addition & 0 deletions ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ PlayerSettings:
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
metroInputSource: 0
wsaTransparentSwapchain: 0
m_HolographicPauseOnTrackingLoss: 1
Expand Down

0 comments on commit 68f9404

Please sign in to comment.