Esempio n. 1
0
 public void Initialize(NLand land)
 {
     topBar.color      = land.Group;
     textLandName.text = land.PropertyName;
     for (int i = 0; i <= Land.maxLevel; i++)
     {
         textRents[i].text = "$" + land.Rents[i].ToString();
     }
     textUpgradePrice.text  = "$" + land.UpgradePrice.ToString();
     textPurchasePrice.text = "$" + land.PurchasePrice.ToString();
 }
    public void Initialize(NProperty property, int side, int index, bool interactable)
    {
        _property = property;

        NLand land = property as NLand;

        if (land != null)
        {
            groupColor.color = land.Group;
        }
        label.text = property.PropertyName;

        _side  = side;
        _index = index;
        toggle.interactable = interactable;
    }
Esempio n. 3
0
    public void RPC_DegradeLand(int propertyID, PhotonPlayer caller)
    {
        if (!PhotonNetwork.isMasterClient)
        {
            return;
        }
        NLand   landToDegrade = NBoardManager.instance.Properties[propertyID] as NLand;
        NPlayer player        = FindGamePlayer(caller);

        if (landToDegrade.Degradable && landToDegrade.CurrentLevel > 0)
        {
            player.ChangeMoney(landToDegrade.UpgradePrice / 2);
            landToDegrade.Degrade();
            photonView.RPC("RPC_UpdateLandLevel", PhotonTargets.All, propertyID, landToDegrade.CurrentLevel);
        }
    }
 public IEnumerator WaitForPlayerConstructProperty()
 {
     while (buttonActivated)
     {
         if (Input.GetMouseButtonDown(0))
         {
             RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
             if (hit.collider != null && hit.collider.CompareTag("Land"))
             {
                 NLand land = hit.collider.GetComponent <NLand>();
                 if (NPlayer.thisPlayer.Properties.Contains(land))
                 {
                     //NPlayer.thisPlayer.Construct(land);
                 }
             }
         }
         yield return(null);
     }
 }
Esempio n. 5
0
    public void RPC_UpgradeLand(int propertyID, PhotonPlayer caller)
    {
        if (!PhotonNetwork.isMasterClient)
        {
            return;
        }
        NLand   landToUpgrade = NBoardManager.instance.Properties[propertyID] as NLand;
        NPlayer player        = FindGamePlayer(caller);

        //Debug.Log(caller.NickName + " wants to upgrade " + landToUpgrade.PropertyName);

        if (player.CurrentMoney < landToUpgrade.UpgradePrice || landToUpgrade.IsMortgaged)
        {
            return;
        }
        if (landToUpgrade.Upgradable && landToUpgrade.CurrentLevel < NLand.maxLevel)
        {
            player.ChangeMoney(-landToUpgrade.UpgradePrice);
            landToUpgrade.Upgrade();
            photonView.RPC("RPC_UpdateLandLevel", PhotonTargets.All, propertyID, landToUpgrade.CurrentLevel);
        }
    }
    NLand CreateLand(string name, int purchasePrice, int updagradePrice, int[] tollFees, Color groupColor,
                     Vector3 pos, Quaternion rotation, float scale)
    {
        NLand land = CreateSpace(_spaceTypes["land"], pos, rotation, scale) as NLand;

        // Set the text
        TextMesh[] textMesh = land.GetComponentsInChildren <TextMesh>();
        textMesh[0].text = name;
        textMesh[1].text = purchasePrice.ToString();

        // Set the color
        SpriteRenderer[] sr = land.GetComponentsInChildren <SpriteRenderer>();
        sr[0].color = landBgColor;
        sr[1].color = groupColor;

        // set owner marker position
        Vector3 omp = pos + Quaternion.AngleAxis(land.gameObject.transform.rotation.eulerAngles.z, Vector3.forward) * ownerMarkerOffset;

        land.OwnerMarkerPos = omp;

        land.Initialize(name, _properties.Count, purchasePrice, updagradePrice, tollFees, groupColor, landBgColor, mortgageBgColor);
        return(land);
    }
    public IEnumerator WaitForPlayerSelectProperty(int buttonIndex)
    {
        while (buttonActivated)
        {
            if (Input.GetMouseButtonDown(0))
            {
                RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);
                if (hit.collider != null && hit.collider.CompareTag("Land"))
                {
                    NLand land = hit.collider.GetComponent <NLand>();
                    if (NPlayer.thisPlayer.Properties.Contains(land))
                    {
                        switch (buttonIndex)
                        {
                        case 1:
                            NPlayerController.instance.UpgradeLand(land.PropertyID, PhotonNetwork.player);
                            break;

                        case 2:
                            NPlayerController.instance.MortgageProperty(land.PropertyID, PhotonNetwork.player);
                            break;

                        case 3:
                            NPlayerController.instance.DegradeLand(land.PropertyID, PhotonNetwork.player);
                            break;

                        case 4:
                            NPlayerController.instance.RedeemProperty(land.PropertyID, PhotonNetwork.player);
                            break;
                        }
                    }
                }
            }
            yield return(null);
        }
    }
