Browse Source

Working Credits

develop
Joshua Reason 3 years ago
parent
commit
9bdf434a10
13 changed files with 319 additions and 7 deletions
  1. BIN
      Assets/Scenes/CreditScreen.unity
  2. +7
    -0
      Assets/Scenes/CreditScreen.unity.meta
  3. BIN
      Assets/Scenes/PlayerJoinScene.unity
  4. +3
    -0
      Assets/Scripts/Player Scripts/PlayerData.cs
  5. +4
    -0
      Assets/Scripts/Player Scripts/PlayerList.cs
  6. +8
    -0
      Assets/Scripts/UI/CreditScreen.meta
  7. +133
    -0
      Assets/Scripts/UI/CreditScreen/CreditUIController.cs
  8. +11
    -0
      Assets/Scripts/UI/CreditScreen/CreditUIController.cs.meta
  9. +9
    -0
      Assets/Scripts/UI/StartScreen/PlayerJoinIcon.cs
  10. +4
    -3
      Assets/TextMesh Pro/Resources/Fonts & Materials/LiberationSans SDF - Outline.mat
  11. +125
    -0
      Assets/World Assets/Materials/Score_Text.mat
  12. +8
    -0
      Assets/World Assets/Materials/Score_Text.mat.meta
  13. BIN
      ProjectSettings/EditorBuildSettings.asset

BIN
Assets/Scenes/CreditScreen.unity (Stored with Git LFS) View File

size 43062

+ 7
- 0
Assets/Scenes/CreditScreen.unity.meta View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: a85bd4296d5a1684fa42dc31c88b08d4
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Scenes/PlayerJoinScene.unity (Stored with Git LFS) View File

size 40672

+ 3
- 0
Assets/Scripts/Player Scripts/PlayerData.cs View File

@ -10,6 +10,9 @@ public class PlayerData : ScriptableObject
public uint ID { get; private set; }
public Color Color { get; private set; }
public int Score;
public UnityEngine.InputSystem.PlayerInput Input { get; private set; }
public static PlayerData Initialise(uint ID, Color color, UnityEngine.InputSystem.PlayerInput input)

+ 4
- 0
Assets/Scripts/Player Scripts/PlayerList.cs View File

@ -30,10 +30,14 @@ public class PlayerList : ScriptableObject
PlayerData data = PlayerData.Initialise(ID, color, input);
data.Score = Random.Range(2, 10);
Players.Add(input, data);
OnPlayerJoin?.Invoke(this,data);
return data;
}

+ 8
- 0
Assets/Scripts/UI/CreditScreen.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f0d43d896ffeafd41a94c6952b8193e6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

+ 133
- 0
Assets/Scripts/UI/CreditScreen/CreditUIController.cs View File

@ -0,0 +1,133 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class CreditUIController : MonoBehaviour
{
[SerializeField]
private PlayerList m_allPlayers;
[SerializeField]
private GameObject m_playerPrefab;
[SerializeField]
private RectTransform winnerPos;
[SerializeField]
private RectTransform losePos;
[SerializeField]
private float waitTime = 1;
[SerializeField]
private float creditDisplayTime = 1;
[SerializeField]
public List<CreditReferences> m_CreditReferences;
[SerializeField]
public List<CreditData> m_Credits;
private int Count;
private void Start()
{
StartCoroutine(DisplaySlow(waitTime));
StartCoroutine(DisplayCredits(creditDisplayTime));
}
[ContextMenu("display All players")]
private void DisplayAllPlayers()
{
int max = m_allPlayers.AllPlayers.Select(p => p.Score).Max();
int min = m_allPlayers.AllPlayers.Select(p => p.Score).Min();
foreach (var data in m_allPlayers.AllPlayers)
{
DisplayScore(data, max, min);
}
}
private IEnumerator DisplaySlow(float timebetween = 1)
{
int max = m_allPlayers.AllPlayers.Select(p => p.Score).Max();
int min = m_allPlayers.AllPlayers.Select(p => p.Score).Min();
foreach (var data in m_allPlayers.AllPlayers.OrderBy(p => p.Score))
{
yield return new WaitForSeconds(timebetween);
DisplayScore(data, max, min);
}
}
private IEnumerator DisplayCredits(float displayTime)
{
float totalTime = displayTime / m_CreditReferences.Count;
while (true)
{
CreditReferences reference = m_CreditReferences[Count%m_CreditReferences.Count];
CreditData data = m_Credits[Count % m_Credits.Count];
Count++;
reference.Title.text = data.Title;
reference.Credit.text = data.Credit;
yield return new WaitForSeconds(totalTime);
}
}
private void DisplayScore(PlayerData player, int maxScore, int minScore)
{
player.Input.SwitchCurrentActionMap("JoinMenu");
float ratio = 0.5f;
if (maxScore != minScore)
ratio = (float)(player.Score - minScore) / (maxScore - minScore);
Vector3 pos = Vector3.Lerp(losePos.position, winnerPos.position, ratio);
pos.x = Random.Range((Screen.width / 4f), Screen.width);
GameObject newPlayer = Instantiate(m_playerPrefab);
newPlayer.transform.parent = (m_playerPrefab.transform.parent);
newPlayer.transform.position = pos;
newPlayer.transform.Rotate(Vector3.forward, Random.Range(-20.0f, 20.0f));
if (Random.Range(0, 2) > 0)
{
newPlayer.transform.localScale.Scale(new Vector3(-1, 1, 1));
newPlayer.GetComponentInChildren<TMPro.TextMeshProUGUI>().transform.localScale.Scale(new Vector3(-1, 1, 1));
}
newPlayer.GetComponent<PlayerJoinIcon>().Initialise(player);
newPlayer.GetComponentInChildren<TMPro.TextMeshProUGUI>().text = player.Score.ToString();
newPlayer.SetActive(true);
}
[System.Serializable]
public struct CreditReferences
{
public TMPro.TextMeshProUGUI Title;
public TMPro.TextMeshProUGUI Credit;
}
[System.Serializable]
public struct CreditData
{
public string Title;
public string Credit;
}
}

