Browse Source

Have Score updating

Josh_Dev_branch
JoshuaReason 5 years ago
parent
commit
ffa4619081
12 changed files with 61 additions and 46 deletions
  1. +2
    -2
      Assets/Data/Inventory/BaseInventory.asset
  2. +2
    -2
      Assets/Data/Logic Blocks/Horse_Left.asset
  3. +2
    -2
      Assets/Data/Logic Blocks/Horse_Right.asset
  4. +18
    -1
      Assets/Scenes/Client Scenes/ClientScene.unity
  5. +1
    -1
      Assets/Scenes/TuteLevelTwo.unity
  6. +5
    -3
      Assets/Scripts/GameMode/GameMode.cs
  7. +5
    -29
      Assets/Scripts/Managers/GameManager.cs
  8. +10
    -1
      Assets/Scripts/Networking/Client/ClientObject.cs
  9. +1
    -0
      Assets/Scripts/Networking/Core/Protocols/LogicProtocols.cs
  10. +5
    -0
      Assets/Scripts/Networking/Server/ClientList.cs
  11. +6
    -5
      Assets/Scripts/UI/InventoryCatch.cs
  12. +4
    -0
      Assets/Scripts/UI/NetworkedUIManager.cs

+ 2
- 2
Assets/Data/Inventory/BaseInventory.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:9310fa0d8f14f0a8df3edf310504907081a4a345138aaa3ce16831b6f0a5c70a
size 1090
oid sha256:dc2df0d3b6567d4e6c80879edaa512a1b93ac778c0c4755d946260db33a5553a
size 1312

+ 2
- 2
Assets/Data/Logic Blocks/Horse_Left.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:ccb2e2bcc61f067df1b019e2c9c4c0887bf628056a41bdf1ed5241f2569f35ae
size 943
oid sha256:c689e7823398372bb409980d735f9ce532db12ffa527ff0b996e907cc0390745
size 868

+ 2
- 2
Assets/Data/Logic Blocks/Horse_Right.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:a8c8f259d738148b0d20f7ec320d76c998d1d9c4e7a1ea79f118fbb53ebe7d36
size 944
oid sha256:fd3e7a21a3b9ea59742941d1f65dec34c56480c36ac7742d03ce15768b696311
size 869

+ 18
- 1
Assets/Scenes/Client Scenes/ClientScene.unity View File

@ -685,7 +685,7 @@ PrefabInstance:
- target: {fileID: 5195354181806561359, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, - target: {fileID: 5195354181806561359, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f,
type: 3} type: 3}
propertyPath: m_AnchoredPosition.y propertyPath: m_AnchoredPosition.y
value: 0.00004012345
value: 0.000022883927
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 5195354181806561359, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, - target: {fileID: 5195354181806561359, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f,
type: 3} type: 3}
@ -832,6 +832,11 @@ PrefabInstance:
propertyPath: TimeText propertyPath: TimeText
value: value:
objectReference: {fileID: 1363815578} objectReference: {fileID: 1363815578}
- target: {fileID: 1240851277759925011, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f,
type: 3}
propertyPath: ScoreText
value:
objectReference: {fileID: 5195354181466942482}
- target: {fileID: 5195354183134146528, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, - target: {fileID: 5195354183134146528, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f,
type: 3} type: 3}
propertyPath: inventory propertyPath: inventory
@ -1122,6 +1127,18 @@ PrefabInstance:
- {fileID: 5195354182462625307, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, type: 3} - {fileID: 5195354182462625307, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, type: 3}
- {fileID: 5195354183157824118, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, type: 3} - {fileID: 5195354183157824118, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, type: 3}
m_SourcePrefab: {fileID: 100100000, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, type: 3} m_SourcePrefab: {fileID: 100100000, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, type: 3}
--- !u!114 &5195354181466942482 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 2665231841929910945, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f,
type: 3}
m_PrefabInstance: {fileID: 5195354181466942481}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &5195354181466942483 stripped --- !u!114 &5195354181466942483 stripped
MonoBehaviour: MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 1240851277759925011, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f, m_CorrespondingSourceObject: {fileID: 1240851277759925011, guid: 3fbc9b76d5c4f7348b60a029bc2ba63f,

+ 1
- 1
Assets/Scenes/TuteLevelTwo.unity View File

@ -506,7 +506,7 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 1704581577, guid: 47297317c21fe8a4c91caa79d00cc9a6, type: 3} - target: {fileID: 1704581577, guid: 47297317c21fe8a4c91caa79d00cc9a6, type: 3}
propertyPath: m_AnchoredPosition.y propertyPath: m_AnchoredPosition.y
value: 0.000017690185
value: -0.0000044650105
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 1704581577, guid: 47297317c21fe8a4c91caa79d00cc9a6, type: 3} - target: {fileID: 1704581577, guid: 47297317c21fe8a4c91caa79d00cc9a6, type: 3}
propertyPath: m_AnchoredPosition.x propertyPath: m_AnchoredPosition.x