Esempio n. 8
0
    public void RPC_UpdateLandLevel(int propertyID, int newLevel)
    {
        NLand land = NBoardManager.instance.Properties[propertyID] as NLand;

        land.SetLevelText(newLevel);
    }
    public void LoadMap(string fileName)
    {
        XDocument xdoc;

        xdoc = XDocument.Load("Assets/StreamingAssets/Maps/" + fileName);
        XElement root  = xdoc.Root;
        var      items = root.Elements("space");

        Vector3    pos = startPos;
        Vector3    increment = new Vector3(), squareIncrement = new Vector3();
        Quaternion rot = Quaternion.identity;

        int edge = 0;

        foreach (XElement item in items)
        {
            string type = item.Attribute("type").Value;
            if (type == "go" || type == "jail" || type == "parking" || type == "gotojail")
            { // TO-DO: algorithm needs improving :(
                // making some parameters
                int a = edge % 2, b = (edge + 1) % 2;
                int c = 0, d = 0;
                if (edge == 0 || edge == 3)
                {
                    c = -1;
                }
                else
                {
                    c = 1;
                }
                if (edge == 1)
                {
                    d = -1;
                }
                else
                {
                    d = 1;
                }

                // position offset
                if (edge > 0)
                {
                    pos += new Vector3(a * d * (spaceHeight - spaceWidth) / 2 * scale, b * d * (spaceHeight - spaceWidth) / 2 * scale, 0);
                }

                // Create the square space
                _spaces.Add(CreateSpace(_spaceTypes[type], pos, Quaternion.identity, scale));

                // calculating increments for the next edge
                increment       = new Vector3(b * c * spaceWidth * scale, a * c * spaceWidth * scale, 0);
                squareIncrement = new Vector3(b * c * (spaceHeight + spaceWidth) / 2 * scale, a * c * (spaceHeight + spaceWidth) / 2 * scale, 0);

                pos += squareIncrement;
                rot  = Quaternion.Euler(0, 0, (4 - edge) * 90);
                edge++;
            }
            else
            {
                if (type == "land")
                {
                    string pName = item.Element("name").Value;
                    Color  gpColor;
                    ColorUtility.TryParseHtmlString(item.Element("group").Value, out gpColor);
                    int      pPrice    = int.Parse(item.Element("purchasePrice").Value);
                    int      uPrice    = int.Parse(item.Element("upgradePrice").Value);
                    int[]    tolls     = new int[6];
                    XElement tollItems = item.Element("toll");
                    for (int i = 0; i <= 5; i++)
                    {
                        tolls[i] = int.Parse(tollItems.Element("lvl" + i).Value);
                    }
                    NLand newLand = CreateLand(pName, pPrice, uPrice, tolls, gpColor, pos, rot, scale);
                    _spaces.Add(newLand);
                    _properties.Add(newLand);
                    if (!groups.ContainsKey(gpColor))
                    {
                        List <NLand> landList = new List <NLand>();
                        landList.Add(newLand);
                        groups.Add(gpColor, landList);
                    }
                    else
                    {
                        groups[gpColor].Add(newLand);
                    }
                }
                else if (type == "railroad")
                {
                    string    name        = item.Element("name").Value;
                    int       pPrice      = int.Parse(item.Element("purchasePrice").Value);
                    int       initToll    = int.Parse(item.Element("initialToll").Value);
                    NRailroad newRailroad = CreateRailroad(name, pPrice, initToll, pos, rot, scale);
                    _spaces.Add(newRailroad);
                    _properties.Add(newRailroad);
                }
                else if (type == "spinner" || type == "chest" || type == "chance" || type == "parkingfee")
                {
                    _spaces.Add(CreateSpace(_spaceTypes[type], pos, rot, scale));
                }
                pos += increment;
            }
            numSpaces++;
        }
    }