diff --git a/Project Undercover/Assets/Models/YBot/Materials/Alpha_Body_MAT.mat b/Project Undercover/Assets/Models/YBot/Materials/Alpha_Body_MAT.mat index 24249a1..8530c5d 100644 --- a/Project Undercover/Assets/Models/YBot/Materials/Alpha_Body_MAT.mat +++ b/Project Undercover/Assets/Models/YBot/Materials/Alpha_Body_MAT.mat @@ -72,5 +72,5 @@ Material: - _UVSec: 0 - _ZWrite: 1 m_Colors: - - _Color: {r: 0.21323532, g: 0.8143629, b: 1, a: 1} + - _Color: {r: 0, g: 0, b: 1, a: 1} - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/Project Undercover/Assets/Resources/NPC.prefab b/Project Undercover/Assets/Resources/NPC.prefab index 2c2667a..8bc5b91 100644 --- a/Project Undercover/Assets/Resources/NPC.prefab +++ b/Project Undercover/Assets/Resources/NPC.prefab @@ -352,10 +352,10 @@ GameObject: - component: {fileID: 95559352611635020} - component: {fileID: 114052105454001458} - component: {fileID: 195641778051991382} - - component: {fileID: 114492707522239788} - component: {fileID: 114063469203119278} - component: {fileID: 136748321063637496} - component: {fileID: 114776369420944768} + - component: {fileID: 114492707522239788} m_Layer: 10 m_Name: NPC m_TagString: NPC @@ -2158,10 +2158,10 @@ MonoBehaviour: spyInteractions: - {fileID: 11400000, guid: 218e2ddac8223e349a855bdae23819ab, type: 2} currentState: {fileID: 11400000, guid: 78ec31c429ad5074bb50d001b1a49a77, type: 2} - remainState: {fileID: 0} navMeshAgent: {fileID: 0} animator: {fileID: 0} characterAnimator: {fileID: 0} + colorsObject: {fileID: 11400000, guid: 0ca93fb1ceb40684f8b400eb4d65bffe, type: 2} --- !u!114 &114776369420944768 MonoBehaviour: m_ObjectHideFlags: 1 diff --git a/Project Undercover/Assets/Resources/NpcColors.asset b/Project Undercover/Assets/Resources/NpcColors.asset new file mode 100644 index 0000000..af5a52f --- /dev/null +++ b/Project Undercover/Assets/Resources/NpcColors.asset @@ -0,0 +1,17 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 0} + m_Name: NpcColors + m_EditorClassIdentifier: Assembly-CSharp::NpcColors + colors: + - {r: 1, g: 0, b: 0, a: 0} + - {r: 0, g: 1, b: 0, a: 0} + - {r: 0, g: 0, b: 1, a: 0} diff --git a/Project Undercover/Assets/Resources/NpcColors.asset.meta b/Project Undercover/Assets/Resources/NpcColors.asset.meta new file mode 100644 index 0000000..9db0b35 --- /dev/null +++ b/Project Undercover/Assets/Resources/NpcColors.asset.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 0ca93fb1ceb40684f8b400eb4d65bffe +timeCreated: 1507940030 +licenseType: Free +NativeFormatImporter: + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Project Undercover/Assets/Resources/PhotonServerSettings.asset b/Project Undercover/Assets/Resources/PhotonServerSettings.asset index 20e982f..b3e2265 100644 --- a/Project Undercover/Assets/Resources/PhotonServerSettings.asset +++ b/Project Undercover/Assets/Resources/PhotonServerSettings.asset @@ -66,4 +66,5 @@ MonoBehaviour: - SetInteractorRPC - SetIsInteractingRPC - SetSelectedInteractionRPC + - SetCharacterColorRPC DisableAutoOpenWizard: 1 diff --git a/Project Undercover/Assets/Resources/Spy.prefab b/Project Undercover/Assets/Resources/Spy.prefab index f8f4adc..bea6007 100644 --- a/Project Undercover/Assets/Resources/Spy.prefab +++ b/Project Undercover/Assets/Resources/Spy.prefab @@ -2158,7 +2158,6 @@ MonoBehaviour: spyInteractions: - {fileID: 11400000, guid: 218e2ddac8223e349a855bdae23819ab, type: 2} currentState: {fileID: 11400000, guid: 1c694dfd46dd4e44b94f7853724fa1c0, type: 2} - remainState: {fileID: 0} navMeshAgent: {fileID: 0} animator: {fileID: 0} characterAnimator: {fileID: 0} diff --git a/Project Undercover/Assets/Scripts/CharacterStateMachine/ActionScripts/PromptInteractionsAction.cs b/Project Undercover/Assets/Scripts/CharacterStateMachine/ActionScripts/PromptInteractionsAction.cs index 55da369..b0d48db 100644 --- a/Project Undercover/Assets/Scripts/CharacterStateMachine/ActionScripts/PromptInteractionsAction.cs +++ b/Project Undercover/Assets/Scripts/CharacterStateMachine/ActionScripts/PromptInteractionsAction.cs @@ -17,7 +17,7 @@ public class PromptInteractionsAction : Action { } else { - //InteractionPanelController.Hide(); + InteractionPanelController.ActivePanel.Hide(); } } diff --git a/Project Undercover/Assets/Scripts/CharacterStateMachine/StateController.cs b/Project Undercover/Assets/Scripts/CharacterStateMachine/StateController.cs index 4890222..0182aa4 100644 --- a/Project Undercover/Assets/Scripts/CharacterStateMachine/StateController.cs +++ b/Project Undercover/Assets/Scripts/CharacterStateMachine/StateController.cs @@ -21,7 +21,6 @@ public class StateController : SelectableObject private static float _startInteractionProgressLimit = 0.3f; private static float _endInteractionProgressLimit = 0.8f; - void Awake() { navMeshAgent = GetComponent(); @@ -32,6 +31,12 @@ public class StateController : SelectableObject } animator = GetComponent(); characterAnimator = GetComponent(); + if (PhotonNetwork.isMasterClient) + { + Color color = NpcColors.GetAvailableColor(); + Vector3 colorAsVector = new Vector3(color.r, color.g, color.b); + photonView.RPC("SetCharacterColorRPC", PhotonTargets.All, colorAsVector); + } } protected override void Start() @@ -179,20 +184,7 @@ public class StateController : SelectableObject } } - [PunRPC] - private void SetSelectedInteractionRPC(int hash) - { - Interaction[] foundInteractions = (Interaction[])Resources.FindObjectsOfTypeAll(typeof(Interaction)); - foreach (var interaction in foundInteractions) - { - if (interaction.CompareHash(hash)) - { - _selectedInteraction = interaction; - return; - } - } - _selectedInteraction = null; - } + public void StartRoaming() { @@ -275,11 +267,11 @@ public class StateController : SelectableObject if (progress < _startInteractionProgressLimit) { Quaternion adjustedRotation = facingRotation * Quaternion.Euler(0, initialRotation, 0); - transform.rotation = Quaternion.Slerp(transform.rotation, adjustedRotation, Time.deltaTime * 10.0f); + transform.rotation = Quaternion.Slerp(transform.rotation, adjustedRotation, progress * (1.0f / _startInteractionProgressLimit)); } else { - transform.rotation = Quaternion.Slerp(transform.rotation, facingRotation, Time.deltaTime * 10.0f); + transform.rotation = Quaternion.Slerp(transform.rotation, facingRotation, (progress - _endInteractionProgressLimit) * (1.0f / (1 - _endInteractionProgressLimit))); } } @@ -295,4 +287,28 @@ public class StateController : SelectableObject { return (SelectedObject.transform.position - transform.position).magnitude < INTERACT_RANGE; } + + #region RPC definitions + [PunRPC] + private void SetCharacterColorRPC(Vector3 color) + { + Material coloredMat = transform.Find("Alpha_Surface").GetComponent().material; + coloredMat.color = new Color(color.x, color.y, color.z); + } + + [PunRPC] + private void SetSelectedInteractionRPC(int hash) + { + Interaction[] foundInteractions = (Interaction[])Resources.FindObjectsOfTypeAll(typeof(Interaction)); + foreach (var interaction in foundInteractions) + { + if (interaction.CompareHash(hash)) + { + _selectedInteraction = interaction; + return; + } + } + _selectedInteraction = null; + } + #endregion } diff --git a/Project Undercover/Assets/Scripts/Misc/NPCColors.cs b/Project Undercover/Assets/Scripts/Misc/NPCColors.cs new file mode 100644 index 0000000..a44b138 --- /dev/null +++ b/Project Undercover/Assets/Scripts/Misc/NPCColors.cs @@ -0,0 +1,44 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +[CreateAssetMenu(menuName = "Colors/NpcColors")] +public static class NpcColors { + + private static List remainingIndices; + private static Color[] colors; + + public static Color GetAvailableColor() + { + if (colors == null) + { + colors = new Color[12]; + colors[0] = new Color(1, 0, 0); + colors[1] = new Color(0, 1, 0); + colors[2] = new Color(1, 0, 1); + colors[3] = new Color(1, 1, 0); + colors[4] = new Color(0, 1, 1); + colors[5] = new Color(1, 0, 1); + colors[6] = new Color(1, 0.5f, 0); + colors[7] = new Color(1, 0, 0.5f); + colors[8] = new Color(0.5f, 1, 0); + colors[9] = new Color(0, 1, 0.5f); + colors[10] = new Color(0, 0.5f, 1); + colors[11] = new Color(0.5f, 0, 1); + colors[11] = new Color(0.8f, 0.8f, 0.8f); + colors[11] = new Color(0.25f, 0.25f, 0.25f); + } + if (remainingIndices == null || remainingIndices.Count == 0) + { + remainingIndices = new List(); + for (int i=0; i < colors.Length; i++) + { + remainingIndices.Add(i); + } + } + int randomIndex = Random.Range(0, remainingIndices.Count); + Color color = colors[remainingIndices[randomIndex]]; + remainingIndices.RemoveAt(randomIndex); + return color; + } +} diff --git a/Project Undercover/Assets/Scripts/Misc/NPCColors.cs.meta b/Project Undercover/Assets/Scripts/Misc/NPCColors.cs.meta new file mode 100644 index 0000000..ba11963 --- /dev/null +++ b/Project Undercover/Assets/Scripts/Misc/NPCColors.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 54ea76467b6b0f244a932a0ee6e08186 +timeCreated: 1507937059 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: