Inheritance: MonoBehaviour
Example #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);
        }
    }
Example #2
0
 void Start()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Example #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;
        }
    }
Example #5
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();
        }
    }
Example #6
0
    ///////////////////////////

    //////////////////////////////////////////////////////////////////////////

    public override void InitializeAgent()
    {
        //Debug.LogWarning("INIT CALLED");
        infoScript = InfoScript.instance;

        base.InitializeAgent();

        _rayPercept = GetComponent <RayPerception>();
        agentRB     = GetComponent <Rigidbody>();
        _renderer   = GetComponent <MeshRenderer>();

        _moveSpeed   = infoScript.moveSpeed_playerAgent;
        _turnDegree  = infoScript.turnDegree_playerAgent;
        _rayDistance = infoScript.rayDistacne_agent;
        _shotAngle   = infoScript.shotDegree;
        _shotRange   = infoScript.shotRange;

        _hitDmg = infoScript.dmg_playerAgent;
        //_rayAngle = infoScript.rayAngle_agent;
        _hp = infoScript.fullHp_playerAgent;
        _renderer.material = infoScript.GetHP_Material(false, _hp);

        _shotCoolTime = infoScript.shotCoolTime_playerAgent;
        _curState     = AgentState.shotReady;

        ResetAgentValue();
    }
Example #7
0
    // Use this for initialization
    void Start()
    {
        GameObject GameController = GameObject.FindGameObjectWithTag ("GameController");
        gameController = GameController.GetComponent<GameController> ();   //GameController receives script from GameController gameobject

        GameObject InfoText = GameObject.FindGameObjectWithTag("InfoText"); //Finds InfoText  gameobject
        InfoScript = InfoText.GetComponent<InfoScript> ();				  //InfoScript receives script from InfoText gameobject
    }
Example #8
0
    private InfoScript InfoScript;     //Used in the void Start to hold reference to the script attached to InfoText gameobject

    // Use this for initialization
    void Start()
    {
        target = Player.transform;

        GameObject InfoText = GameObject.FindGameObjectWithTag("InfoText");         //Finds ScoreText  gameobject

        InfoScript = InfoText.GetComponent <InfoScript> ();                         //InfoScript receives script from InfoText gameobject
    }
Example #9
0
    // Use this for initialization
    void Start()
    {
        GameObject InfoText = GameObject.FindGameObjectWithTag("InfoText"); //Finds InfoText  gameobject
         InfoScript = InfoText.GetComponent<InfoScript> ();	                 //InfoScript receives script from InfoText gameobject

         Player = GameObject.FindGameObjectWithTag ("Player"); // Finds Player's gameobject so it can be used in the script
         playerController = Player.GetComponent<PlayerController> ();
    }
Example #10
0
    // Use this for initialization
    void Start()
    {
        GameObject Player = GameObject.FindGameObjectWithTag ("Player"); // Finds Player's gameobject so it can be used in the script
        target = Player.transform;

        GameObject InfoText = GameObject.FindGameObjectWithTag("InfoText"); //Finds InfoText  gameobject
        InfoScript = InfoText.GetComponent<InfoScript> ();                 //ScoreScript receives script from InfoText gameobject
    }
Example #11
0
 public static InfoScript instance()
 {
     if (instance_ == null)
     {
         instance_ = GameObject.FindObjectOfType <InfoScript>();
     }
     return(instance_);
 }
Example #12
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
 }
Example #13
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);
    }
Example #14
0
    private InfoScript InfoScript;     //Used in the void Start to hold reference to the script attached to InfoText gameobject

    // Use this for initialization
    void Start()
    {
        GameObject InfoText = GameObject.FindGameObjectWithTag("InfoText");          //Finds InfoText  gameobject

        InfoScript = InfoText.GetComponent <InfoScript> ();                          //InfoScript receives script from InfoText gameobject


        Player           = GameObject.FindGameObjectWithTag("Player"); // Finds Player's gameobject so it can be used in the script
        playerController = Player.GetComponent <PlayerController> ();
    }
Example #15
0
    ////////////////////////////////////////////////////////////////////////////////

    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }

        _agentMatCount  = agentHpMat.Length;
        _zombieMatCount = zombieHpMat.Length;
    }
Example #16
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);
        }
    }
Example #17
0
    private InfoScript InfoScript;     //Used in the void Start to hold reference to the script attached to InfoText gameobject

    // Use this for initialization
    void Start()
    {
        GameObject GameController = GameObject.FindGameObjectWithTag("GameController");

        gameController = GameController.GetComponent <GameController> ();          //GameController receives script from GameController gameobject

        GameObject InfoText = GameObject.FindGameObjectWithTag("InfoText");        //Finds InfoText  gameobject

        InfoScript = InfoText.GetComponent <InfoScript> ();                        //InfoScript receives script from InfoText gameobject
    }
Example #18
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;
    }
Example #19
0
    private InfoScript InfoScript;     //Used in the void Start to hold reference to the script attached to InfoText gameobject

    // Use this for initialization
    void Start()
    {
        GameObject Player = GameObject.FindGameObjectWithTag("Player");          // Finds Player's gameobject so it can be used in the script

        target = Player.transform;


        GameObject InfoText = GameObject.FindGameObjectWithTag("InfoText");        //Finds InfoText  gameobject

        InfoScript = InfoText.GetComponent <InfoScript> ();                        //ScoreScript receives script from InfoText gameobject
    }
Example #20
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();
    }
Example #21
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!");
     }
 }
Example #22
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);
        }
    }
Example #23
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;
     }
 }
Example #24
0
    void Awake()
    {
        if (info == null)
        {
            DontDestroyOnLoad(gameObject);
            info = this;
        }

        else if (info != this)
        {
            Destroy(gameObject);
        }
    }
Example #25
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);
    }
Example #26
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%!");
        }
    }
Example #27
0
    void SetZombieInitValue()
    {
        InfoScript infoScript = InfoScript.instance;

        _moveSpeed         = infoScript.moveSpeed_zombie;
        _turnSpeed         = infoScript.turnDegree_zombie;
        _hitDmg            = infoScript.dmg_zombie;
        _hp                = infoScript.fullHp_zombie;
        _renderer.material = infoScript.GetHP_Material(true, _hp);
        _attackCooltime    = infoScript.coolTime_zombie;
        _prevAttackTime    = 0f;
        _zombieState       = ZombieState.attackReady;

        _isDead = false; // TODO : change set this in mgr (why? episiode reset)
    }
Example #28
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.");
        }
    }
Example #29
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!");
        }
    }
Example #30
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!");
        }
    }
Example #31
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();
    }
Example #32
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);
        }
    }
Example #33
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();
    }
Example #34
0
    // Use this for initialization
    void Start()
    {
        target = Player.transform;

        GameObject InfoText = GameObject.FindGameObjectWithTag("InfoText"); //Finds ScoreText  gameobject
        InfoScript = InfoText.GetComponent<InfoScript> ();				   //InfoScript receives script from InfoText gameobject
    }