示例#1
0
    private void restOfActivate()
    {
        bool?response = ModalPopup.response;

        // If they did want to buy
        if (response == true)
        {
            GameObject player     = gm.GetComponent <GameManagerScript>().GetCurrentPlayer();
            int        playerCash = player.GetComponent <PlayerScript>().GetCash();

            if (playerCash < buyCost)
            {
                InfoScript.instance().Displayer("You don't have enough money");
                return;
            }

            // Update player's cash and add to their ownership
            player.GetComponent <PlayerScript>().RemvCash(buyCost);
            player.GetComponent <PlayerScript>().GetOwnedTiles().Add(gameObject);
            player.GetComponent <PlayerScript>().IncNumProp();
            this.owner = player;
            InfoScript.instance().Displayer(gm.GetCurrentPlayer().GetComponent <PlayerScript>().GetName() + " has bought " + tileName + "!");
        }
        else
        {
            InfoScript.instance().Displayer(gm.GetCurrentPlayer().GetComponent <PlayerScript>().GetName() + "didn't buy" + tileName);
        }
    }
示例#2
0
    private void restOfActivate()
    {
        bool?response = ModalPopup.response;

        if (response == true)
        {
            RemvCash(50);
            timeInJail = 0;
            state      = State.Active;
            InfoScript.instance().Displayer("You're free, roll to advance.");
            return;
        }

        // Atempt to roll doubles
        lastRolled = die.RollDie();
        if (die.isDouble())
        {
            InfoScript.instance().Displayer("Rolled doubles and broke out of jail!");
            timeInJail = 0;
            // Update location to trigger Update()
            locationIndex += lastRolled;
            //impossible to hit go from this location
            state = State.Moving;
        }
        else
        {
            timeInJail++;
            InfoScript.instance().Displayer("Did not roll doubles, stay in jail!");
            gm.NextTurn();
        }
    }
示例#3
0
    // Upgrade the property
    public void Upgrade(int index)
    {
        // If it can be upgraded
        if (rentIndex >= rent.Length - 1)
        {
            InfoScript.instance().Displayer("You cannot upgrade further.");
            return;
        }
        else if (isMortgaged == true)
        {
            InfoScript.instance().Displayer("Cannot upgrade mortgaged property.");
            return;
        }

        // If player has enough money
        if (owner.GetComponent <PlayerScript>().GetCash() < upgradeCost)
        {
            InfoScript.instance().Displayer("Player doesn't have enough money to upgrade.");
            return;
        }


        owner.GetComponent <PlayerScript>().RemvCash(upgradeCost);
        rentIndex++;
        gm.GetTileButton(index).GetComponentInChildren <Text>().text = rentIndex.ToString();
    }
    // Handling pay me logic
    public void PayMe()
    {
        if (hasBeenPaid == true)
        {
            InfoScript.instance().Displayer("Player has already been charged.");
            return;
        }

        // If last player to go has landed on an owned property
        int lastPlayerLoc = playerList[lastPlayerIndex].GetComponent <PlayerScript>().GetLocIndex();

        // If tile doesn't implement IBuyTile, avoid error
        bool isOwned = false;

        try
        {
            isOwned = tilesList[lastPlayerLoc].GetComponent <IBuyTile>().IsOwned();
        }
        catch (Exception e)
        {
            InfoScript.instance().Displayer("This tile cannot be owned!");
        }

        // Pay money!
        if (isOwned)
        {
            tilesList[lastPlayerLoc].GetComponent <IBuyTile>().PayPlayer(playerList[lastPlayerIndex]);
            hasBeenPaid = true;
        }
    }
示例#5
0
 public override void Activate()
 {
     InfoScript.instance().Displayer(cardName + "\n" + text);
     gm.GetCurrentPlayer().GetComponent <PlayerScript>().SetLocIndex(0);
     gm.GetCurrentPlayer().GetComponent <PlayerScript>().transform.position = gm.GetTile(0).transform.position;
     gm.GetCurrentPlayer().GetComponent <PlayerScript>().AddCash(200);
     //make this a reference to go tile
 }
示例#6
0
    public override void Activate()
    {
        InfoScript.instance().Displayer(cardName + "\n" + text);
        int x = 0;

        //take 50 from every player and give to current player

        gm.GetCurrentPlayer().GetComponent <PlayerScript>().AddCash(x);
    }
