Пример #1
0
    }     //Start()

    void Update()
    {
        if (!isLocalPlayer || !initialzed)
        {
            return;
        }

        if (this.turnEventStr != matchDataBroadcaster.TurnEventStr &&
            this.turnEventStr != null)
        {
            HandleTurnEvent();
            // this.turnEventStr = gameMan.turnEventBroadcast; // Unnecessary, this gets done later.
        }

        if (this.lastKnownPriceList != matchDataBroadcaster.PriceListStr)
        {
            Debug.Log(debugTag + "Updating prices...");
            UpdateLocalPrices();
            UpdateMarketFooters();
            // this.lastKnownPriceList = gameMan.priceListStr; // Unnecessary, this gets done later.
        }

        // Highlight cards during Buying Phase
        if (CheckForNewMatchData(1))
        {
            if (this.matchData.Turn == this.id)
            {
                if (this.matchData.Round > matchController.Config.GraceRounds)
                {
                    Debug.Log(debugTag + "Highlighting " + GetNeighbors().Count
                              + " when there's " + GetUnownedCards().Count
                              + " card(s) left");
                    CardAnimations.HighlightCards(GetNeighbors(), this.id);
                }
                else
                {
                    CardAnimations.HighlightCards(GetUnownedCards(), this.id);
                }
            }
            else
            {
                CardAnimations.HighlightCards(GetUnownedCards(), 0);
            }
        }

        if (matchData.Winner >= 0)
        {
            // Debug.Log("WINNER WINNER CHICKED DINNER! CONGRATS PLAYER " + matchData.Winner);
            this.hudController.DisplayWinner(matchData.Winner);
        }

        // This is at the bottom so handlers can compare old data with new data
        UpdateKnownInfo();
    }     // Update()
Пример #2
0
    // METHODS #####################################################################################
    #region METHODS

    // Start is called before the first frame update.
    void Start()
    {
        if (!isLocalPlayer)
        {
            return;
        }

        this.hand.Callback += OnHandUpdated;
        // connection = connectionToClient;

        if (TryToGrabComponents())
        {
            if (!initIdFlag)
            {
                InitId();
            }

            // CmdSpawnMouseManager();

            CmdGetHand();
            // Debug.Log(debug + "Hand size: " + this.hand.Count);
            // gridMan.CreateHandObjects(this.id, this.hand);
            this.knownOwnersList = new List <Coordinate2> [GameManager.playerCount];
            this.knownOwnersGrid = new int[GameManager.width, GameManager.height];

            for (int i = 0; i < GameManager.playerCount; i++)
            {
                this.knownOwnersList[i] = new List <Coordinate2>();
            }

            UpdateKnownRounds();

            // If this is Player 1 and it's the first Turn of the first Round
            if (this.id == 1 && this.lastKnownTurn == 1 &&
                this.lastKnownRound == 1 &&
                this.lastKnownPhase == 1)
            {
                CardAnimations.HighlightCards(GetUnownedCards(), this.id);
            }
        }
        else
        {
            Debug.LogError(debug + "ERROR: Could not grab all components!");
        }
    }     //Start()
Пример #3
0
    }     //Start()

    void Update()
    {
        if (!isLocalPlayer)
        {
            return;
        }

        // On New Turn
        if (PhaseCheck(1))
        {
            Debug.Log(debug + "It must be Phase 1 (" + this.lastKnownPhase + " - " + gameMan.phase);
            ColorPurchasedTile();
            // If the new turn is the player's turn and is past the grace rounds
            //&& gameMan.turn > GameManager.graceRounds
            if (gameMan.turn == this.id)
            {
                if (gameMan.round > GameManager.graceRounds)
                {
                    CardAnimations.HighlightCards(GetNeighbors(), this.id);
                }
                else
                {
                    CardAnimations.HighlightCards(GetUnownedCards(), this.id);
                }
            }
            else
            {
                CardAnimations.HighlightCards(GetUnownedCards(), 0);
            }
        }
        else if (PhaseCheck(2) && gameMan.turnEventBroadcast != this.turnEventStr)
        {
            HandleEvent(phase: 2);

            // Phase 2 Operations go here
            // if (gameMan.turn == this.id)
            // {
            //  Debug.Log("HEYO");
            //  HandleEvent(phase: 2);
            // }
        }
        UpdateKnownRounds();
    }     // Update()
Пример #4
0
    }     // Update()

    private IEnumerator InitPlayer(string address)
    {
        // Grab Components
        yield return(StartCoroutine(GrabComponentsCoroutine()));

        // Determine of the main grid has been created yet
        GameObject testCard = GameObject.Find(CardUtility.CreateCardObjectName("Tile", 0, 0));

        while (testCard == null)
        {
            testCard = GameObject.Find(CardUtility.CreateCardObjectName("Tile", 0, 0));
            yield return(null);
        }

        // Get ID from MatchManager
        CmdInitId(address);
        while (this.id == -1)
        {
            yield return(null);
        }

        // Fetch username from PlayerDataController and send it serverside to MatchController
        InitUsername();

        // Send our ID to the HudController, then force an update from it.
        this.hudController.GetComponent <HudController>().ThisPlayerId = this.id;
        this.hudController.UpdateHud();

        // Grab the config from the broadcaster
        this.config = JsonUtility.FromJson <MatchConfig>(matchDataBroadcaster.MatchConfigStr);
        while (this.config == null)
        {
            yield return(null);
        }

        // Create hand card objects
        Debug.Log(debugTag + "Creating hand card objects for Player " + this.id);
        gridController.CreatePlayerHandObjects(this.id);

        // CmdGetHand(this.id);
        // Debug.Log(debug + "Hand size: " + this.hand.Count);
        // gridMan.CreateHandObjects(this.id, this.hand);
        this.knownOwnersList = new List <Coordinate2> [config.MaxPlayerCount];
        // this.knownOwnersGrid = new int[config.GameGridWidth, config.GameGridHeight];

        for (int i = 0; i < config.MaxPlayerCount; i++)
        {
            this.knownOwnersList[i] = new List <Coordinate2>();
        }

        InitLocalResourcePrices();

        this.matchData    = JsonUtility.FromJson <MatchData>(matchDataBroadcaster.MatchDataStr);
        this.turnEventStr = matchDataBroadcaster.TurnEventStr;

        // InitLocalMarketGrid();
        UpdateKnownInfo();

        while (this.id == -1)
        {
            yield return(null);
        }

        for (int i = 0; i < config.PlayerHandSize; i++)
        {
            CmdGetHandCard(this.id, i);
        }

        // If this is Player 1 and it's the first Turn of the first Round
        if (this.id == 1 && this.matchData.Turn == 1 &&
            this.matchData.Round == 1 &&
            this.matchData.Phase == 1)
        {
            CardAnimations.HighlightCards(GetUnownedCards(), this.id);
        }

        this.initialzed = true;
    }