示例#1
0
 public override void AskForAction(ActionType actionType, object callbackObject, InfoDescription error)
 {
     this.callbackObject = callbackObject;
     unityPlayer.TurnTimeoutHandler.StartTurnTimer(this, actionType, callbackObject);
     if (error == InfoDescription.NoError)
     {
         //  NO ERROR
         HandleActionRequest(actionType);
         TurnArrowController.SetActive(LocalNetworkPlayer.GetRelativePlayerSeat(GetPlayersSeat()));
     }
     else
     {
         //  SHOW ERROR
         HandleError(error);
         HandleActionRequest(actionType);
         TurnArrowController.SetActive(LocalNetworkPlayer.GetRelativePlayerSeat(GetPlayersSeat()));
         LogManager.Log(error.ToString("G"));
     }
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="LocalNetworkRoom" /> class based on the given message.
        /// </summary>
        /// <param name="message">The received message</param>
        /// <param name="localPlayer">The client local player</param>
        /// <param name="roomOptions">The room options for the new room</param>
        /// <returns>A new <see cref="LocalNetworkRoom" /> instance</returns>
        internal static LocalNetworkRoom FromJoinMessage(IncomingMessage message, LocalNetworkPlayer localPlayer, RoomOptions roomOptions)
        {
            var playerRoom = new LocalNetworkRoom(roomOptions);

            playerRoom.ReadFromMessage(message);

            var playerCount = message.ReadInt32();

            for (int i = 0; i < playerCount; i++)
            {
                var playerId     = message.ReadPlayerId();
                var remotePlayer = RemoteNetworkPlayer.FromMessage(message);
                playerRoom.InternalAddPlayer(remotePlayer, playerId);
            }

            var localPlayerId = message.ReadPlayerId();

            playerRoom.InternalAddPlayer(localPlayer, localPlayerId);

            playerRoom.CustomProperties.ReadFromMessage(message);

            return(playerRoom);
        }
示例#3
0
    public static void ResetHand(int winner, UnityRound currentRound, Player winnerPlayer)
    {
        if (Properties.ActiveGameType == GameType.SinglePlayer)
        {
            destinationPosition = playerPositions[winner].position;
            destinationRotation = playerPositions[winner].rotation;
        }
        else
        {
            int networkWinnerSeat = LocalNetworkPlayer.GetRelativePlayerSeat(winner);
            destinationPosition = playerPositions[networkWinnerSeat].position;
            destinationRotation = playerPositions[networkWinnerSeat].rotation;
        }

        unityRound = currentRound;

        playedCardCount = 0;
        PlayedCardsController.awaitingWinner = winnerPlayer;

        moveCards = true;

        TurnArrowController.TurnArrowOff();
    }
 /// <summary>
 /// Initializes a new instance of the <see cref="LocalNetworkRoom" /> class.
 /// </summary>
 /// <param name="roomOptions">The room options for the new room</param>
 /// <param name="localPlayer">The client local player</param>
 public LocalNetworkRoom(RoomOptions roomOptions, LocalNetworkPlayer localPlayer)
     : this(roomOptions)
 {
     this.InternalAddPlayer(localPlayer);
 }
示例#5
0
 public override NetworkPlayerBase InitializeNetworkPlayer()
 {
     player = new LocalNetworkPlayer(gameTable.gameTable, this);
     return(player);
 }
示例#6
0
 public override void PlayCard(Common.Card cardToPlay)
 {
     PlayedCardsController.PlayCard(cardToPlay, LocalNetworkPlayer.GetRelativePlayerSeat(GetPlayersSeat()), this);
 }
示例#7
0
        /// <summary>
        /// Reset drop zone cards, do last hand and hand to winner animation
        /// </summary>
        /// <param name="handWinner"></param>
        /// <returns></returns>
        private IEnumerator ResetDropZone(NetworkPlayerView handWinner)
        {
            Debug.Log("ResetDropZone");
            Transform            lastHand = LastHandPanel.transform;
            List <CardBehaviour> cards    = droppedCards.Keys.ToList();
            Dictionary <CardBehaviour, Transform> lastCards = new Dictionary <CardBehaviour, Transform>();

            CardBehaviour playerCard = cards.Find(x => (droppedCards[x].tag == "Player"));
            CardBehaviour r1Card     = cards.Find(x => (droppedCards[x].tag == "Robot1"));
            CardBehaviour r2Card     = cards.Find(x => (droppedCards[x].tag == "Robot2"));

            droppedCards.Clear();

            int   j    = 0;
            float time = 0;

            bool lastMoveEnd = true;

            if (playerCard != null)
            {
                LocalNetworkPlayer networkPlayer = GameObject.FindGameObjectWithTag("Player").GetComponent <LocalNetworkPlayer>();
                if (networkPlayer != null && networkPlayer.badCard != null)
                {
                    foreach (Transform card in transform)
                    {
                        if (card.GetComponent <CardBehaviour>().Card.CompareTo(networkPlayer.badCard.GetComponent <CardBehaviour>().Card) == 0)
                        {
                            lastCards.Add(card.GetComponent <CardBehaviour>(), lastHand.GetChild(j++));
                            break;
                        }
                    }
                }
                else
                {
                    lastCards.Add(playerCard, lastHand.GetChild(j++));
                }

                lastMoveEnd = false;
            }

            if (r1Card != null)
            {
                lastMoveEnd = false;
                lastCards.Add(r1Card, lastHand.GetChild(j++));
            }

            if (r2Card != null)
            {
                lastMoveEnd = false;
                lastCards.Add(r2Card, lastHand.GetChild(j));
            }

            StartCoroutine(AnimationToHandWinner(new List <CardBehaviour>(lastCards.Keys), handWinner.transform.GetChild(0).GetChild(1)));

            yield return(new WaitForSeconds(1.3f));

            while (time < 0.2f)
            {
                time += Time.deltaTime;

                foreach (var card in lastCards.Keys)
                {
                    Transform zone = lastCards[card];

                    float currentScale = Mathf.Lerp(1, 0, time / 0.2f);
                    zone.localScale = new Vector3(currentScale, zone.localScale.y, zone.localScale.z);
                }

                yield return(null);
            }

            time = 0;
            bool flag = false;

            while (time < 0.2f)
            {
                time += Time.deltaTime;

                foreach (var card in lastCards.Keys)
                {
                    Transform zone = lastCards[card];

                    if (flag == false)
                    {
                        zone.GetComponent <Image>().sprite         = card.CardImg.sprite;
                        zone.GetComponent <Image>().color          = Color.white;
                        zone.GetComponent <Image>().preserveAspect = true;
                    }

                    float currentScale = Mathf.Lerp(0, 1, time / 0.2f);
                    zone.localScale = new Vector3(currentScale, zone.localScale.y, zone.localScale.z);
                }

                flag = true;
                yield return(null);
            }

            while (lastMoveEnd != true)
            {
                yield return(null);
            }

            ResetHandDropes();
            Debug.Log("ResetDropZone END.");
        }