Пример #1
0
    /// <summary>
    /// If player selects a penguin, highlight it, if another one was previously clicked, clear its selection
    /// </summary>
    /// <param name="newPenguin"></param>
    ///
    void ChangePenguin(GamePenguin newPenguin)
    {
        if (m_currentPenguin)
        {
            m_currentPenguin.OnSelectOff(); // Unselect currently selected
        }
        m_currentPenguin = newPenguin;      // New selection

        // Set Selected flag on new penguin
        //
        m_currentPenguin.OnSelect();
    }
Пример #2
0
        public override void OnPenguinClicked(GameManager gm, GamePenguin penguin)
        {
            // If a penguin is already selected, unselect it
            //
            if (gm.CurrentPenguin)
            {
                gm.UnselectPenguin();
            }

            // Evaluate clicked penguin
            //
            if (gm.CurrentPlayer.IsMyPenguin(penguin))
            {
                // Compute valid moves
                //
                gm.FindLegalMoves(penguin);

                // If there are no valid moves, remove penguin
                //
                if (penguin.ValidMoveList.Count == 0)
                {
                    gm.CurrentPlayer.AddFish(penguin.CurrentTile.FishScoreValue); // Take fish on this tile

                    penguin.CurrentTile.Sink();                                   // Remove tile

                    // gm.OnExpungePenguin()   // Remove Penguin

                    // gm.NextPlayer();   // Go to next player
                }
                else   // Make clicked penguin the current penguin
                {
                    gm.CurrentPenguin = penguin;
                    gm.CurrentTile    = penguin.CurrentTile;

                    penguin.OnSelect();
                }
            }
        }
    /// <summary>
    /// Respond to player clicking on a penguin they want to move
    /// </summary>
    /// <param name="penguin"></param>
    ///
    public override void OnPenguinClicked(GamePenguin penguin)
    {
        // If a penguin is already selected, unselect it
        //
        if (s_refGM.CurrentPenguin)
        {
            s_refGM.ClearPenguinCurrent();
        }

        // Evaluate clicked penguin
        //
        if (s_refGM.CurrentPlayer.IsMyPenguin(penguin))
        {
            // Compute valid moves
            //
            s_refGM.FindLegalMoves(penguin);

            // If there are no valid moves, remove penguin
            //
            if (penguin.ValidMoveList.Count == 0)
            {
                s_refGM.RemoveUnmovablePenguin(penguin);
            }
            else   // Make clicked penguin the current penguin
            {
                s_refGM.MakePenguinCurrent(penguin);

                // Check if penguin is alone on an "island" of tiles and remove it if it is
                //
                bool bPenguinRemoved = s_refGM.TryRemovePenguin();

                if (!bPenguinRemoved)
                {
                    penguin.OnSelect();                    // If penguin not removed, visually highlight it and wait for player to move
                }
            }
        }
    }