+ 5
- 3
Assets/Scripts/GameMode/GameMode.cs View File

@ -81,13 +81,15 @@ public abstract class GameMode : ScriptableObject
public void FinishedMove(PlayerData[] allPlayers) public void FinishedMove(PlayerData[] allPlayers)
{ {
foreach (PlayerData player in allPlayers)
OnPlayerFinishedMove(player.character, player.client, player.character.CurrentBlock);
OnAllPlayersFinishedMove(allPlayers); OnAllPlayersFinishedMove(allPlayers);
AllPlayersMovedEvent?.Invoke(); AllPlayersMovedEvent?.Invoke();
} }
public void OnePlayerMoved(PlayerData player)
{
OnPlayerFinishedMove(player.character, player.client, player.character.CurrentBlock);
}
public void RoundEnd(PlayerData[] allPlayers) public void RoundEnd(PlayerData[] allPlayers)
{ {
OnRoundEnd(allPlayers); OnRoundEnd(allPlayers);

+ 5
- 29
Assets/Scripts/Managers/GameManager.cs View File

@ -96,8 +96,8 @@ public class GameManager : MonoBehaviour
{ {
gamemode.RoundStart(playerArray.ToArray()); gamemode.RoundStart(playerArray.ToArray());
LogicProtocols.FloatMsg RoundTime = new LogicProtocols.FloatMsg( gamemode.GetRoundTime()); LogicProtocols.FloatMsg RoundTime = new LogicProtocols.FloatMsg( gamemode.GetRoundTime());
bspawn.getPlayerScores();
bspawn.getPlayerLocations();
//bspawn.getPlayerScores();
//bspawn.getPlayerLocations();
playerArray.ForEach(p => p.client.conn.Send(LogicProtocols.SendRoundTime, RoundTime)); playerArray.ForEach(p => p.client.conn.Send(LogicProtocols.SendRoundTime, RoundTime));
} }
@ -105,33 +105,6 @@ public class GameManager : MonoBehaviour
{ {
playerArray.ForEach(p => p.recievedList = false); playerArray.ForEach(p => p.recievedList = false);
//while (playerArray.Any(p => !p.blockReader.Finished))
//{
// foreach (PlayerData player in playerArray)
// {
// if (!player.waiting)
// {
// if (player.blockReader.CurrentBlock != null && !player.blockReader.CurrentBlock.hasBeenRemoved)
// {
// //Debug.Log("used Block: " + player.blockReader.CurrentBlock.name);
// player.client.Inventory.Remove(player.blockReader.CurrentBlock);
// player.blockReader.CurrentBlock.hasBeenRemoved = true;
// }
// player.waiting = player.blockReader.Read(player.character, AnimationTime);
// }
// }
//
// yield return new WaitForSeconds(AnimationTime);
//
//
//
// if (playerArray.All(p => p.waiting))
// {
// playerArray.ForEach(p => p.waiting = false);
// Debug.Log("Finished one move");
// }
//}
Debug.Log("Doing Round Routine"); Debug.Log("Doing Round Routine");
while (playerArray.Any(p => !p.blockReader.Finished)) while (playerArray.Any(p => !p.blockReader.Finished))
@ -144,6 +117,8 @@ public class GameManager : MonoBehaviour
yield return new WaitUntil(() => playerArray.All(p => p.waiting)); yield return new WaitUntil(() => playerArray.All(p => p.waiting));
gamemode.FinishedMove(playerArray.ToArray()); gamemode.FinishedMove(playerArray.ToArray());
playerArray.ForEach(p => p.client.SendScore());
} }
if (gamemode.isGameOver(playerArray.ToArray())) if (gamemode.isGameOver(playerArray.ToArray()))
@ -208,6 +183,7 @@ public class GameManager : MonoBehaviour
Debug.Log("Waiting: " + waitTime); Debug.Log("Waiting: " + waitTime);
yield return new WaitForSeconds(waitTime); yield return new WaitForSeconds(waitTime);
gamemode.OnePlayerMoved(data);
} }
data.waiting = true; data.waiting = true;
} }

+ 10
- 1
Assets/Scripts/Networking/Client/ClientObject.cs View File

