Beispiel #1
0
        public void CanDesearializeNeighborhood()
        {
            Neighborhood myNeighborhood = JsonConvert.DeserializeObject <Neighborhood>(neighborhood1data.ToString());

            Assert.IsTrue(myNeighborhood.id == 79);
            Trace.WriteLine(myNeighborhood.geometry.coordinates[0][0][0]);
        }
Beispiel #2
0
    private Vector3 camPos; //Camera position

    void Awake()
    {
        neighborhood = GetComponent <Neighborhood>();
        rigid        = GetComponent <Rigidbody>();
        pos          = Random.insideUnitSphere * Spawner.S.spawnRadius;

        Vector3 vel = Random.onUnitSphere * Spawner.S.velocity;

        rigid.velocity = vel;

        LookAhead();

        Color randColor = Color.black;

        while (randColor.r + randColor.g + randColor.b < 1.0f)
        {
            randColor = new Color(Random.value, Random.value, Random.value);
        }

        Renderer[] rends = gameObject.GetComponentsInChildren <Renderer>();
        foreach (Renderer r in rends)
        {
            r.material.color = randColor;
        }

        TrailRenderer tRend = GetComponent <TrailRenderer>();

        tRend.material.SetColor("_TintColor", randColor);
    }
Beispiel #3
0
        public async Task <IActionResult> Get([FromRoute] int id)
        {
            using (SqlConnection conn = Connection)
            {
                conn.Open();
                using (SqlCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandText = @"
                     SELECT Id, NeighborhoodName, NeighborhoodId FROM Neighborhood
                        WHERE Id = @id";
                    cmd.Parameters.Add(new SqlParameter("@id", id));
                    SqlDataReader reader = cmd.ExecuteReader();

                    Neighborhood hood = null;

                    if (reader.Read())
                    {
                        hood = new Neighborhood
                        {
                            Id = reader.GetInt32(reader.GetOrdinal("Id")),
                            NeighborhoodName = reader.GetString(reader.GetOrdinal("NeighborhoodName")),
                        };
                    }
                    reader.Close();

                    return(Ok(hood));
                }
            }
        }
Beispiel #4
0
    public bool SellToDealer(Buyer buyer, Neighborhood block)
    {
        var canSell = true;

        if (block.Respect[ID] < 0.2f)
            return false;
        foreach (var t in buyer.TypesBuying)
        {
            if (WeaponStock.Where(w => w.Type == t.Key).Count() < t.Value)
            {
                canSell = false;
                break;
            }
        }
        if (canSell)
        {
            if(!ContractedBuyers.ContainsKey(block))
            {
                ContractedBuyers.Add(block, new List<Buyer>());
            }
            ContractedBuyers[block].Add(buyer);

        }
        return canSell;
    }
Beispiel #5
0
 /// <summary>
 /// Bestemmer nabolag
 /// </summary>
 /// <param name="neighborhood"></param>
 /// <author>Mathias Poulsen</author>
 public void SetNeighborhood(Neighborhood neighborhood)
 {
     if (activeCase.Neighborhood != neighborhood)
     {
         activeCase.Neighborhood = neighborhood;
     }
 }
Beispiel #6
0
    // Use this for instantiation
    void Awake()
    {
        neighborhood = GetComponent <Neighborhood>();
        rigid        = GetComponent <Rigidbody>();

        // Set a random initial position
        pos = Random.insideUnitSphere * Spawner.s.spawnRadius;

        // Set a random initial velocity
        Vector3 vel = Random.onUnitSphere * Spawner.s.velocity;

        rigid.velocity = vel;

        lookAhead();

        // Give the Boid a random color, but make sure it's not too dark
        Color randColor = Color.black;

        while (randColor.r + randColor.g + randColor.b < 1.0f)
        {
            randColor = new Color(Random.value, Random.value, Random.value);
        }
        Renderer[] rends = gameObject.GetComponentsInChildren <Renderer>();
        foreach (Renderer r in rends)
        {
            r.material.color = randColor;
        }
        TrailRenderer tRend = GetComponent <TrailRenderer>();

        tRend.material.SetColor("_TintColor", randColor);
    }
