Beispiel #1
0
    public override void Init(MainApplication application)
    {
        this.application = application;
        PhotonNetwork.CurrentRoom.IsOpen = false;
        selfState = new RPSPlayerState();

        SyncInitCards();
    }
Beispiel #2
0
 public void OnEvent(EventData photonEvent)
 {
     if (photonEvent.Code == EventCode.kSyncInitCards)
     {
         var player = PhotonNetwork.CurrentRoom.GetPlayer(photonEvent.Sender);
         if (player == self)
         {
             Debug.LogError("Receiving command not sent to self."); return;
         }
         object[] data = (object[])photonEvent.CustomData;
         opponentState = new RPSPlayerState();
         for (int i = 0; i < opponentState.deck.Count; ++i)
         {
             opponentState.deck[i] = (int)data[i];
         }
         for (int i = 0; i < RPSPlayerState.kDefaultHandSize; ++i)
         {
             selfState.Draw();
         }
         for (int i = 0; i < RPSPlayerState.kDefaultHandSize; ++i)
         {
             opponentState.Draw();
         }
     }
     if (photonEvent.Code == EventCode.kPlayedCard)
     {
         var      player = PhotonNetwork.CurrentRoom.GetPlayer(photonEvent.Sender);
         object[] data   = (object[])photonEvent.CustomData;
         int      idx    = (int)data[0];
         if (player == self)
         {
             selfIdx = idx;
             int selfID = selfState.hand[selfIdx];
         }
         else if (player == opponent)
         {
             opponentIdx = idx;
             int opponentId = opponentState.hand[opponentIdx];
         }
         else
         {
             Debug.LogError("Unknown player event raised in room");
             return;
         }
         UpdatePlayed();
     }
 }
Beispiel #3
0
 public override void Win(RPSPlayerState self, RPSPlayerState opponent)
 {
     opponent.TakeDamage(11);
 }
Beispiel #4
0
 public override void Tie(RPSPlayerState self, RPSPlayerState opponent)
 {
 }
Beispiel #5
0
 public override void Lose(RPSPlayerState self, RPSPlayerState opponent)
 {
     self.TakeDamage(2);
 }
Beispiel #6
0
 public override void Tie(RPSPlayerState self, RPSPlayerState opponent)
 {
     opponent.TakeDamage(3);
 }
Beispiel #7
0
 public abstract void Lose(RPSPlayerState self, RPSPlayerState opponent);