@ -74,6 +74,7 @@ namespace Networking.Client
client.RegisterHandler(LoginProtocols.SceneChange, RecieveSceneChange); client.RegisterHandler(LoginProtocols.SceneChange, RecieveSceneChange);
client.RegisterHandler(MsgType.Disconnect, OnDisconnect); client.RegisterHandler(MsgType.Disconnect, OnDisconnect);
client.RegisterHandler(LogicProtocols.SendRoundTime, UpdateTime); client.RegisterHandler(LogicProtocols.SendRoundTime, UpdateTime);
client.RegisterHandler(LogicProtocols.SendScore, UpdateScore);
} }
public void Stop() public void Stop()
@ -118,13 +119,21 @@ namespace Networking.Client
public void UpdateTime(NetworkMessage msg) public void UpdateTime(NetworkMessage msg)
{ {
Debug.Log("Recieveing time from server");
LogicProtocols.FloatMsg floatMsg; LogicProtocols.FloatMsg floatMsg;
if (!msg.TryRead(out floatMsg)) if (!msg.TryRead(out floatMsg))
return; return;
RoundTime = floatMsg.Float; RoundTime = floatMsg.Float;
} }
public void UpdateScore(NetworkMessage msg)
{
LogicProtocols.FloatMsg floatMsg;
if (!msg.TryRead(out floatMsg))
return;
RoundScore = floatMsg.Float;
}
} }
} }

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

@ -12,6 +12,7 @@ namespace Networking
public const short SendInventory = 201; public const short SendInventory = 201;
public const short SendRoundTime = 202; public const short SendRoundTime = 202;
public const short SendNotification = 203; public const short SendNotification = 203;
public const short SendScore = 204;
public class LogicMsg : MessageBase public class LogicMsg : MessageBase

+ 5
- 0
Assets/Scripts/Networking/Server/ClientList.cs View File

@ -199,6 +199,11 @@ namespace Networking.Server
conn.SendByChannel(LogicProtocols.SendInventory, new LogicProtocols.InventoryMsg(Inventory), TransportConfigure.ReliableFragmented); conn.SendByChannel(LogicProtocols.SendInventory, new LogicProtocols.InventoryMsg(Inventory), TransportConfigure.ReliableFragmented);
} }
public void SendScore()
{
conn.Send(LogicProtocols.SendScore, new LogicProtocols.FloatMsg(SceneScore));
}
public void ChangeScene(string scene, bool Additive = false) public void ChangeScene(string scene, bool Additive = false)
{ {
conn.Send(LoginProtocols.SceneChange, new LoginProtocols.SceneMsg(scene,Additive)); conn.Send(LoginProtocols.SceneChange, new LoginProtocols.SceneMsg(scene,Additive));

+ 6
- 5
Assets/Scripts/UI/InventoryCatch.cs View File

@ -8,25 +8,26 @@ public class InventoryCatch : LogicElementHolder
[SerializeField] [SerializeField]
private InventoryUI InventoryUI; private InventoryUI InventoryUI;
public override void OnAdd(LogicElementUI element) public override void OnAdd(LogicElementUI element)
{ {
foreach (LogicBlock block in element.logicElement.GetAllBlocks()) foreach (LogicBlock block in element.logicElement.GetAllBlocks())
{ {
BagItem item = InventoryUI.content.FirstOrDefault(p => p.canHold(block)); BagItem item = InventoryUI.content.FirstOrDefault(p => p.canHold(block));
if (item != default) if (item != default)
item.OnAdd(element); item.OnAdd(element);
Destroy(element.gameObject); Destroy(element.gameObject);
} }
} }
public override void OnDoubleClick(LogicElementUI element) public override void OnDoubleClick(LogicElementUI element)
{ {
//DoNothing //DoNothing
} }
public override void OnRemove(LogicElementUI element) public override void OnRemove(LogicElementUI element)
{ {
//DoNothing //DoNothing

+ 4
- 0
Assets/Scripts/UI/NetworkedUIManager.cs View File

@ -13,6 +13,8 @@ public class NetworkedUIManager : PlayerUIManager
private TMPro.TextMeshProUGUI TimeText; private TMPro.TextMeshProUGUI TimeText;
[SerializeField] [SerializeField]
private RectTransform Title; private RectTransform Title;
[SerializeField]
private TMPro.TextMeshProUGUI ScoreText;
[Header("Debug")] [Header("Debug")]
[SerializeField] [SerializeField]
@ -29,9 +31,11 @@ public class NetworkedUIManager : PlayerUIManager
TrayUI.SetBlockReader(reader); TrayUI.SetBlockReader(reader);
StartTime = Time.time; StartTime = Time.time;
ShowPosition.y -= Title.rect.height; ShowPosition.y -= Title.rect.height;
ScoreText.text = "Score: " + Client.RoundScore;
OnClick_Show(); OnClick_Show();
} }
private void Update() private void Update()
{ {

Loading…
Cancel
Save