Beispiel #7
0
        public Neighborhood GetNeighborhoodById(int Id)
        {
            using (SqlConnection conn = Connection)
            {
                conn.Open();
                using (SqlCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandText = @"SELECT Id, Name
                                    FROM Neighborhood";

                    SqlDataReader reader = cmd.ExecuteReader();

                    if (reader.Read())
                    {
                        Neighborhood neighborhood = new Neighborhood
                        {
                            Id   = reader.GetInt32(reader.GetOrdinal("Id")),
                            Name = reader.GetString(reader.GetOrdinal("Name"))
                        };
                        reader.Close();
                        return(neighborhood);
                    }
                    else
                    {
                        reader.Close();
                        return(null);
                    }
                }
            }
        }
Beispiel #8
0
    //użyj tej funkcji do inicjalizacji
    void Awake()
    {
        neighborhood = GetComponent <Neighborhood>();
        rigid        = GetComponent <Rigidbody>();
        //ustala losowe położenie początkowe
        pos = Random.insideUnitSphere * Spawner.S.spawnRadius;
        //ustal losową prędkość początkową
        Vector3 vel = Random.onUnitSphere * Spawner.S.velocity;

        rigid.velocity = vel;
        LookAhead();
        //zdefiniuj losowy kolor dla boida, ale upewnij się, że niej zbyt ciemny
        Color randColor = Color.black;

        while (randColor.r + randColor.g + randColor.b < 1.0f)
        {
            randColor = new Color(Random.value, Random.value, Random.value);
        }
        Renderer[] rends = gameObject.GetComponentsInChildren <Renderer>();
        foreach (Renderer r in rends)
        {
            r.material.color = randColor;
        }
        TrailRenderer tRend = GetComponent <TrailRenderer>();

        tRend.material.SetColor("_TintColor", randColor);
    }