+ 11
- 0
Assets/Scripts/UI/CreditScreen/CreditUIController.cs.meta View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bc723bcaa734e8646a99f2415e540ff0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

+ 9
- 0
Assets/Scripts/UI/StartScreen/PlayerJoinIcon.cs View File

@ -27,6 +27,15 @@ public class PlayerJoinIcon : MonoBehaviour
}
private void OnDisable()
{
if (m_data != null)
{
m_data.Input.currentActionMap.FindAction("Ping").started -= OnPlayerPing;
m_data.Input.currentActionMap.FindAction("Ping").canceled -= OnPlayerPing;
}
}
public void Initialise(PlayerData data)
{
Debug.Log("Initialised new Player");

+ 4
- 3
Assets/TextMesh Pro/Resources/Fonts & Materials/LiberationSans SDF - Outline.mat View File

@ -32,8 +32,7 @@ Material:
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 28684132378477856, guid: 8f586378b4e144a9851e7b34d9b748ee,
type: 2}
m_Texture: {fileID: 28684132378477856, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OutlineTex:
@ -50,6 +49,7 @@ Material:
- _BumpFace: 0
- _BumpOutline: 0
- _ColorMask: 15
- _CullMode: 0
- _Diffuse: 0.5
- _FaceDilate: 0.1
- _FaceUVSpeedX: 0
@ -65,7 +65,7 @@ Material:
- _OutlineSoftness: 0
- _OutlineUVSpeedX: 0
- _OutlineUVSpeedY: 0
- _OutlineWidth: 0.1
- _OutlineWidth: 0.343
- _PerspectiveFilter: 0.875
- _Reflectivity: 10
- _ScaleRatioA: 0.9
@ -102,3 +102,4 @@ Material:
- _ReflectOutlineColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecularColor: {r: 1, g: 1, b: 1, a: 1}
- _UnderlayColor: {r: 0, g: 0, b: 0, a: 0.5}
m_BuildTextureStacks: []

+ 125
- 0
Assets/World Assets/Materials/Score_Text.mat View File

@ -0,0 +1,125 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Score_Text
m_Shader: {fileID: 4800000, guid: fe393ace9b354375a9cb14cdbbc28be4, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BaseMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _AlphaClip: 0
- _Blend: 0
- _BumpScale: 1
- _ColorMask: 15
- _Cull: 2
- _CullMode: 0
- _Cutoff: 0.5
- _DstBlend: 0
- _EnvironmentReflections: 1
- _FaceDilate: 0
- _GlossMapScale: 0
- _Glossiness: 0
- _GlossyReflections: 0
- _GradientScale: 5
- _MaskSoftnessX: 0
- _MaskSoftnessY: 0
- _Metallic: 0
- _OcclusionStrength: 1
- _OutlineSoftness: 0
- _OutlineWidth: 0
- _PerspectiveFilter: 0.875
- _QueueOffset: 0
- _ReceiveShadows: 1
- _ScaleRatioA: 1
- _ScaleRatioB: 1
- _ScaleRatioC: 1
- _ScaleX: 1
- _ScaleY: 1
- _ShaderFlags: 0
- _Sharpness: 0
- _Smoothness: 0.5
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _Stencil: 0
- _StencilComp: 8
- _StencilOp: 0
- _StencilReadMask: 255
- _StencilWriteMask: 255
- _Surface: 0
- _TextureHeight: 512
- _TextureWidth: 512
- _UnderlayDilate: 0
- _UnderlayOffsetX: 0
- _UnderlayOffsetY: 0
- _UnderlaySoftness: 0
- _VertexOffsetX: 0
- _VertexOffsetY: 0
- _WeightBold: 0.5
- _WeightNormal: 0
- _WorkflowMode: 1
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
- _ClipRect: {r: -32767, g: -32767, b: 32767, a: 32767}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _FaceColor: {r: 1, g: 1, b: 1, a: 1}
- _OutlineColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
- _UnderlayColor: {r: 0, g: 0, b: 0, a: 0.5}
m_BuildTextureStacks: []
--- !u!114 &3715928537810302973
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 2

+ 8
- 0
Assets/World Assets/Materials/Score_Text.mat.meta View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0a67ea2466379b44f913e57a770b8d35
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

BIN
ProjectSettings/EditorBuildSettings.asset (Stored with Git LFS) View File

size 670

Loading…
Cancel
Save