public override void Use()
 {
     //makes sure player is in jail before they can use card
     if (Jail.InJail())
     {
         Jail.LeaveJail();
         base.Use();
         GameManager.EndOfRollOptions();
     }
 }
Exemplo n.º 2
0
 public static void NextPlayer()
 {
     _activeCard = null;
     _curPlayer  = _players[(Array.IndexOf(_players, _curPlayer) + 1) % _players.Length];
     if (Jail.InJail())
     {
         MenuManager.SwitchToMenuWithInventory(MenuManager.InJailTurnOptions);
     }
     else
     {
         MenuManager.SwitchToMenuWithInventory(MenuManager.TurnOptions);
     }
     //change the target for the camera to the current player
     CameraFollow.target = _curPlayer.transform;
     MenuManager.UpdateInventoryData();
 }
Exemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        velocity = rb.velocity;             //Set the velocity of the dice.

        if (Rolling)
        {
            //if still rolling, the dice numbers are set to 0, and so returns from function
            byte diceTotal = 0;
            foreach (Die die in dice)
            {
                if (die.number == 0)
                {
                    return;
                }
                diceTotal += die.number;
            }

            //set total
            _diceTotal = diceTotal;
            _rolling   = false;

            //checks if player is in jail or not
            if (!Jail.InJail())
            {
                GameManager.CurrentPlayer.Move((sbyte)Result);
            }
            else if (dice[0].number == dice[1].number)
            {
                Jail.LeaveJail();
                GameManager.CurrentPlayer.Move((sbyte)Result);
            }
            else
            {
                MenuManager.SwitchToMenuWithInventory(MenuManager.EndOfTurnOptions);
            }

            //set the camera to track the current player and enable end of roll options
            CameraFollow.target = GameManager.CurrentPlayer.transform;
        }
    }
Exemplo n.º 4
0
    public static void CallTradingButtonListener(Button button)
    {
        if (button == Back)
        {
            //destroy previous cards
            if (TradingOptions.enabled == true)
            {
                foreach (GameObject cardObj in GameObject.FindGameObjectsWithTag("InventoryCard"))
                {
                    GameObject.Destroy(cardObj);
                }
                MenuManager.SwitchToMenu(TradingSetup);
                MenuManager.ShowMenu(BackFromTradingOptions);
            }
            else if (Jail.InJail())
            {
                MenuManager.SwitchToMenuWithInventory(MenuManager.InJailTurnOptions);
            }
            else
            {
                MenuManager.SwitchToMenuWithInventory(MenuManager.TurnOptions);
            }

            _tradee = null;
            //prevent memory leaks
            Resources.UnloadUnusedAssets();
        }
        else if (button == Offer && !(MenuManager.ButtonClicked && ((Tradee.gameObject.GetComponent <AI>() != null && CounterOfferInProgress) ||
                                                                    (GameManager.CurrentPlayer.gameObject.GetComponent <AI>() != null && !CounterOfferInProgress))))
        {
            Text text = Offer.GetComponentInChildren <Text>();
            text.text = text.text == "Offer" ? "CounterOffer" : "Offer";

            _counterOffer       = !_counterOffer;
            Accept.interactable = true;
            Back.interactable   = !Back.interactable;

            UpdateCardsInTrade();
            Offer.interactable = false;
        }
        else if (button == Accept && !(MenuManager.ButtonClicked && ((Tradee.gameObject.GetComponent <AI>() != null && CounterOfferInProgress) ||
                                                                     (GameManager.CurrentPlayer.gameObject.GetComponent <AI>() != null && !CounterOfferInProgress))))
        {
            foreach (Property property in _playerOffer)
            {
                GameManager.CurrentPlayer.RemoveProperty(property);
                Tradee.AddProperty(property);
            }
            foreach (Property property in _tradeeOffer)
            {
                Tradee.RemoveProperty(property);
                GameManager.CurrentPlayer.AddProperty(property);
            }

            _tradee = null;
            if (Jail.InJail())
            {
                MenuManager.SwitchToMenuWithInventory(MenuManager.InJailTurnOptions);
            }
            else
            {
                MenuManager.SwitchToMenuWithInventory(MenuManager.TurnOptions);
            }
        }
        else if (Array.IndexOf(TradingPartnerOptions, button) != -1)
        {
            //set tradee to selected player
            foreach (Player player in GameManager.Players)
            {
                if (player.gameObject.name == button.GetComponentInChildren <Text>().text)
                {
                    _tradee = player;
                    break;
                }
            }

            //reset offer lists
            _tradeeOffer = new List <Property>();
            _playerOffer = new List <Property>();

            MenuManager.SwitchToMenu(TradingOptions);
            MenuManager.ShowMenu(BackFromTradingOptions);

            _counterOffer       = false;
            Accept.interactable = false;
            Offer.GetComponentInChildren <Text>().text = "Offer";

            UpdateCardsInTrade();
            Offer.interactable = false;
        }
    }
Exemplo n.º 5
0
    /// <summary>
    /// moves the player to the specified tile
    /// </summary>
    /// <param name="endPosition"></param>
    public void Move(Tile endPosition)
    {
        //pos = Vector3.MoveTowards(transform.position, endPosition.transform.position, 1.5f * Time.deltaTime);
        _isMoving = true;
        int start = Array.IndexOf(GameManager.Tiles, _playerPosition);
        int end   = Array.IndexOf(GameManager.Tiles, endPosition);

        //add all the tiles on the players path to an array of transform objects
        if (start < end)
        {
            int count = 0;
            _target = new Transform[end - start];
            for (int i = start + 1; i <= end; i++)
            {
                _target[count] = GameManager.Tiles[i].transform;
                count++;
            }
        }
        else if (end < start)
        {
            int count = 0;
            _target = new Transform[(end + GameManager.Tiles.Length) - start];
            for (int j = start + 1; j < GameManager.Tiles.Length; j++)
            {
                _target[count] = GameManager.Tiles[j].transform;
                count++;
            }
            for (int k = 0; k <= end; k++)
            {
                _target[count] = GameManager.Tiles[k].transform;
                count++;
            }
        }
        bool traveledByTileLink = false;

        _playerPosition = endPosition;
        //if there is a snake or ladder the player will move along it
        _playerPosition.MoveAlongTileLink();

        //graphical representation

        //Collect $200 if you pass go
        if (!traveledByTileLink)
        {
            if (!Jail.InJail())
            {
                int position = start;
                while (position != 0)
                {
                    position++;
                    if (position > 39)
                    {
                        position = 0;
                        this.AddFunds(200);
                    }
                    if (position == end)
                    {
                        position = 0;
                    }
                }
            }
        }
    }