Beispiel #9
0
        public ActionResult Create(Neighborhood neighborhood)
        {
            try
            {
                using (SqlConnection conn = Connection)
                {
                    conn.Open();
                    using (SqlCommand cmd = conn.CreateCommand())
                    {
                        cmd.CommandText = @"INSERT INTO Neighborhood (Name)
                                            OUTPUT INSERTED.Id
                                            VALUES (@name)";

                        cmd.Parameters.Add(new SqlParameter("@name", neighborhood.Name));

                        var id = (int)cmd.ExecuteScalar();
                        neighborhood.Id = id;
                        return(RedirectToAction(nameof(Index)));
                    }
                }
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
Beispiel #10
0
        /// <summary>
        /// Test whether a value is in a set.
        /// </summary>
        /// <param name="v">Value to test.</param>
        /// <returns>Whether that value is present.</returns>
        public override object Contains(params object[] _v)
        {
            int          v    = (int)_v[0];
            Neighborhood hood = Find(v);

            return(hood.currNode != null);
        }
Beispiel #11
0
        public ActionResult Edit(int id, Neighborhood neighborhood)
        {
            try
            {
                using (SqlConnection conn = Connection)
                {
                    conn.Open();
                    using (SqlCommand cmd = conn.CreateCommand())
                    {
                        cmd.CommandText = @"UPDATE Neighborhood
                                           SET Name = @name
                                               WHERE Id = @id";

                        cmd.Parameters.Add(new SqlParameter("@name", neighborhood.Name));

                        cmd.Parameters.Add(new SqlParameter("@id", id));

                        int rowsAffected = cmd.ExecuteNonQuery();
                        if (rowsAffected > 0)
                        {
                            return(RedirectToAction(nameof(Index)));
                        }
                        throw new Exception("No rows affected");
                    };
                }
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
Beispiel #12
0
        private Neighborhood GetNeighborhoodById(int id)
        {
            using (SqlConnection conn = Connection)
            {
                conn.Open();
                using (SqlCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandText = "SELECT n.Id, n.Name FROM Neighborhood n WHERE n.Id = @id";

                    cmd.Parameters.Add(new SqlParameter("@id", id));

                    var          reader       = cmd.ExecuteReader();
                    Neighborhood neighborhood = null;

                    if (reader.Read())
                    {
                        neighborhood = new Neighborhood()
                        {
                            Id   = reader.GetInt32(reader.GetOrdinal("Id")),
                            Name = reader.GetString(reader.GetOrdinal("Name"))
                        };
                    }
                    reader.Close();
                    return(neighborhood);
                }
            }
        }
Beispiel #13
0
        public Neighborhood GetNeighborhoodById(int id)
        {
            using (SqlConnection conn = Connection)
            {
                conn.Open();
                using (SqlCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandText = "SELECT Name FROM Neighborhood WHERE Id = @id";
                    cmd.Parameters.Add(new SqlParameter("@id", id));
                    SqlDataReader reader = cmd.ExecuteReader();

                    Neighborhood neighborhood = null;

                    if (reader.Read())
                    {
                        neighborhood = new Neighborhood
                        {
                            Id   = id,
                            Name = reader.GetString(reader.GetOrdinal("Name"))
                        };
                    }

                    reader.Close();

                    return(neighborhood);
                }
            }
        }
Beispiel #14
0
        // GET: Walkers/Details/5
        public ActionResult Details(int id)
        {
            Walker       walker    = _walkerRepo.GetWalkerById(id);
            List <Walk>  walks     = _walkRepo.GetWalksById(id);
            Neighborhood hood      = _neighborRepo.GetNeighborhoodById(walker.NeighborhoodId);
            string       walkTotal = _walkRepo.WalkTime(walks);
            //int walkId = walk.DogId;
            //Owner owner = _walkRepo.GetOwner(walk.DogId);
            //Owner owner = _ownerRepo.GetOwnerByDog;

            ProfileViewModel vm = new ProfileViewModel()
            {
                Walker    = walker,
                Walks     = walks,
                Hood      = hood,
                WalkTotal = walkTotal
            };


            if (vm.Walker == null)
            {
                return(NotFound());
            }

            return(View(vm));
        }
Beispiel #15
0
        public void Delete(int neighborhoodId)
        {
            Neighborhood neighborhood = GetById(neighborhoodId);

            _neighborhoodRepository.Delete(neighborhood);
            _unitOfWork.Complete();
        }
Beispiel #16
0
        public Field(int x, int y, Neighborhood n = Neighborhood.Moore, int neighborhoodSize = 1)
        {
            RenderOneCommand = new RelayCommand(RenderOne);

            Neighborhood     = n;
            NeighborhoodSize = neighborhoodSize;
            MaxX             = x;
            MaxY             = y;

            Cells = new Cell[x, y];
            for (int i = 0; i < x; i++)
            {
                for (int j = 0; j < y; j++)
                {
                    Cells[i, j] = new Cell();
                }
            }
            for (int i = 0; i < x; i++)
            {
                for (int j = 0; j < y; j++)
                {
                    CalculateNeighbors(i, j);
                }
            }
        }
        public async Task <IActionResult> Edit(int id, [Bind("NeighborhoodId,Name,CommuneId")] Neighborhood neighborhood)
        {
            if (id != neighborhood.NeighborhoodId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(neighborhood);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!NeighborhoodExists(neighborhood.NeighborhoodId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CommuneId"] = new SelectList(_context.Commune, "CommuneId", "CommuneId", neighborhood.CommuneId);
            return(View(neighborhood));
        }
        /// <summary>
        /// Updates the normals on this <see cref="TileMesh"/> so that they align
        /// with the passed neighboring <see cref="Tile"/>s. Each Tile's MeshManager
        /// must have a non-null ActiveTile.
        /// </summary>
        public void CalculateNeighboringNormals(Neighborhood neighbors)
        {
            Neighborhood n = neighbors;

            if (n.Up != null)
            {
                //incr x, z[res]
                AverageNormalsWith(n.Up.MeshManager, Orientation.Up);
            }
            if (n.Right != null)
            {
                //x[res], incr z
                AverageNormalsWith(n.Right.MeshManager, Orientation.Right);
            }
            if (n.Down != null)
            {
                //incr x, z[0]
                AverageNormalsWith(n.Down.MeshManager, Orientation.Down);
            }
            if (n.Left != null)
            {
                //x[0], incr z
                AverageNormalsWith(n.Left.MeshManager, Orientation.Left);
            }
        }
Beispiel #19
0
        public List <Neighborhood> GetAll()
        {
            using (SqlConnection conn = Connection)
            {
                conn.Open();
                using (SqlCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandText = @"SELECT Id, Name FROM Neighborhood";

                    SqlDataReader reader = cmd.ExecuteReader();

                    List <Neighborhood> neighborhoods = new List <Neighborhood>();

                    while (reader.Read())
                    {
                        Neighborhood neighborhood = new Neighborhood()
                        {
                            Id   = reader.GetInt32(reader.GetOrdinal("Id")),
                            Area = reader.GetString(reader.GetOrdinal("Name"))
                        };
                        neighborhoods.Add(neighborhood);
                    }

                    reader.Close();

                    return(neighborhoods);
                }
            }
        }
Beispiel #20
0
        public Neighborhood GetNeighborhoodById(int id)
        {
            using (SqlConnection conn = Connection)
            {
                conn.Open();
                using (SqlCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandText = @"SELECT Id, Name FROM Neighborhood WHERE Id = @id";
                    cmd.Parameters.AddWithValue("@id", id);
                    SqlDataReader reader = cmd.ExecuteReader();

                    if (reader.Read())
                    {
                        Neighborhood neighborhood = new Neighborhood()
                        {
                            Id   = reader.GetInt32(reader.GetOrdinal("Id")),
                            Area = reader.GetString(reader.GetOrdinal("Name"))
                        };
                        reader.Close();
                        return(neighborhood);
                    }
                    else
                    {
                        reader.Close();
                        return(null);
                    }
                }
            }
        }
Beispiel #21
0
        /// <summary>
        /// todo write description
        /// </summary>
        /// <param name="neighbors"></param>
        /// <param name="hideTerrain">Hide the terrain when welding neighbors?</param>
        /// <param name="onComplete">Called when the heightmap has finished applying</param>
        private void WeldNeighbors(Neighborhood neighbors, bool hideTerrain)
        {
            if (HeightmapResolution == 0)
            {
                return;
            }

            if (!(neighbors.Right == null || neighbors.Right.MeshManager.HeightmapResolution == 0))
            {
                // x[1 -> max] z[max]
                WeldEdges(neighbors.Right, true, false, hideTerrain);
            }
            if (!(neighbors.Up == null || neighbors.Up.MeshManager.HeightmapResolution == 0))
            {
                // x[max] z[1 -> max]
                WeldEdges(neighbors.Up, false, false, hideTerrain);
            }
            if (!(neighbors.Left == null || neighbors.Left.MeshManager.HeightmapResolution == 0))
            {
                // x[1 -> max] z[1]
                WeldEdges(neighbors.Left, true, true, hideTerrain);
            }
            if (!(neighbors.Down == null || neighbors.Down.MeshManager.HeightmapResolution == 0))
            {
                // x[1] z[1 -> max]
                WeldEdges(neighbors.Down, false, true, hideTerrain);
            }

            SetTerrainHeightmap();
        }
Beispiel #22
0
    void Awake()
    {
        rigidBody    = GetComponent <Rigidbody>();
        neighborhood = GetComponent <Neighborhood>();

        //Select a random starting position
        Position = Random.insideUnitSphere * SpawnManager.Instance.spawnRadius;

        //Select a random initial speed
        Vector3 vel = Random.onUnitSphere * SpawnManager.Instance.velocity;

        rigidBody.velocity = vel;

        //Color the pack element in a random color
        Color randColor = Color.black;

        while (randColor.r + randColor.g + randColor.b < 1.0f)
        {
            randColor = new Color(Random.value, Random.value, Random.value);
        }
        Renderer[] rends = gameObject.GetComponentsInChildren <Renderer>();
        foreach (Renderer r in rends)
        {
            r.material.color = randColor;
        }
    }
Beispiel #23
0
        public List <Neighborhood> GetAllNeighborhoods()
        {
            using (SqlConnection conn = Connection)
            {
                conn.Open();

                using SqlCommand cmd = conn.CreateCommand();
                cmd.CommandText      = "SELECT Id, Name FROM Neighborhood";

                SqlDataReader reader = cmd.ExecuteReader();

                List <Neighborhood> neighborhoods = new List <Neighborhood>();

                while (reader.Read())
                {
                    int idColumnPosition = reader.GetOrdinal("Id");
                    int idValue          = reader.GetInt32(idColumnPosition);

                    int    nameColumnPosition = reader.GetOrdinal("Name");
                    string nameValue          = reader.GetString(nameColumnPosition);

                    Neighborhood neighborhood = new Neighborhood
                    {
                        Id   = idValue,
                        Name = nameValue
                    };

                    neighborhoods.Add(neighborhood);
                }

                reader.Close();

                return(neighborhoods);
            }
        }
Beispiel #24
0
    // Update is called once per frame
    void Update()
    {
        if (UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject())
        {
            return;
        }
        RaycastHit hit;
        var        ray    = Camera.main.ScreenPointToRay(Input.mousePosition);
        var        hasHit = false;

        if (hasHit = Physics.Raycast(ray, out hit, 100.0f))
        {
            if (hit.collider.tag == "Neighborhood")
            {
                var block = hit.collider.GetComponent <Neighborhood>();
                foreach (var c in InfoPanel.GetComponentsInChildren <Text>())
                {
                    switch (c.gameObject.name)
                    {
                    case "Name":
                        c.text = block.Name;
                        break;

                    case "DealerName":
                        if (block.FriendlyDealer != null)
                        {
                            c.text = block.FriendlyDealer.Name;
                        }
                        else
                        {
                            c.text = "Unoccupied";
                        }
                        break;

                    case "Respect":
                        if (block.FriendlyDealer != null)
                        {
                            c.text = Mathf.RoundToInt(block.Respect[block.FriendlyDealer.ID] * 100f).ToString() + "%";
                        }
                        else
                        {
                            c.text = "??%";
                        }
                        break;
                    }
                }
                if (Input.GetMouseButtonUp(0))
                {
                    SelectedNeighborhood = block;
                    BuyerPanel.SetActive(true);
                    //Camera.main.GetComponent<CameraInteraction>().CenterPoint = new Vector3(block.transform.position.x, 0, block.transform.position.z);
                }
            }
        }
        if (!hasHit && Input.GetMouseButtonDown(0))
        {
            SelectedNeighborhood = null;
            BuyerPanel.SetActive(false);
        }
    }
Beispiel #25
0
 public void DeleteNeighborhood(Neighborhood entity)
 {
     if (entity != null)
     {
         repository.Delete(entity);
     }
 }
Beispiel #26
0
    /// <summary>
    /// Returns the data associated with the building, does not do anything with buttons
    /// </summary>
    /// <returns>The readout.</returns>
    public override string getReadoutText(NetworkInstanceId pid)
    {
        string s;

        updateRent();
        modManager.clearButtons();
        string       ownerName = "";
        Neighborhood tmp       = getNeighborhood();

        if (!validOwner())
        {
            ownerName = "None";
        }
        else
        {
            ownerName = getPlayer(owner).getName();
        }
        s = "Type: " + buildingTypes [type] + "\nName : " + buildingName + "\nOwner: " + ownerName + "\nPrice: " + getCost();
        if (tmp != null)
        {
            s += "\nNeighborhood: " + tmp.buildingName;
        }
        if (notForSale)
        {
            s += "\nNot for sale";
        }
        else
        {
            s += "\n<color=#00ff00ff>For Sale</color>";
        }
        s += "\nAttractiveness: " + getAttractiveness();
        return(s);
    }
Beispiel #27
0
 public void InsertNeighborhood(Neighborhood entity)
 {
     if (entity != null)
     {
         repository.Insert(entity);
     }
 }
Beispiel #28
0
 public void UpdateNeighborhood(Neighborhood entity)
 {
     if (entity != null)
     {
         repository.Update(entity);
     }
 }
Beispiel #29
0
        /// <summary>
        /// Finds the interior contours of the area.
        /// </summary>
        /// <param name="area">The area to analyze.</param>
        /// <param name="neighborhood">What type of neighborhood to segerate contours by.</param>
        /// <returns>
        /// A list of the contours. Each index corresponds to the distance from the outer edge (0 is right next to it, 1 is futher inside, etc).
        /// </returns>
        public static IReadOnlyList <IReadOnlySet <Position> > DetermineInteriorContours(
            this ConnectedArea area,
            Neighborhood neighborhood)
        {
            Func <Position, IEnumerable <Position> > getNeighborhood =
                neighborhood == Neighborhood.Moore
                    ? PositionExtensions.GetMooreNeighbors
                    : PositionExtensions.GetVonNeumannNeighbors;

            HashSet <Position> remainingPositions = new(area);
            List <IReadOnlySet <Position> > edges = new();

            // Find outer edge

            var outerEdge = remainingPositions.Where(p => getNeighborhood(p).Any(p => !area.Contains(p))).ToHashSet();

            edges.Add(outerEdge);
            remainingPositions.ExceptWith(outerEdge);

            // Find remaining boundaries

            while (remainingPositions.Any())
            {
                var lastEdge = edges.Last();

                var edge = remainingPositions.Where(p => getNeighborhood(p).Any(lastEdge.Contains)).ToHashSet();
                edges.Add(edge);
                remainingPositions.ExceptWith(edge);
            }

            return(edges);
        }
Beispiel #30
0
    // Use this for initialization
    void Start()
    {
        content      = transform.Find("Viewport/Content").gameObject;
        buttonPrefab = (GameObject)Resources.Load("NButton");
        localPlayer  = FindObjectOfType <Player> ().localPlayer;
        localPlayer.controlsAllowed(false);
        cancel = content.transform.Find("Cancel").GetComponent <Button> ();
        hoods  = localPlayer.getNeighborhoods();
        ypos   = cancel.transform.position.y;

        cancel.onClick.AddListener(delegate {
            localPlayer.controlsAllowed(true);
            Destroy(this.gameObject);
        });

        foreach (Neighborhood n in hoods)
        {
            ypos -= BUTTON_HEIGHT;
            GameObject tmp = (GameObject)Instantiate(buttonPrefab);
            tmp.transform.SetParent(content.transform, false);
            tmp.transform.position = new Vector3(cancel.transform.position.x, ypos, cancel.transform.position.z);
            Button tmpButton = tmp.GetComponent <Button> ();
            Text   t         = tmpButton.transform.Find("Text").GetComponent <Text> ();
            t.text = n.buildingName;
            Neighborhood tmpN = n;
            tmpButton.onClick.AddListener(delegate {
                localPlayer.CmdAddToNeighborhood(localPlayer.netId, localPlayer.targetObject.netId, tmpN.netId);
                localPlayer.controlsAllowed(true);
                Destroy(this.gameObject);
            });
        }
    }
Beispiel #31
0
    void Awake()
    {
        neighborhood = GetComponent <Neighborhood>();
        rigid        = GetComponent <Rigidbody>();

        //losowe polozenie poczatkowe
        pos = Random.insideUnitSphere * Spawner.S.spawnRadius;
        //losowa predkosc poczatkowa
        Vector3 vel = Random.onUnitSphere * Spawner.S.velocity;

        rigid.velocity = vel;

        LookAhead();

        //losowy kolor dla boida, lecz upewnij sie zeby nie byl zbyt ciemny
        Color randColor = Color.black;

        while (randColor.r + randColor.g + randColor.b < 1.0f)
        {
            randColor = new Color(Random.value, Random.value, Random.value);
        }
        Renderer[] rends = gameObject.GetComponentsInChildren <Renderer>();
        foreach (Renderer r in rends)
        {
            r.material.color = randColor;
        }
        TrailRenderer tRend = GetComponent <TrailRenderer>();

        tRend.material.SetColor("_TinTColor", randColor);
    }
        public void TestNeighborhoodCtor()
        {
            var nbrhd = new Neighborhood<double>(2);
            nbrhd.ApplyRadiusFunc<double>(v=>v);

            foreach (var ps in nbrhd.ToElementsColumnMajor())
            {
                Debug.WriteLine("{0} {1} {2}", ps.X, ps.Y, ps.Val);
            }
        }
Beispiel #33
0
 // Update is called once per frame
 void Update()
 {
     if (UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject())
         return;
     RaycastHit hit;
     var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
     var hasHit = false;
     if (hasHit = Physics.Raycast(ray, out hit, 100.0f))
     {
         if (hit.collider.tag == "Neighborhood")
         {
             var block = hit.collider.GetComponent<Neighborhood>();
             foreach (var c in InfoPanel.GetComponentsInChildren<Text>())
             {
                 switch (c.gameObject.name)
                 {
                     case "Name":
                         c.text = block.Name;
                         break;
                     case "DealerName":
                         if (block.FriendlyDealer != null)
                             c.text = block.FriendlyDealer.Name;
                         else
                             c.text = "Unoccupied";
                         break;
                     case "Respect":
                         if (block.FriendlyDealer != null)
                             c.text = Mathf.RoundToInt(block.Respect[block.FriendlyDealer.ID] * 100f).ToString() + "%";
                         else
                             c.text = "??%";
                         break;
                 }
             }
             if (Input.GetMouseButtonUp(0))
             {
                 SelectedNeighborhood = block;
                 BuyerPanel.SetActive(true);
                 //Camera.main.GetComponent<CameraInteraction>().CenterPoint = new Vector3(block.transform.position.x, 0, block.transform.position.z);
             }
         }
     }
     if (!hasHit && Input.GetMouseButtonDown(0))
     {
         SelectedNeighborhood = null;
         BuyerPanel.SetActive(false);
     }
 }
Beispiel #34
0
    void AffectRespect(float Amount, Neighborhood block)
    {
        var neighborBlocks = Manager.City.Neighborhoods.Where(ne => Vector3.Distance(ne.transform.position, block.transform.position) < 20).ToList();
        neighborBlocks.Remove(block);
        block.Respect[ID] += Amount;
        block.Respect[ID] = Mathf.Clamp(block.Respect[ID], 0, 1);

        for (int u = 1; u < Manager.Dealers.Where(d => d != this).ToList().Count; u++)
        {
            block.Respect[Manager.Dealers[u].ID] -= Amount / 2f;
            block.Respect[Manager.Dealers[u].ID] = Mathf.Clamp(block.Respect[Manager.Dealers[u].ID], 0, 1);
        }
        foreach (var n in neighborBlocks)
        {
            n.Respect[ID] += Amount / 2f;
            n.Respect[ID] = Mathf.Clamp(n.Respect[ID], 0, 1);
            for (int u = 1; u < Manager.Dealers.Where(d => d != this).ToList().Count; u++)
            {
                n.Respect[Manager.Dealers[u].ID] -= Amount / 4f;
                n.Respect[Manager.Dealers[u].ID] = Mathf.Clamp(n.Respect[Manager.Dealers[u].ID], 0, 1);
            }
        }
    }
Beispiel #35
0
 Neighborhood GetLivingNeighbors(int row, int column)
 {
     row = row - 1;
     column = column - 1;
     var neighbors = new Neighborhood();
     var cell = cells[row*Width + column];
     cell.AddIfLiving(neighbors);
     return neighbors;
 }
Beispiel #36
0
 // Use this for initialization
 void Start()
 {
     neighborhood = GetComponent<Neighborhood>();
     AvailableBuyers = new List<Buyer>();
     StartCoroutine("MakeBuyer");
 }