DerangedSenators / copsandrobbers

2D Multiplayer Cops and Robbers Game made with Unity for the Aston University Team project module
https://www.copsandrobbers.co.uk
Apache License 2.0
6 stars 5 forks source link

PlayerExport/ImportScript #72

Closed Mirlle closed 3 years ago

Mirlle commented 3 years ago
hsravat-4590 commented 3 years ago

Sample Idea:

class TransmitInfo{
  public readonly PlayerHit mPlayerHit; //Set this in constructor
  public readonly int mPlayer; // This Player
  struct PlayerLocation{
    float x;
    float y;
  }
  struct playersHit{
     boolean ZERO;
     boolean ONE;
     boolean TWO;
     boolean THREE;
     boolean FOUR
  }

 public readonly int MoneyBagPicked;
}
hsravat-4590 commented 3 years ago

How will we validate PlayerLocation?

hsravat-4590 commented 3 years ago

All other validations (PlayersHit and Pickups) are validated using PlayerLocation

hsravat-4590 commented 3 years ago
  • [ ] Player position
  • [ ] [Damaging player]
  • [ ] Players current health
hsravat-4590 commented 3 years ago

Change of plan with PlayerHit. Instead of holding it in a struct, we should hold it in a HashMap<int,int> where the first value if 1 indicates that that player is hit. As we can assume that only one player is hit by another in a single frame, we know that there will only be one 1 value in the hashmap allowing us to discover it in O(1) time rather than O(N) as it was previously. Using a HashMap will also remove the restriction on the amount of players in a game

hsravat-4590 commented 3 years ago

Change of plan with PlayerHit. Instead of holding it in a struct, we should hold it in a HashMap<int,int> where the first value if 1 indicates that that player is hit. As we can assume that only one player is hit by another in a single frame, we know that there will only be one 1 value in the hashmap allowing us to discover it in O(1) time rather than O(N) as it was previously. Using a HashMap will also remove the restriction on the amount of players in a game

Alternatively, As only one player is hit at a time, you could just have a field public readonly int playerHit to record the id of the player that has been hit or -1 if no player was hit in that frame

hsravat-4590 commented 3 years ago

Protobuf Files

Location.proto PlayerHit.proto MoneyBagPicked.proto