示例#7
0
    // This property is now mortgaged.
    public void ToMortgaged()
    {
        if (rentIndex != 0)
        {
            InfoScript.instance().Displayer("You need to have no upgrades to mortgage.");
        }

        owner.GetComponent <PlayerScript>().AddCash(mortgageValue);
        isMortgaged = true;
    }
示例#8
0
    /*             TILESCRIPT INHERITANCE                */

    // Buying process
    public override void Activate()
    {
        InfoScript.instance().Displayer(gm.GetCurrentPlayer().GetComponent <PlayerScript>().GetName() + " has landed on " + tileName);
        // If the tile doesn't have an owner, ask to buy
        if (owner == null)
        {
            StartCoroutine(ModalPopup.instance().Dialog("Buy this property?"));
            Invoke("restOfActivate", 4);
        }
    }
示例#9
0
 // When trying to sell
 public void SellTile()
 {
     if (isMortgaged == false)
     {
         InfoScript.instance().Displayer("You're trying to mortgage " + tileName);
     }
     else
     {
         InfoScript.instance().Displayer(tileName + " is already mortgaged!");
     }
 }
示例#10
0
    /*             TILESCRIPT INHERITANCE                */

    // Buying process
    public override void Activate()
    {
        InfoScript.instance().Displayer(gm.GetCurrentPlayer().GetComponent <PlayerScript>().GetName() + " has landed on " + tileName);
        // If the tile doesn't have an owner, ask to buy
        if (owner == null)
        {
            //bool response = EditorUtility.DisplayDialog(tileName, ("Would you like to buy this tile for " + buyCost + "?"), "Yes", "No");
            StartCoroutine(ModalPopup.instance().Dialog("Buy this property?"));
            Invoke("restOfActivate", 4);
        }
    }
示例#11
0
 // REMOVE a value from cash
 public void RemvCash(int cash)
 {
     if (this.cash - cash < 0)
     {
         InfoScript.instance().Displayer("This player doesn't have enough money to pay");
     }
     else
     {
         this.cash -= cash;
     }
 }
示例#12
0
    // Ends player turn
    private void EndTurn()
    {
        if (cash <= 0 && numProperties <= 0)
        {
            InfoScript.instance().Displayer(playerName + " has lost the game!");
        }

        SetWaiting();
        //button.SetActive(false); // Client side
        gm.NextTurn();
    }
示例#13
0
    // Rolls two dice, upadtes previous die roll and possibly calls incDouble in gamemanager
    public int RollDie(int numSides)
    {
        die1 = Random.Range(1, numSides + 1);
        die2 = Random.Range(1, numSides + 1);
        if (isDouble())
        {
            gm.IncDouble();
        }

        InfoScript.instance().Displayer("Rolled: " + (die1 + die2) + (isDouble() ? " DOUBLE" : ""));

        return(die1 + die2);
    }
示例#14
0
    /*             TILESCRIPT INHERITANCE                */

    // Tax either 200 or 10%.
    public override void Activate()
    {
        if (gm.GetCurrentPlayer().GetComponent <PlayerScript>().GetCash() >= 200)
        {
            gm.GetCurrentPlayer().GetComponent <PlayerScript>().RemvCash(200);
            InfoScript.instance().Displayer("You've been taxed 200!");
        }
        else
        {
            int cash = gm.GetCurrentPlayer().GetComponent <PlayerScript>().GetCash();

            gm.GetCurrentPlayer().GetComponent <PlayerScript>().RemvCash(cash / 10);
            InfoScript.instance().Displayer("You've been taxed 10%!");
        }
    }
示例#15
0
    public void PressMortgageButton()
    {
        if (verifyOwner() == false)
        {
            return;
        }

        try
        {
            InfoScript.instance().Displayer("Mortgaged " + gm.GetComponent <GameManagerScript>().GetTile(lastTileIndex).GetComponent <TileScript>().GetName());
            gm.GetComponent <GameManagerScript>().GetTile(lastTileIndex).GetComponent <IBuyTile>().Mortgage();
        }
        catch (Exception e)
        {
            InfoScript.instance().Displayer("This tile cannot be mortgaged!");
        }
    }
