Browse Source

fixed client inventory removing items + time is sent over by server

master
JoshuaReason 5 years ago
parent
commit
e48e419c29
6 changed files with 139 additions and 49 deletions
  1. +2
    -2
      Assets/Data/GameModes/ColorCollide.asset
  2. +47
    -46
      Assets/Scenes/Client Scenes/ClientScene.unity
  3. +13
    -0
      Assets/Scripts/GameMode/GameMode.cs
  4. +3
    -0
      Assets/Scripts/Managers/GameManager.cs
  5. +51
    -0
      Assets/Scripts/Networking/Core/Protocols/LogicProtocols.cs
  6. +23
    -1
      Assets/Scripts/UI/NetworkedUIManager.cs

+ 2
- 2
Assets/Data/GameModes/ColorCollide.asset View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:e9ac3ad2b1266807e868377fa1c148c766f34904a0d06c0fcb93b523bb4e8298
size 532
oid sha256:25df2a78a63b91d5d6e0cd99283ff0e03bf82505fe6c3a31a840a43725e367e4
size 582

+ 47
- 46
Assets/Scenes/Client Scenes/ClientScene.unity View File

@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1 m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0} m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0} m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1}
m_IndirectSpecularColor: {r: 0.44657868, g: 0.49641263, b: 0.57481706, a: 1}
m_UseRadianceAmbientProbe: 0 m_UseRadianceAmbientProbe: 0
--- !u!157 &3 --- !u!157 &3
LightmapSettings: LightmapSettings:
@ -221,6 +221,7 @@ MonoBehaviour:
maxLength: 6 maxLength: 6
reader: reader:
LogicChain: [] LogicChain: []
readerQueue: []
--- !u!114 &1324620582 stripped --- !u!114 &1324620582 stripped
MonoBehaviour: MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 5195354183101525349, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, m_CorrespondingSourceObject: {fileID: 5195354183101525349, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f,
@ -683,41 +684,51 @@ PrefabInstance:
m_Modification: m_Modification:
m_TransformParent: {fileID: 0} m_TransformParent: {fileID: 0}
m_Modifications: m_Modifications:
- target: {fileID: 2584547907285081931, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f,
- target: {fileID: 5195354182462625300, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f,
type: 3} type: 3}
propertyPath: m_isInputParsingRequired
value: 1
propertyPath: m_Name
value: Player Canvas
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4132265620032504676, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f,
type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target
value:
objectReference: {fileID: 1324620581}
- target: {fileID: 4132265620032504676, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f,
- target: {fileID: 5195354182462625300, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f,
type: 3} type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
value: OnClick_Return
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4080157917815310858, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, - target: {fileID: 4080157917815310858, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f,
type: 3} type: 3}
propertyPath: m_IsActive propertyPath: m_IsActive
value: 0 value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 5195354182462625300, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f,
type: 3}
propertyPath: m_Name
value: Player Canvas
objectReference: {fileID: 0}
- target: {fileID: 5195354182462625300, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f,
- target: {fileID: 5195354183101525344, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f,
type: 3} type: 3}
propertyPath: m_IsActive propertyPath: m_IsActive
value: 1 value: 1
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 5195354183101525344, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f,
- target: {fileID: 5195354183101525349, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f,
type: 3} type: 3}
propertyPath: m_IsActive
propertyPath: m_Color.r
value: 0.8862745
objectReference: {fileID: 0}
- target: {fileID: 5195354183101525349, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f,
type: 3}
propertyPath: m_Color.g
value: 0.884576
objectReference: {fileID: 0}
- target: {fileID: 5195354183101525349, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f,
type: 3}
propertyPath: m_Color.b
value: 0.88235295
objectReference: {fileID: 0}
- target: {fileID: 5195354183101525349, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f,
type: 3}
propertyPath: m_Color.a
value: 1 value: 1
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 5195354183101525349, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f,
type: 3}
propertyPath: m_Sprite
value:
objectReference: {fileID: 10911, guid: 0000000000000000f000000000000000, type: 0}
- target: {fileID: 5195354181806561359, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, - target: {fileID: 5195354181806561359, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f,
type: 3} type: 3}
propertyPath: m_AnchoredPosition.y propertyPath: m_AnchoredPosition.y
@ -733,6 +744,21 @@ PrefabInstance:
propertyPath: m_AnchoredPosition.x propertyPath: m_AnchoredPosition.x
value: -0.000015290107 value: -0.000015290107
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 2584547907285081931, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f,
type: 3}
propertyPath: m_isInputParsingRequired
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4132265620032504676, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f,
type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target
value:
objectReference: {fileID: 1324620581}
- target: {fileID: 4132265620032504676, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f,
type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
value: OnClick_Return
objectReference: {fileID: 0}
- target: {fileID: 5195354182462625304, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, - target: {fileID: 5195354182462625304, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f,
type: 3} type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
@ -857,7 +883,7 @@ PrefabInstance:
type: 3} type: 3}
propertyPath: inventory propertyPath: inventory
value: value:
objectReference: {fileID: 11400000, guid: eea1505cebc20b64b8c421ba71e10781,
objectReference: {fileID: 11400000, guid: 9f2bac6895147d444858493b9609d026,
type: 2} type: 2}
- target: {fileID: 2665231842396078511, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, - target: {fileID: 2665231842396078511, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f,
type: 3} type: 3}
@ -979,31 +1005,6 @@ PrefabInstance:
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
value: OnClick_Toggle value: OnClick_Toggle
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 5195354183101525349, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f,
type: 3}
propertyPath: m_Color.r
value: 0.8862745
objectReference: {fileID: 0}
- target: {fileID: 5195354183101525349, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f,
type: 3}
propertyPath: m_Color.g
value: 0.884576
objectReference: {fileID: 0}
- target: {fileID: 5195354183101525349, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f,
type: 3}
propertyPath: m_Color.b
value: 0.88235295
objectReference: {fileID: 0}
- target: {fileID: 5195354183101525349, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f,
type: 3}
propertyPath: m_Color.a
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5195354183101525349, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f,
type: 3}
propertyPath: m_Sprite
value:
objectReference: {fileID: 10911, guid: 0000000000000000f000000000000000, type: 0}
- target: {fileID: 5195354183101525346, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, - target: {fileID: 5195354183101525346, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f,
type: 3} type: 3}
propertyPath: m_AspectRatio propertyPath: m_AspectRatio

