spys and npcs change colors again
This commit is contained in:
parent
f284cf88eb
commit
e518a5d87f
10 changed files with 120 additions and 22 deletions
|
@ -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}
|
||||
|
|
|
@ -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
|
||||
|
|
17
Project Undercover/Assets/Resources/NpcColors.asset
Normal file
17
Project Undercover/Assets/Resources/NpcColors.asset
Normal file
|
@ -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}
|
9
Project Undercover/Assets/Resources/NpcColors.asset.meta
Normal file
9
Project Undercover/Assets/Resources/NpcColors.asset.meta
Normal file
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0ca93fb1ceb40684f8b400eb4d65bffe
|
||||
timeCreated: 1507940030
|
||||
licenseType: Free
|
||||
NativeFormatImporter:
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -66,4 +66,5 @@ MonoBehaviour:
|
|||
- SetInteractorRPC
|
||||
- SetIsInteractingRPC
|
||||
- SetSelectedInteractionRPC
|
||||
- SetCharacterColorRPC
|
||||
DisableAutoOpenWizard: 1
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -17,7 +17,7 @@ public class PromptInteractionsAction : Action {
|
|||
}
|
||||
else
|
||||
{
|
||||
//InteractionPanelController.Hide();
|
||||
InteractionPanelController.ActivePanel.Hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ public class StateController : SelectableObject
|
|||
private static float _startInteractionProgressLimit = 0.3f;
|
||||
private static float _endInteractionProgressLimit = 0.8f;
|
||||
|
||||
|
||||
void Awake()
|
||||
{
|
||||
navMeshAgent = GetComponent<NavMeshAgent>();
|
||||
|
@ -32,6 +31,12 @@ public class StateController : SelectableObject
|
|||
}
|
||||
animator = GetComponent<Animator>();
|
||||
characterAnimator = GetComponent<CharacterAnimator>();
|
||||
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<Renderer>().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
|
||||
}
|
||||
|
|
44
Project Undercover/Assets/Scripts/Misc/NPCColors.cs
Normal file
44
Project Undercover/Assets/Scripts/Misc/NPCColors.cs
Normal file
|
@ -0,0 +1,44 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[CreateAssetMenu(menuName = "Colors/NpcColors")]
|
||||
public static class NpcColors {
|
||||
|
||||
private static List<int> 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<int>();
|
||||
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;
|
||||
}
|
||||
}
|
12
Project Undercover/Assets/Scripts/Misc/NPCColors.cs.meta
Normal file
12
Project Undercover/Assets/Scripts/Misc/NPCColors.cs.meta
Normal file
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 54ea76467b6b0f244a932a0ee6e08186
|
||||
timeCreated: 1507937059
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in a new issue