Esempio n. 1
0
 public override void Deserialize(JHSNetworkReader reader)
 {
     PassWord       = reader.ReadPackedUInt32();
     Port           = reader.ReadPackedUInt32();
     IP             = reader.ReadString();
     gameMatchState = (GameMatchState)reader.ReadByte();
 }
    public void Start(GameMatchState matchState)
    {
        _matchState = matchState;

        _setupFX();

        _passController = new PassInterludeController();

        viewFactory.CreateAsync <PlayFieldView>("PlayFieldView", (_view) =>
        {
            _playfieldView = _view as PlayFieldView;
            view           = _view;

            _playfieldView.onIntroFinishedEvent += _playfieldView_OnIntroTransitionEvent;
            _playfieldView.confirmButton.onClick.AddListener(_onConfirmTurnButton);
            _playfieldView.undoButton.onClick.AddListener(_onUndoButton);
            _playfieldView.exitButton.onClick.AddListener(_onExitButton);

            _playfieldView.SetActivePlayer(activePlayer.index);

            for (int i = 0; i < _matchState.playerGroup.playerCount; ++i)
            {
                PlayerState player = _matchState.playerGroup.GetPlayerByIndex(i);
                _playfieldView.SetPlayerName(i, player.name);
                _playfieldView.SetPlayerScore(i, player.score);
            }

            _setupActiveCustomersView(_playfieldView.staticCardLayer);
            _createPlayerHandView(kLocalPlayerIndex, _playfieldView.staticCardLayer);
        });
    }
Esempio n. 3
0
 public void UpdateServer(uint connectionId, GameMatchState status)
 {
     lock (servers)
     {
         if (servers.TryGetValue(connectionId, out Server server))
         {
             servers[connectionId].status = status;
         }
     }
 }
Esempio n. 4
0
    public static void AnimateOtherPlayerMoves(List <MoveResult> moveList, GameMatchState state, ActiveCustomersView customersView, Transform parent, Action <Vector3> slamCallback, TweenCallback callback)
    {
        Assert.IsNotNull(moveList);
        //Assert.IsTrue(moveList.Count > 0);

        Sequence allPlayedCards = DOTween.Sequence();
        //MoveResult[] moveResults = new MoveResult[PlayerGroup.kMaxPlayerCount];
        int count = moveList.Count;

        for (int i = 0; i < count; ++i)
        {
            MoveRequest request = moveList[i].request;
            MoveResult  result  = moveList[i];

            CustomerCardView customerView = customersView.GetCardByIndex(request.customerSlot);

            IngredientCardData cardData = state.GetCardById(result.usedIngredient) as IngredientCardData;

            if (cardData == null)
            {
                Debug.LogError("Card data is null! cant animate other player card");
                continue;
            }

            IngredientCardView ingredientView = Singleton.instance.cardResourceBank.CreateCardView(
                cardData,
                parent) as IngredientCardView;

            ingredientView.transform.position = parent.transform.position;

            Vector3 delta     = (Camera.main.transform.position - customerView.transform.position).normalized;
            Vector3 targetPos = customerView.transform.position + delta;
            Tween   moveTo    = ingredientView.transform.DOMove(targetPos, 0.75f);
            moveTo.SetEase(Ease.OutQuad);

            ViewFactory vf = Singleton.instance.gui.viewFactory;

            Tween zoomSlam = ZoomSlamTween(ingredientView, customerView, false, () =>
            {
                vf.RemoveView(ingredientView);
                if (slamCallback != null)
                {
                    slamCallback(ingredientView.transform.position);
                }
            }, null);

            Sequence cardTween = DOTween.Sequence();
            cardTween.Append(moveTo);
            cardTween.Insert(moveTo.Duration(false) * 0.75f, zoomSlam);

            allPlayedCards.Insert(i * (cardTween.Duration() * 0.95f), cardTween);
        }
        allPlayedCards.OnComplete(callback);
        allPlayedCards.Play();
    }
Esempio n. 5
0
    public static GameMatchCore Create(
        List <PlayerState> playerList,
        CardDeck customerDeck,
        CardDeck ingredientDeck)
    {
        GameMatchCore core = new GameMatchCore();

        // Also no commands for starting player hands
        core.matchState = GameMatchState.Create(
            playerList,
            customerDeck,
            ingredientDeck);

        return(core);
    }
Esempio n. 6
0
    public static GameMatchState Create(
        List <PlayerState> playerList,
        CardDeck customerDeck,
        CardDeck indredientDeck)
    {
        GameMatchState matchState = new GameMatchState();

        matchState.customerDeck   = customerDeck;
        matchState.ingredientDeck = indredientDeck;

        matchState._setupCardMap();
        matchState._setupPlayerHands(playerList, matchState.ingredientDeck);
        matchState._setupCustomerCards(matchState.customerDeck);

        return(matchState);
    }
    public void Start(GameMatchState matchState)
    {
        _matchState = matchState;

        _setupFX();

        viewFactory.CreateAsync <PlayFieldView>("PlayFieldView", (_view) =>
        {
            _playfieldView = _view as PlayFieldView;
            view           = _view;

            _playfieldView.onIntroFinishedEvent += _playfieldView_OnIntroTransitionEvent;
            _playfieldView.confirmButton.onClick.AddListener(_onConfirmTurnButton);
            _playfieldView.undoButton.onClick.AddListener(_onUndoButton);
            _playfieldView.exitButton.onClick.AddListener(_onExitButton);

            _playfieldView.SetActivePlayer(activePlayer.index);

            if (_networkManager.isConnected)
            {
                _playfieldView.SetThisPlayer(PhotonNetwork.player.NickName);
            }

            for (int i = 0; i < _matchState.playerGroup.playerCount; ++i)
            {
                PlayerState player = _matchState.playerGroup.GetPlayerByIndex(i);
                _playfieldView.SetPlayerName(i, player.name);
                _playfieldView.SetPlayerScore(i, player.score);
            }

            _setupActiveCustomersView(_playfieldView.staticCardLayer);
            _createPlayerHandView(localPlayer.index, _playfieldView.staticCardLayer);

            //_shockClockController = new ShockClockController();
            //_shockClockController.Start(10.0, PhotonNetwork.time, onTimerCallback);
            viewFactory.CreateAsync <ShockClockView>("ShockClockView", (clock) =>
            {
                _shockClockView           = clock as ShockClockView;
                _shockClockView.timerText = "10";
            }, _playfieldView.staticCardLayer);
        });
    }