public override void PayRent(Player player, PropertyTile property) { base.PayRent(player, property); if (property.Owner != null && property.Owner != player) { StreetTile streetProperty = property as StreetTile; ObjectValidator.NullObjectValidation(streetProperty, "Property instance should be a StreetTile"); int numberOfStreetsInDistrict = streetProperty.Owner.Properties .Count(tile => tile is StreetTile && ((StreetTile)tile).Color == streetProperty.Color); if (numberOfStreetsInDistrict == StreetTile.GetNumberOfStreetsInDistrict(streetProperty.Color)) { streetProperty.Owner.AddMoney(streetProperty.BaseRent * numberOfStreetsInDistrict); player.WidthdrawMoney(streetProperty.BaseRent * numberOfStreetsInDistrict); } else { streetProperty.Owner.AddMoney(streetProperty.BaseRent); player.WidthdrawMoney(streetProperty.BaseRent); } } }
// Start is called before the first frame update void Start() { streetWire = new GameObject("StreetWire"); GameObject streets = new GameObject("Streets"); GameObject sidewalks = new GameObject("Sidewalks"); GameObject traficLights = new GameObject("Sidewalks"); GameObject decorations = new GameObject("Decorations"); GameObject buildings = new GameObject("Buildings"); streets.transform.parent = streetWire.transform; sidewalks.transform.parent = streetWire.transform; decorations.transform.parent = streetWire.transform; traficLights.transform.parent = streetWire.transform; buildings.transform.parent = streetWire.transform; GameObject[] carListArray = Resources.LoadAll <GameObject>("Prefabs/Cars"); //reader(); // IF HERE FOR SCENARIOUS func(carListArray) if (useDummySim) { sim = new SimulationDummy(); } else { sim = new SimulationImpact(); } //Crossroad(carListArray); //Intersect(carListArray); //reader(); //BasicMap(carListArray); List <Edge> edg = map.edges; //Node n1 = new Node(new Vector3(5, 0, 0), true); //Node n2 = new Node(new Vector3(10, 0, 10), true); //edg.Add(new Edge(n1, n2, 1, 1, 60, "")); //Debug.Log(edg.Count); GameObject[] decorationListArray = Resources.LoadAll <GameObject>("Prefabs/Decorations"); List <GameObject> decorationList = decorationListArray.ToList(); System.Random rand = new System.Random(); GameObject[] buildingListArray = Resources.LoadAll <GameObject>("Prefabs/Buildings"); List <GameObject> buildingList = buildingListArray.ToList(); Vector3 tl = new Vector3(0, 0, 0); Vector3 br = new Vector3(0, 0, 0); foreach (Edge e in edg) { Debug.Log("asd"); StreetTile street = streetTiles[Math.Min(e.forwardLanes + e.backwardLanes - 1, 1)]; int prefsNum = (int)Math.Ceiling(e.length / street.length); for (int i = 0; i <= prefsNum; i++) { float x = e.startNode.position.x + (e.direction.x) * ((float)i / prefsNum); float z = e.startNode.position.z + (e.direction.z) * ((float)i / prefsNum); Quaternion rotation = Quaternion.AngleAxis(-90 + (float)Math.Atan2((e.direction.x), (e.direction.z)) * (180F / (float)Math.PI), Vector3.up); Vector3 pos = new Vector3(x, 0, z); if (x > tl.x) { tl.x = x; } if (z > tl.z) { tl.z = z; } if (x < br.x) { br.x = x; } if (z < br.z) { br.z = z; } Vector3 normal = Vector3.Cross(e.direction, new Vector3(0, 1, 0)).normalized; Vector3 decorOffset = normal * (street.width / 2 + 1); Vector3 buildingOffset = normal * (street.width / 2 + 2) * 2; bool complicatedEnd = map.nodeNeighbours[e.endNode.AddId].Count > 2; bool complicatedStart = map.nodeNeighbours[e.startNode.AddId].Count > 2; bool canBuild = (!complicatedStart || i > 2) && (!complicatedEnd || i < prefsNum - 2); Instantiate(street, pos, rotation, streets.transform); if (e.startNode.traficLight && (i == 0 || i == prefsNum)) { Instantiate(traficL, pos + decorOffset, rotation, traficLights.transform); } Instantiate(sidewalk, pos + decorOffset, rotation, sidewalks.transform); if (rand.NextDouble() < decorationChance && canBuild) { Instantiate(decorationList[UnityEngine.Random.Range(0, decorationList.Count)] , pos + decorOffset, rotation, decorations.transform); } if (rand.NextDouble() < buildingChance && canBuild) { Instantiate(buildingList[UnityEngine.Random.Range(0, buildingList.Count)] , pos + buildingOffset, rotation, buildings.transform); } rotation *= Quaternion.Euler(0, 180, 0); //right side Instantiate(sidewalk, pos - decorOffset, rotation, sidewalks.transform); if (rand.NextDouble() < decorationChance && canBuild) { Instantiate(decorationList[UnityEngine.Random.Range(0, decorationList.Count)] , pos - decorOffset, rotation, decorations.transform); } if (rand.NextDouble() < buildingChance && canBuild) { Instantiate(buildingList[UnityEngine.Random.Range(0, buildingList.Count)] , pos - buildingOffset, rotation, buildings.transform); } } } // int n = 40; // for (int x = (int)Math.Floor(br.x); x < (int)Math.Ceiling(tl.x);x += 50) { // for (int z = (int)Math.Floor(br.z); z < (int)Math.Ceiling(tl.z);z += 50) { // GameObject b = Instantiate(buildingList[UnityEngine.Random.Range(0, buildingList.Count)] // ,new Vector3(x, 0, z), Quaternion.identity, buildings.transform); // b.transform.localScale = new Vector3(1.5f,1.5f,1.5f); // } // } sim.Init(cars, map, tf); //sim.Init(cars, map, new TrafficLight(edgeS)); //Test1(); }