+ 13
- 0
Assets/Scripts/GameMode/GameMode.cs View File

@ -11,12 +11,17 @@ public abstract class GameMode : ScriptableObject
[Tooltip("Scene to load which contains Gamemode UI")] [Tooltip("Scene to load which contains Gamemode UI")]
private string GameModeScene; private string GameModeScene;
[SerializeField]
[Tooltip("Round Times are acessed from the top down")]
private List<float> RoundTimes;
public Action GameStartEvent; public Action GameStartEvent;
public Action RoundStartEvent; public Action RoundStartEvent;
public Action AllPlayersMovedEvent; public Action AllPlayersMovedEvent;
public Action RoundEndEvent; public Action RoundEndEvent;
public Action OnGameOverEvent; public Action OnGameOverEvent;
protected abstract void OnGameStart(PlayerData[] allPlayers); protected abstract void OnGameStart(PlayerData[] allPlayers);
/// <summary> /// <summary>
@ -44,6 +49,14 @@ public abstract class GameMode : ScriptableObject
protected abstract void OnGameOver(PlayerData[] allPlayers); protected abstract void OnGameOver(PlayerData[] allPlayers);
public float GetRoundTime()
{
float retVal = RoundTimes[0];
if (RoundTimes.Count > 1)
RoundTimes.RemoveAt(0);
return RoundTimes[0];
}
public void GameStart(PlayerData[] allPlayers) public void GameStart(PlayerData[] allPlayers)
{ {

+ 3
- 0
Assets/Scripts/Managers/GameManager.cs View File

@ -95,6 +95,9 @@ public class GameManager : MonoBehaviour
private void StartRound() private void StartRound()
{ {
gamemode.RoundStart(playerArray.ToArray()); gamemode.RoundStart(playerArray.ToArray());
LogicProtocols.FloatMsg RoundTime = new LogicProtocols.FloatMsg( gamemode.GetRoundTime());
playerArray.ForEach(p => p.client.conn.Send(LogicProtocols.SendRoundTime, RoundTime));
} }
private IEnumerator RoundRoutine() private IEnumerator RoundRoutine()

+ 51
- 0
Assets/Scripts/Networking/Core/Protocols/LogicProtocols.cs View File

@ -10,6 +10,8 @@ namespace Networking
{ {
public const short SendLogicList = 200; public const short SendLogicList = 200;
public const short SendInventory = 201; public const short SendInventory = 201;
public const short SendRoundTime = 202;
public const short SendNotification = 203;
public class LogicMsg : MessageBase public class LogicMsg : MessageBase
@ -103,5 +105,54 @@ namespace Networking
} }
public class FloatMsg : MessageBase
{
public float Float;
public FloatMsg() { }
public FloatMsg(float Float)
{
this.Float = Float;
}
public override void Serialize(NetworkWriter writer)
{
base.Serialize(writer);
writer.Write(Float);
}
public override void Deserialize(NetworkReader reader)
{
base.Deserialize(reader);
Float = reader.ReadSingle();
}
}
public class StringMsg : MessageBase
{
public float String;
public StringMsg() { }
public StringMsg(float String)
{
this.String = String;
}
public override void Serialize(NetworkWriter writer)
{
base.Serialize(writer);
writer.Write(String);
}
public override void Deserialize(NetworkReader reader)
{
base.Deserialize(reader);
String = reader.ReadSingle();
}
}
} }
} }

+ 23
- 1
Assets/Scripts/UI/NetworkedUIManager.cs View File

@ -35,6 +35,18 @@ public class NetworkedUIManager : PlayerUIManager
OnClick_Show(); OnClick_Show();
} }
private void OnEnable()
{
if (Client.isConnected)
Client.client.RegisterHandler(LogicProtocols.SendRoundTime, UpdateTime);
}
private void OnDisable()
{
if (Client.isConnected)
Client.client.UnregisterHandler(LogicProtocols.SendRoundTime);
}
private void Update() private void Update()
{ {
if (!isTimePaused) if (!isTimePaused)
@ -65,5 +77,15 @@ public class NetworkedUIManager : PlayerUIManager
else else
TimeText.color = Color.black; TimeText.color = Color.black;
} }
public void UpdateTime(NetworkMessage msg)
{
LogicProtocols.FloatMsg floatMsg;
if (!msg.TryRead(out floatMsg))
return;
TotalTime = floatMsg.Float;
}
} }

Loading…
Cancel
Save