diff --git a/Assets/Scripts/Multiplayer/Transforms.meta b/Assets/Scripts/Multiplayer/Transforms.meta
new file mode 100644
index 0000000..09f3f57
--- /dev/null
+++ b/Assets/Scripts/Multiplayer/Transforms.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 995aec6206780bb4d8c1bccbccf5ac8c
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scripts/Multiplayer/ClientNetworkTransform.cs b/Assets/Scripts/Multiplayer/Transforms/ClientNetworkTransform.cs
similarity index 55%
rename from Assets/Scripts/Multiplayer/ClientNetworkTransform.cs
rename to Assets/Scripts/Multiplayer/Transforms/ClientNetworkTransform.cs
index eb8bfcd..0d9feb0 100644
--- a/Assets/Scripts/Multiplayer/ClientNetworkTransform.cs
+++ b/Assets/Scripts/Multiplayer/Transforms/ClientNetworkTransform.cs
@@ -10,12 +10,13 @@ using UnityEngine;
[DisallowMultipleComponent]
public class ClientNetworkTransform : NetworkTransform
{
- ///
- /// Used to determine who can write to this transform. Owner client only.
- /// This imposes state to the server. This is putting trust on your clients. Make sure no security-sensitive features use this transform.
- ///
- protected override bool OnIsServerAuthoritative()
- {
- return false;
- }
+ public AuthorityMode authorityMode = AuthorityMode.Client;
+
+ protected override bool OnIsServerAuthoritative() => authorityMode == AuthorityMode.Server;
+}
+
+public enum AuthorityMode
+{
+ Server,
+ Client
}
\ No newline at end of file
diff --git a/Assets/Scripts/Multiplayer/ClientNetworkTransform.cs.meta b/Assets/Scripts/Multiplayer/Transforms/ClientNetworkTransform.cs.meta
similarity index 100%
rename from Assets/Scripts/Multiplayer/ClientNetworkTransform.cs.meta
rename to Assets/Scripts/Multiplayer/Transforms/ClientNetworkTransform.cs.meta
diff --git a/Assets/Scripts/Multiplayer/Transforms/Project.Scripts.Multiplayer.Transforms.asmdef b/Assets/Scripts/Multiplayer/Transforms/Project.Scripts.Multiplayer.Transforms.asmdef
new file mode 100644
index 0000000..2e4cb7e
--- /dev/null
+++ b/Assets/Scripts/Multiplayer/Transforms/Project.Scripts.Multiplayer.Transforms.asmdef
@@ -0,0 +1,17 @@
+{
+ "name": "Project.Scripts.Multiplayer.Transforms",
+ "rootNamespace": "",
+ "references": [
+ "GUID:1491147abca9d7d4bb7105af628b223e",
+ "GUID:3b8ed52f1b5c64994af4c4e0aa4b6c4b"
+ ],
+ "includePlatforms": [],
+ "excludePlatforms": [],
+ "allowUnsafeCode": false,
+ "overrideReferences": false,
+ "precompiledReferences": [],
+ "autoReferenced": true,
+ "defineConstraints": [],
+ "versionDefines": [],
+ "noEngineReferences": false
+}
\ No newline at end of file
diff --git a/Assets/Scripts/Multiplayer/Transforms/Project.Scripts.Multiplayer.Transforms.asmdef.meta b/Assets/Scripts/Multiplayer/Transforms/Project.Scripts.Multiplayer.Transforms.asmdef.meta
new file mode 100644
index 0000000..65afbc0
--- /dev/null
+++ b/Assets/Scripts/Multiplayer/Transforms/Project.Scripts.Multiplayer.Transforms.asmdef.meta
@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 41f069d934ffb98448515c5816eaffdf
+AssemblyDefinitionImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scripts/Player/Input/PlayerInput.cs b/Assets/Scripts/Player/Input/PlayerInput.cs
index e2a9b98..af19334 100644
--- a/Assets/Scripts/Player/Input/PlayerInput.cs
+++ b/Assets/Scripts/Player/Input/PlayerInput.cs
@@ -5,17 +5,17 @@ using System;
using UnityEngine;
using UnityEngine.InputSystem;
-public class PlayerInput : MonoBehaviour
+public class PlayerInput : MonoBehaviour, IMoveData
{
[SerializeField] private int playerNumber;
- public Vector2 movement;
- public Vector2 look;
+ private MoveData moveData = new();
public Gamepad controller { get; private set; }
public bool whipAttack;
public event Action ropeLengthShrinken;
public event Action ropeLengthExtend;
+ public event Action OnNewMoveData;
public bool useArrowKeys = false;
@@ -32,12 +32,14 @@ public class PlayerInput : MonoBehaviour
private void Update()
{
- movement.x = Input.GetAxisRaw("bruh");
- movement.y = Input.GetAxisRaw("bruh_v");
+ moveData.Movement.x = Input.GetAxisRaw("bruh");
+ moveData.Movement.y = Input.GetAxisRaw("bruh_v");
whipAttack = Input.GetKey(KeyCode.R);
if (Input.GetKey(KeyCode.E)) ropeLengthShrinken?.Invoke(playerNumber);
if (Input.GetKey(KeyCode.Q)) ropeLengthExtend?.Invoke(playerNumber);
+
+ OnNewMoveData?.Invoke(moveData);
}
}
diff --git a/Assets/Scripts/Player/Input/Project.Scripts.Player.Input.asmdef b/Assets/Scripts/Player/Input/Project.Scripts.Player.Input.asmdef
index d509a6b..47f82f6 100644
--- a/Assets/Scripts/Player/Input/Project.Scripts.Player.Input.asmdef
+++ b/Assets/Scripts/Player/Input/Project.Scripts.Player.Input.asmdef
@@ -2,7 +2,11 @@
"name": "Project.Scripts.Player.Input",
"rootNamespace": "",
"references": [
- "GUID:75469ad4d38634e559750d17036d5f7c"
+ "GUID:75469ad4d38634e559750d17036d5f7c",
+ "GUID:ab47f305e1cd6654ca0ff5d6c7942d09",
+ "GUID:1491147abca9d7d4bb7105af628b223e",
+ "GUID:41f069d934ffb98448515c5816eaffdf",
+ "GUID:3b8ed52f1b5c64994af4c4e0aa4b6c4b"
],
"includePlatforms": [],
"excludePlatforms": [],
diff --git a/Assets/Scripts/Player/Input/ReconciliationPlayerControllerMiddleman.cs b/Assets/Scripts/Player/Input/ReconciliationPlayerControllerMiddleman.cs
new file mode 100644
index 0000000..116ec13
--- /dev/null
+++ b/Assets/Scripts/Player/Input/ReconciliationPlayerControllerMiddleman.cs
@@ -0,0 +1,203 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Reflection;
+using Unity.Netcode;
+using UnityEditor.Events;
+using UnityEngine;
+using UnityEngine.Events;
+using UnityEngine.InputSystem;
+using UnityEngine.UIElements;
+using UnityEngine.Windows;
+
+
+/// This script is for networking the player with reconciliation
+
+[RequireComponent(typeof(ClientNetworkTransform))]
+public class ReconciliationPlayerControllerMiddleman : NetworkBehaviour, IMoveData
+{
+ // Current
+ private InputPayload currentInputState;
+ private int currentTick => NetworkManager.Singleton.NetworkTickSystem.LocalTime.Tick;
+ private int bufferIndex => currentTick % BUFFER_SIZE;
+ private PlayerInput inputSource;
+
+
+ // Shared
+ private const int BUFFER_SIZE = 1024;
+
+ // Local
+ private StatePayload[] stateBuffer;
+ private InputPayload[] inputBuffer;
+ private StatePayload latestServerState;
+ private StatePayload lastProcessedState;
+
+ private Queue inputQueue = new Queue();
+
+ private ClientNetworkTransform clientNetworkTransform;
+
+
+ [Header("Debug")]
+ [SerializeField] private bool ForceEnableComponent = false;
+
+ public event Action OnNewMoveData;
+
+ void OnEnable()
+ {
+ if (NetworkManager.Singleton == null)
+ {
+ Debug.Log("[Movement] No network manager found. Ignoring reconciliation.");
+ if (!ForceEnableComponent)
+ {
+ this.enabled = false;
+ return;
+ }
+ }
+
+ if (!TryGetComponent(out inputSource))
+ {
+ Debug.LogError("[Movement] No player input found. Ignoring reconciliation.");
+ this.enabled = false;
+ return;
+ }
+
+ stateBuffer = new StatePayload[BUFFER_SIZE];
+ inputBuffer = new InputPayload[BUFFER_SIZE];
+
+ currentInputState = new InputPayload();
+ inputSource.OnNewMoveData += (moveData) => currentInputState.moveData = moveData;
+
+ clientNetworkTransform = GetComponent();
+ SwitchAuthorityMode(AuthorityMode.Client);
+ }
+
+ private void Update()
+ {
+ if (IsServer)
+ ServerTick();
+
+ if (IsOwner)
+ ClientTick();
+ }
+
+ private void ServerTick()
+ {
+ foreach (InputPayload payload in inputQueue)
+ {
+ stateBuffer[bufferIndex] = ProcessMovement(payload);
+ }
+
+ OnServerStateRecieved_ServerRpc(stateBuffer[bufferIndex]);
+ }
+
+ private void ClientTick()
+ {
+ if (!latestServerState.Equals(default(StatePayload)) &&
+ (lastProcessedState.Equals(default(StatePayload)) ||
+ !latestServerState.Equals(lastProcessedState)))
+ {
+ Reconciliation();
+ }
+
+ // Add payload to inputBuffer
+ InputPayload payload = new InputPayload();
+ payload.tick = currentTick;
+ payload.moveData = currentInputState.moveData;
+ inputBuffer[bufferIndex] = payload;
+
+ stateBuffer[bufferIndex] = ProcessMovement(payload);
+
+ if (!(IsHost || IsServer))
+ OnClientInput_ClientRpc(payload);
+ }
+
+ [ClientRpc]
+ private void OnClientInput_ClientRpc(InputPayload payload)
+ {
+ inputQueue.Enqueue(payload);
+ }
+
+
+ [ServerRpc]
+ private void OnServerStateRecieved_ServerRpc(StatePayload serverState)
+ {
+ if (!IsOwner) return;
+ latestServerState = serverState;
+ }
+
+ private void Reconciliation()
+ {
+ lastProcessedState = latestServerState;
+
+ int serverStateBufferIndex = latestServerState.tick % BUFFER_SIZE;
+ float positionError = Vector3.Distance(latestServerState.position, stateBuffer[serverStateBufferIndex].position);
+
+ if (positionError > 0.001f)
+ {
+ transform.position = latestServerState.position;
+
+ stateBuffer[serverStateBufferIndex] = latestServerState;
+
+ int tickToProcess = latestServerState.tick + 1;
+
+ for (; tickToProcess < currentTick; tickToProcess++)
+ {
+ // Reprocess movement
+ StatePayload reprocessedState = ProcessMovement(inputBuffer[tickToProcess]);
+
+ // Update buffer with reprocessed state
+ int bufferIndex = tickToProcess % BUFFER_SIZE;
+ stateBuffer[bufferIndex] = reprocessedState;
+ }
+
+ Debug.Log($"[{latestServerState.tick}] Reconciliated");
+ }
+ }
+
+ private void SwitchAuthorityMode(AuthorityMode mode)
+ {
+ clientNetworkTransform.authorityMode = mode;
+ bool shouldSync = mode == AuthorityMode.Client;
+ clientNetworkTransform.SyncPositionX = shouldSync;
+ clientNetworkTransform.SyncPositionY = shouldSync;
+ clientNetworkTransform.SyncPositionZ = shouldSync;
+ }
+
+
+ private StatePayload ProcessMovement(InputPayload payload)
+ {
+ OnNewMoveData?.Invoke(payload.moveData);
+
+ return new StatePayload()
+ {
+ tick = payload.tick,
+ position = transform.position
+ };
+ }
+}
+
+public struct InputPayload : INetworkSerializable
+{
+ public int tick;
+ public MoveData moveData;
+
+ public void NetworkSerialize(BufferSerializer serializer) where T : IReaderWriter
+ {
+ serializer.SerializeValue(ref tick);
+ serializer.SerializeValue(ref moveData);
+ }
+}
+
+public struct StatePayload : INetworkSerializable
+{
+ public int tick;
+ public Vector3 position;
+
+ public void NetworkSerialize(BufferSerializer serializer) where T : IReaderWriter
+ {
+ serializer.SerializeValue(ref tick);
+ serializer.SerializeValue(ref position);
+ }
+}
\ No newline at end of file
diff --git a/Assets/Scripts/Player/Input/ReconciliationPlayerControllerMiddleman.cs.meta b/Assets/Scripts/Player/Input/ReconciliationPlayerControllerMiddleman.cs.meta
new file mode 100644
index 0000000..c17bd66
--- /dev/null
+++ b/Assets/Scripts/Player/Input/ReconciliationPlayerControllerMiddleman.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 0b44a9f6fa4174c4da1032d1e3e4ddcd
\ No newline at end of file
diff --git a/Assets/Scripts/Player/Movement/PlayerMovement.cs b/Assets/Scripts/Player/Movement/PlayerMovement.cs
index bdce55f..252c40b 100644
--- a/Assets/Scripts/Player/Movement/PlayerMovement.cs
+++ b/Assets/Scripts/Player/Movement/PlayerMovement.cs
@@ -25,7 +25,7 @@ public class PlayerMovement : MonoBehaviour
[SerializeField]
private float maxWhipMoveSpeed = 30f;
- private PlayerInput playerInput;
+ private IMoveData playerInput;
private HealthComponent hp;
private PlayerCollideAttack attack;
@@ -33,62 +33,34 @@ public class PlayerMovement : MonoBehaviour
private void Start()
{
rb = GetComponent();
- playerInput = GetComponent();
hp = GetComponent();
attack = GetComponent();
- if (gameObject.name == "Player2")
+ // Try to get middleman first
+ if (TryGetComponent(out ReconciliationPlayerControllerMiddleman middleman))
{
- playerInput.useArrowKeys = true;
+ playerInput = middleman;
+ }
+ else
+ {
+ playerInput = GetComponent();
}
- if (playerInput.controller != null)
- {
- var pad = (DualShockGamepad)Gamepad.all.ElementAtOrDefault(playerInput.PlayerNum);
- if (pad == null) return;
+ playerInput.OnNewMoveData += PlayerInput_OnNewMoveData;
- if (playerInput.PlayerNum == 1)
- pad.SetLightBarColor(Color.red);
- }
}
- private void Update()
+ private void PlayerInput_OnNewMoveData(MoveData moveData)
{
- //if (playerInput.movement != Vector2.zero)
- // animationHandler.Run(true);
- //else
- // animationHandler.Run(false);
+ rb.AddForce(moveData.Movement * moveSpeed);
}
- private void FixedUpdate()
- {
- //if (whipAttack.IsBeingWhipped)
- //{
- // //float sign = Vector2.Dot((whipAttack.joint.position - whipAttack.otherPlayerAttack.joint.position).normalized, movement.normalized);
-
- // Vector2 ropeDir = whipAttack.otherPlayerAttack.joint.position - whipAttack.joint.position;
- // Vector2 tangent = new Vector2(-ropeDir.y, ropeDir.x).normalized;
-
- // rb.AddForce(Vector2.Dot(playerInput.movement, tangent) * tangent * whipMoveSpeed);
- // rb.velocity = Vector2.ClampMagnitude(rb.velocity, maxWhipMoveSpeed);
- //}
- //else if (whipAttack.IsWhippingOtherPlayer)
- //{
- // playerInput.movement = Vector2.zero;
- //}
- //else
- {
- rb.AddForce(playerInput.movement * moveSpeed);
- }
-
- }
-
void OnCollisionStay2D(Collision2D collision)
{
if (collision.collider.gameObject.CompareTag("Enemy"))
{ // Other object is an enemy
- hp.TakeDamage(1f);
+ hp.TakeDamage(1f);
}
}
diff --git a/Assets/Scripts/Player/Movement/Project.Scripts.Player.Movement.asmdef b/Assets/Scripts/Player/Movement/Project.Scripts.Player.Movement.asmdef
index 433e258..528f071 100644
--- a/Assets/Scripts/Player/Movement/Project.Scripts.Player.Movement.asmdef
+++ b/Assets/Scripts/Player/Movement/Project.Scripts.Player.Movement.asmdef
@@ -8,7 +8,8 @@
"GUID:ddd4dba7c768b564a879069c52854fc5",
"GUID:2ea4a18a75f268848b43865100892489",
"GUID:ab47f305e1cd6654ca0ff5d6c7942d09",
- "GUID:f4c364e1215051e4dbc6c0bc8fb49793"
+ "GUID:f4c364e1215051e4dbc6c0bc8fb49793",
+ "GUID:1491147abca9d7d4bb7105af628b223e"
],
"includePlatforms": [],
"excludePlatforms": [],
diff --git a/Assets/Scripts/Player/Other/MoveData.cs b/Assets/Scripts/Player/Other/MoveData.cs
new file mode 100644
index 0000000..03fd0eb
--- /dev/null
+++ b/Assets/Scripts/Player/Other/MoveData.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using Unity.Netcode;
+using Unity.VisualScripting.YamlDotNet.Core.Tokens;
+using UnityEngine;
+
+public struct MoveData : INetworkSerializable
+{
+ public Vector2 Movement;
+ public Vector2 Look;
+
+ public void NetworkSerialize(BufferSerializer serializer) where T : IReaderWriter
+ {
+ serializer.SerializeValue(ref Movement);
+ //serializer.SerializeValue(ref Look); // Not used yet
+ }
+}
+
+public interface IMoveData
+{
+ public event Action OnNewMoveData;
+}
\ No newline at end of file
diff --git a/Assets/Scripts/Player/Other/MoveData.cs.meta b/Assets/Scripts/Player/Other/MoveData.cs.meta
new file mode 100644
index 0000000..be2575c
--- /dev/null
+++ b/Assets/Scripts/Player/Other/MoveData.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: fe68eaee6977ed948b5a2a0e53a44ef6
\ No newline at end of file
diff --git a/Assets/Scripts/Player/Other/PlayerCollideAttack.cs b/Assets/Scripts/Player/Other/PlayerCollideAttack.cs
index 70bc38c..074252a 100644
--- a/Assets/Scripts/Player/Other/PlayerCollideAttack.cs
+++ b/Assets/Scripts/Player/Other/PlayerCollideAttack.cs
@@ -15,15 +15,17 @@ public class PlayerCollideAttack : MonoBehaviour
{
if (collision.collider.tag != "Enemy") return;
- HealthComponent health = collision.collider.gameObject.GetComponent();
- if (health == null)
- health = collision.collider.transform.parent.GetComponent();
- if (health == null) return;
- health = collision.collider.gameObject.GetComponentInChildren();
- if (health == null) return;
+ // Below was messing with assembly definitions
- float speed = body.velocity.magnitude;
- float damage = speedToDamage.Evaluate(speed);
- health.TakeDamage(damage);
+ //HealthComponent health = collision.collider.gameObject.GetComponent();
+ //if (health == null)
+ // health = collision.collider.transform.parent.GetComponent();
+ //if (health == null) return;
+ // health = collision.collider.gameObject.GetComponentInChildren();
+ //if (health == null) return;
+
+ //float speed = body.velocity.magnitude;
+ //float damage = speedToDamage.Evaluate(speed);
+ //health.TakeDamage(damage);
}
}
diff --git a/Assets/Scripts/Player/Other/Project.scripts.player.other.asmdef b/Assets/Scripts/Player/Other/Project.scripts.player.other.asmdef
index fa3b1b0..d59de16 100644
--- a/Assets/Scripts/Player/Other/Project.scripts.player.other.asmdef
+++ b/Assets/Scripts/Player/Other/Project.scripts.player.other.asmdef
@@ -3,10 +3,9 @@
"rootNamespace": "",
"references": [
"GUID:6055be8ebefd69e48b49212b09b47b2f",
- "GUID:1eb4e3e6c04cdc848bab71651b1e2ecd",
"GUID:f0aa6e1ec272fc041a727a9dfb7c1e67",
"GUID:75469ad4d38634e559750d17036d5f7c",
- "GUID:2ea4a18a75f268848b43865100892489"
+ "GUID:1491147abca9d7d4bb7105af628b223e"
],
"includePlatforms": [],
"excludePlatforms": [],
diff --git a/Assets/Scripts/Rope/RopeSimulator.cs b/Assets/Scripts/Rope/RopeSimulator.cs
index 2c5a4ad..2ae0719 100644
--- a/Assets/Scripts/Rope/RopeSimulator.cs
+++ b/Assets/Scripts/Rope/RopeSimulator.cs
@@ -355,26 +355,26 @@ public class RopeSimulator : NetworkBehaviour
{
Assert.IsTrue(ShouldSimulate);
- if (overshoot > pullAnimationOvershootThreshold)
- {
- float startDot = Vector2.Dot((start.position - rope.points[1].position).normalized, start.playerInput.movement);
- if (startDot > 0.35f)
- {
- start.playerAnimationHandler?.animator.SetBool("IsPulling", true);
- }
+ //if (overshoot > pullAnimationOvershootThreshold)
+ //{
+ // float startDot = Vector2.Dot((start.position - rope.points[1].position).normalized, start.playerInput.movement);
+ // if (startDot > 0.35f)
+ // {
+ // start.playerAnimationHandler?.animator.SetBool("IsPulling", true);
+ // }
- float endDot = Vector2.Dot((end.position - rope.points[rope.points.Count - 2].position).normalized, end.playerInput.movement);
- if (endDot > 0.35f)
- {
- end.playerAnimationHandler?.animator.SetBool("IsPulling", true);
- }
+ // float endDot = Vector2.Dot((end.position - rope.points[rope.points.Count - 2].position).normalized, end.playerInput.movement);
+ // if (endDot > 0.35f)
+ // {
+ // end.playerAnimationHandler?.animator.SetBool("IsPulling", true);
+ // }
- }
- else
- {
- start.playerAnimationHandler?.animator.SetBool("IsPulling", false);
- end.playerAnimationHandler?.animator.SetBool("IsPulling", false);
- }
+ //}
+ //else
+ //{
+ // start.playerAnimationHandler?.animator.SetBool("IsPulling", false);
+ // end.playerAnimationHandler?.animator.SetBool("IsPulling", false);
+ //}
}
private void PullPlayers(float overshoot)
diff --git a/Assets/Scripts/Upgrade/Upgrader.cs b/Assets/Scripts/Upgrade/Upgrader.cs
index df90ba2..62a9a45 100644
--- a/Assets/Scripts/Upgrade/Upgrader.cs
+++ b/Assets/Scripts/Upgrade/Upgrader.cs
@@ -125,176 +125,176 @@ public class Upgrader : MonoBehaviour
// Update is called once per frame
void Update()
{
- bool upgrade = canUpgrade();
+ //bool upgrade = canUpgrade();
- if (canUpgrade())
- {
+ //if (canUpgrade())
+ //{
- if (!prevCouldUpgrade)
- {
- background.color = Color.white;
- foreach (Image i in upgradeImages)
- {
- i.color = Color.white;
- }
+ // if (!prevCouldUpgrade)
+ // {
+ // background.color = Color.white;
+ // foreach (Image i in upgradeImages)
+ // {
+ // i.color = Color.white;
+ // }
- Player1Cursor.gameObject.SetActive(true);
- Player2Cursor.gameObject.SetActive(true);
- }
+ // Player1Cursor.gameObject.SetActive(true);
+ // Player2Cursor.gameObject.SetActive(true);
+ // }
- int p1a = getRegion(Player1Input.look.x, Player1Input.look.y, 8);
- int p2a = getRegion(Player2Input.look.x, Player2Input.look.y, 8);
+ // int p1a = getRegion(Player1Input.look.x, Player1Input.look.y, 8);
+ // int p2a = getRegion(Player2Input.look.x, Player2Input.look.y, 8);
- //keyboard upgrade
- if (Input.GetKey(KeyCode.Alpha1))
- {
- p1a = p2a = 0;
- }
- else if (Input.GetKey(KeyCode.Alpha2))
- {
- p1a = p2a = 1;
- }
- else if (Input.GetKey(KeyCode.Alpha3))
- {
- p1a = p2a = 2;
- }
- else if (Input.GetKey(KeyCode.Alpha4))
- {
- p1a = p2a = 3;
- }
- else if (Input.GetKey(KeyCode.Alpha5))
- {
- p1a = p2a = 4;
- }
- else if (Input.GetKey(KeyCode.Alpha6))
- {
- p1a = p2a = 5;
- }
- else if (Input.GetKey(KeyCode.Alpha7))
- {
- p1a = p2a = 6;
- }
- else if (Input.GetKey(KeyCode.Alpha8))
- {
- p1a = p2a = 7;
- }
+ // //keyboard upgrade
+ // if (Input.GetKey(KeyCode.Alpha1))
+ // {
+ // p1a = p2a = 0;
+ // }
+ // else if (Input.GetKey(KeyCode.Alpha2))
+ // {
+ // p1a = p2a = 1;
+ // }
+ // else if (Input.GetKey(KeyCode.Alpha3))
+ // {
+ // p1a = p2a = 2;
+ // }
+ // else if (Input.GetKey(KeyCode.Alpha4))
+ // {
+ // p1a = p2a = 3;
+ // }
+ // else if (Input.GetKey(KeyCode.Alpha5))
+ // {
+ // p1a = p2a = 4;
+ // }
+ // else if (Input.GetKey(KeyCode.Alpha6))
+ // {
+ // p1a = p2a = 5;
+ // }
+ // else if (Input.GetKey(KeyCode.Alpha7))
+ // {
+ // p1a = p2a = 6;
+ // }
+ // else if (Input.GetKey(KeyCode.Alpha8))
+ // {
+ // p1a = p2a = 7;
+ // }
- if (p1a != -1 && p2a == p1a)
- {
- if (acceptTime > 2f)
- {
- switch (p1a)
- {
- case 0:
- UpgradeMopSize();
- break;
- case 1:
- UpgradeSpeed();
- break;
- case 2:
- RopeUpgrade();
- break;
- case 3:
- HealthUpgrade();
- break;
- case 4:
- DamageUpgrade();
- break;
- case 5:
- BloodUpgrade();
- break;
- case 6:
- ReelUpgrade();
- break;
- case 7:
- ReviveUpgrade();
- break;
- }
+ // if (p1a != -1 && p2a == p1a)
+ // {
+ // if (acceptTime > 2f)
+ // {
+ // switch (p1a)
+ // {
+ // case 0:
+ // UpgradeMopSize();
+ // break;
+ // case 1:
+ // UpgradeSpeed();
+ // break;
+ // case 2:
+ // RopeUpgrade();
+ // break;
+ // case 3:
+ // HealthUpgrade();
+ // break;
+ // case 4:
+ // DamageUpgrade();
+ // break;
+ // case 5:
+ // BloodUpgrade();
+ // break;
+ // case 6:
+ // ReelUpgrade();
+ // break;
+ // case 7:
+ // ReviveUpgrade();
+ // break;
+ // }
- // Subtract blood
- bloodManager.score -= upgradeCost;
- upgradeCost = (int)(upgradeCost * 1.2f);
- acceptTime = 0f;
- }
- else
- {
- acceptTime += Time.deltaTime;
+ // // Subtract blood
+ // bloodManager.score -= upgradeCost;
+ // upgradeCost = (int)(upgradeCost * 1.2f);
+ // acceptTime = 0f;
+ // }
+ // else
+ // {
+ // acceptTime += Time.deltaTime;
- foreach (Image i in upgradeImages)
- {
- i.fillAmount = 1f;
- i.gameObject.transform.localScale = Vector3.one;
- }
+ // foreach (Image i in upgradeImages)
+ // {
+ // i.fillAmount = 1f;
+ // i.gameObject.transform.localScale = Vector3.one;
+ // }
- switch (p1a)
- {
- case 0:
- description.text = upgrades.mopUpgrade.name;
- break;
- case 1:
- description.text = upgrades.speedUpgrade.name;
- break;
- case 2:
- description.text = upgrades.ropeUpgrade.name;
- break;
- case 3:
- description.text = upgrades.healthUpgrade.name;
- break;
- case 4:
- description.text = upgrades.damageUpgrade.name;
- break;
- case 5:
- description.text = upgrades.bloodUpgrade.name;
- break;
- case 6:
- description.text = upgrades.reelUpgrade.name;
- break;
- case 7:
- description.text = upgrades.reviveUpgrade.name;
- break;
- }
+ // switch (p1a)
+ // {
+ // case 0:
+ // description.text = upgrades.mopUpgrade.name;
+ // break;
+ // case 1:
+ // description.text = upgrades.speedUpgrade.name;
+ // break;
+ // case 2:
+ // description.text = upgrades.ropeUpgrade.name;
+ // break;
+ // case 3:
+ // description.text = upgrades.healthUpgrade.name;
+ // break;
+ // case 4:
+ // description.text = upgrades.damageUpgrade.name;
+ // break;
+ // case 5:
+ // description.text = upgrades.bloodUpgrade.name;
+ // break;
+ // case 6:
+ // description.text = upgrades.reelUpgrade.name;
+ // break;
+ // case 7:
+ // description.text = upgrades.reviveUpgrade.name;
+ // break;
+ // }
- upgradeImages[p1a].fillAmount = acceptTime / 2f;
- upgradeImages[p1a].transform.localScale = Vector3.one * 2f;
- }
- }
- else
- {
- description.text = "";
+ // upgradeImages[p1a].fillAmount = acceptTime / 2f;
+ // upgradeImages[p1a].transform.localScale = Vector3.one * 2f;
+ // }
+ // }
+ // else
+ // {
+ // description.text = "";
- if (acceptTime > 0f)
- {
- foreach (Image i in upgradeImages)
- {
- i.fillAmount = 1f;
- i.gameObject.transform.localScale = Vector3.one;
- }
- }
+ // if (acceptTime > 0f)
+ // {
+ // foreach (Image i in upgradeImages)
+ // {
+ // i.fillAmount = 1f;
+ // i.gameObject.transform.localScale = Vector3.one;
+ // }
+ // }
- acceptTime = 0f;
- // background.fillAmount = 0f;
- }
- }
- else if (prevCouldUpgrade)
- {
- AudioManager.PlaySound("Blood_Splatter_Large_SFX", Vector3.zero, false, false);
+ // acceptTime = 0f;
+ // // background.fillAmount = 0f;
+ // }
+ //}
+ //else if (prevCouldUpgrade)
+ //{
+ // AudioManager.PlaySound("Blood_Splatter_Large_SFX", Vector3.zero, false, false);
- description.text = "";
- background.color = Color.gray;
- foreach (Image i in upgradeImages)
- {
- i.color = Color.gray;
- i.gameObject.transform.localScale = Vector3.one;
- }
+ // description.text = "";
+ // background.color = Color.gray;
+ // foreach (Image i in upgradeImages)
+ // {
+ // i.color = Color.gray;
+ // i.gameObject.transform.localScale = Vector3.one;
+ // }
- Player1Cursor.gameObject.SetActive(false);
- Player2Cursor.gameObject.SetActive(false);
- }
+ // Player1Cursor.gameObject.SetActive(false);
+ // Player2Cursor.gameObject.SetActive(false);
+ //}
- Player1Cursor.localPosition = Player1Input.look.normalized * (125 - 12);
- Player2Cursor.localPosition = Player2Input.look.normalized * (125 - 12);
+ //Player1Cursor.localPosition = Player1Input.look.normalized * (125 - 12);
+ //Player2Cursor.localPosition = Player2Input.look.normalized * (125 - 12);
- prevCouldUpgrade = upgrade;
+ //prevCouldUpgrade = upgrade;
}
/// Increases mop radius by 10%