public int GetBuildingsOwnedByPlayer(Props.PropertyType pType, PlayerType cur_player)
    {
        int count = 0;

        for (int i = 0; i < PropertyList.Length; i++)
        {
            if (PropertyList[i].Owner() == cur_player && PropertyList[i].Type() == pType)
            {
                count++;
            }
        }
        return(count);
    }
    public void Init(Props.PropertyType type, float amt)
    {
        switch (type)
        {
        case Props.PropertyType.Turn:
        {
            rent = new HouseRent(amt);
            break;
        }

        case Props.PropertyType.Tax:
        {
            rent = new TaxRent(amt);
            break;
        }

        case Props.PropertyType.Place:
        {
            rent = new HouseRent(amt);
            break;
        }

        case Props.PropertyType.Community:
        {
            rent = new CommunityRent();
            break;
        }

        case Props.PropertyType.Transport:
        {
            rent = new TransportRent();
            break;
        }

        case Props.PropertyType.Chance:
        {
            rent = new CommunityRent();         // Chance also uses Community logic
            break;
        }

        case Props.PropertyType.Utility:
        {
            rent = new UtilityRent();
            break;
        }

        case Props.PropertyType.Jail:
        {
            rent = new NoRent();
            break;
        }

        case Props.PropertyType.Parking:
        {
            rent = new NoRent();
            break;
        }

        default:
        {
            Debug.Log("Unsupported Rent type" + type.ToString());
            rent = new NoRent();
            break;
        }
        }
    }
Exemple #3
0
    void ToTransaction()
    {
        int        index = m_CurrentPlayer.GetCurrentCell();
        PlayerType owner = m_CurrentProperty.Owner();

        Props.PropertyType propertyType = m_CurrentProperty.Type();

        /* If Landed on Jail */
        if (propertyType == Props.PropertyType.Jail && m_CurrentProperty.Name() == "Jail")
        {
            app.view.GoToJail(m_CurrentPlayerIndex, m_CurrentPlayer);
            Go(HSM.State.CompleteTransaction);
            return;
        }
        else if (owner == PlayerType.Bank)
        {
            bool isAvailable = m_CurrentProperty.CanBuy();
            bool canAfford   = m_CurrentPlayer.CanPay(m_CurrentProperty.Cost());
            /* Certain Bank Properties like Tax, Community Cards, Jail, Chance etc or not available to buy*/
            if (isAvailable)
            {
                if (canAfford) /* If player can afford to buy a property show buy dialog */
                {
                    app.view.ShowBuyDialog(m_CurrentProperty);
                    if (m_CurrentPlayer.m_AI)
                    {
                        Invoke("OnBuySell", 0.5f);
                    }
                }
                else
                {
                    Go(HSM.State.CompleteTransaction);
                }
            }
            else
            {
                PayRent(index, new Dictionary <string, string>());
            }
        }
        else if (owner == m_CurrentPlayer.m_Player)
        {
            Go(HSM.State.CompleteTransaction);
        }
        else
        {
            Dictionary <string, string> param = new Dictionary <string, string>();
            if (propertyType == Props.PropertyType.Transport)
            {
                int count = app.model.GetBuildingsOwnedByPlayer(propertyType, owner);
                param.Add("count", count.ToString());
            }
            else if (propertyType == Props.PropertyType.Utility)
            {
                int count = app.model.GetBuildingsOwnedByPlayer(propertyType, owner);
                param.Add("count", count.ToString());
                param.Add("dicevalue", m_CurrentPlayer.m_LastDiceRoll.ToString());
            }
            else if (propertyType == Props.PropertyType.Turn)
            {
                GoPassed();
                Go(HSM.State.CompleteTransaction);
                return;
            }
            PayRent(index, param);
        }
    }