示例#16
0
    // Method the sell button calls
    public void PressSellButton()
    {
        if (verifyOwner() == false)
        {
            return;
        }

        try
        {
            InfoScript.instance().Displayer("Sold upgrade on " + gm.GetComponent <GameManagerScript>().GetTile(lastTileIndex).GetComponent <TileScript>().GetName());
            gm.GetComponent <GameManagerScript>().GetTile(lastTileIndex).GetComponent <PropertyScript>().SellUpgrade(lastTileIndex);
        }
        catch (Exception e)
        {
            InfoScript.instance().Displayer("You cannot sell upgrades on this tile.");
        }
    }
示例#17
0
    // Upgrade prop
    public void PressUpgradeButton()
    {
        if (verifyOwner() == false)
        {
            return;
        }

        try
        {
            InfoScript.instance().Displayer("Bought upgrade on " + gm.GetComponent <GameManagerScript>().GetTile(lastTileIndex).GetComponent <TileScript>().GetName());
            gm.GetComponent <GameManagerScript>().GetTile(lastTileIndex).GetComponent <PropertyScript>().Upgrade(lastTileIndex);
        }
        catch (Exception e)
        {
            InfoScript.instance().Displayer("This tile cannot be upgraded!");
        }
    }
示例#18
0
    public void SellUpgrade(int index)
    {
        if (rentIndex <= 0)
        {
            InfoScript.instance().Displayer("There are no upgrades to sell.");
            return;
        }
        else if (isMortgaged == true)
        {
            InfoScript.instance().Displayer("Cannot sell upgrade on mortgaged property.");
            return;
        }

        // Give player cash
        owner.GetComponent <PlayerScript>().AddCash(upgradeCost / 2);

        rentIndex--;
        gm.GetTileButton(index).GetComponentInChildren <Text>().text = rentIndex.ToString();
    }
示例#19
0
    // if current player owns property
    public bool verifyOwner()
    {
        try
        {
            List <GameObject> tiles        = gm.GetCurrentPlayer().GetComponent <PlayerScript>().GetOwnedTiles();
            GameObject        selectedTile = gm.GetTile(lastTileIndex);

            if (tiles.Contains(selectedTile) == false)
            {
                InfoScript.instance().Displayer("You do not own this tile!");
                return(false);
            }

            return(true);
        }
        catch (Exception e)
        {
            return(false);
        }
    }
示例#20
0
    // Decides how to handle mortgaging
    public void Mortgage()
    {
        // Already mortgaged
        if (isMortgaged == true)
        {
            if (owner.GetComponent <PlayerScript>().GetCash() > mortgageValue + (mortgageValue / 10))
            {
                InfoScript.instance().Displayer("Bought back property from mortgage.");
                FromMortgaged();
                return;
            }
            else
            {
                InfoScript.instance().Displayer("You don't have enough money to buy from mortgage.");
                return;
            }
        }

        ToMortgaged();
    }
示例#21
0
    /*             TILESCRIPT INHERITANCE                */

    // Buy tile option
    public override void Activate()
    {
        InfoScript.instance().Displayer("Free spot!");
    }
示例#22
0
 //Pay the player when pay me button has been pressed
 public void PayPlayer(GameObject payer)
 {
     payer.GetComponent <PlayerScript>().RemvCash(GetRent());
     owner.GetComponent <PlayerScript>().AddCash(GetRent());
     InfoScript.instance().Displayer(payer.GetComponent <PlayerScript>().GetName() + " paid " + owner.GetComponent <PlayerScript>().GetName() + " " + GetRent());
 }
示例#23
0
 public override void Activate()
 {
     InfoScript.instance().Displayer(cardName + "\n" + text);
     gm.GetCurrentPlayer().GetComponent <PlayerScript>().AddCash(50);
 }
示例#24
0
    /*             TILESCRIPT INHERITANCE                */

    // standard activation method
    public override void Activate()
    {
        InfoScript.instance().Displayer("Just visiting jail");
    }
示例#25
0
    /*             TILESCRIPT INHERITANCE                */

    public override void Activate()
    {
        InfoScript.instance().Displayer("You're on GO!");
    }